bluebird图书馆似乎自动使用$ g++ --version
g++ (GCC) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ -std=c++14 -Wall -lpthread src/test.cpp -o bin/test
src/test.cpp: In instantiation of ‘std::future<void> test::async_rf(Args ...) [with Args = {int}]’:
src/test.cpp:35:29: required from here
src/test.cpp:23:27: error: no matching function for call to ‘async(<unresolved overloaded function type>, test*, int)’
return std::async (&test::rf, this, std::forward<Args>(args)...);
^
In file included from src/test.cpp:1:0:
/usr/include/c++/5.1.0/future:1703:5: note: candidate: template<class _Fn, class ... _Args> std::future<typename std::result_of<_Functor(_ArgTypes ...)>::type> std::async(std::launch, _Fn&&, _Args&& ...)
async(launch __policy, _Fn&& __fn, _Args&&... __args)
^
/usr/include/c++/5.1.0/future:1703:5: note: template argument deduction/substitution failed:
src/test.cpp:23:27: note: cannot convert ‘&((test*)this)->*test::rf’ (type ‘<unresolved overloaded function type>’) to type ‘std::launch’
return std::async (&test::rf, this, std::forward<Args>(args)...);
^
In file included from src/test.cpp:1:0:
/usr/include/c++/5.1.0/future:1723:5: note: candidate: template<class _Fn, class ... _Args> std::future<typename std::result_of<_Functor(_ArgTypes ...)>::type> std::async(_Fn&&, _Args&& ...)
async(_Fn&& __fn, _Args&&... __args)
^
/usr/include/c++/5.1.0/future:1723:5: note: template argument deduction/substitution failed:
src/test.cpp:23:27: note: couldn't deduce template parameter ‘_Fn’
return std::async (&test::rf, this, std::forward<Args>(args)...);
^
两者作为&#34; map&#34;和&#34; flatMap&#34;在承诺上,例如看这个例子。
Promise::then
答案 0 :(得分:13)
这是es6 Promise API的合约吗?
是的,它是由Promises/A+建立的合同,并从那里开始进入ES6规范。您会找到一些讨论here,here和here。