fork(3) download
  1. #include <iostream>
  2. #include <functional>
  3. #include <future>
  4.  
  5. template<class Fn, class... Args>
  6. inline auto runAsyncTerminateOnException(Fn&& fn, Args&&... args) {
  7. auto make_call = std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...);
  8.  
  9. return std::async(std::launch::async, [=]() -> decltype(make_call()) {
  10. try {
  11. return make_call();
  12. } catch (...) {
  13. std::cout << "Terminate Called!" << std::endl;
  14. std::terminate();
  15. }
  16. });
  17. }
  18.  
  19. struct Foo {
  20. template<class... Args>
  21. void print(Args&&... args) {
  22. printf("Foo::print(%d)\n", std::forward<Args>(args)...);
  23. }
  24. };
  25.  
  26. int main() {
  27. Foo foo;
  28. std::future<void> future = runAsyncTerminateOnException(&Foo::print<int>, &foo, 2);
  29. // your code goes here
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 7576KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'auto runAsyncTerminateOnException(Fn&&, Args&& ...) [with Fn = void (Foo::*)(int&&); Args = {Foo*, int}]':
prog.cpp:28:86:   required from here
prog.cpp:9:70: error: no match for call to '(std::_Bind<std::_Mem_fn<void (Foo::*)(int&&)>(Foo*, int)>) ()'
     return std::async(std::launch::async, [=]() -> decltype(make_call()) {
                                                                      ^
In file included from prog.cpp:2:0:
/usr/include/c++/5/functional:1129:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args)
  ^
/usr/include/c++/5/functional:1129:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: error: no match for call to '(std::_Mem_fn<void (Foo::*)(int&&)>) (Foo*&, int&)'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo*&, std::tuple<> >((* & std::declval<Foo*&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo*') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo*&, std::tuple<> >((* & std::declval<Foo*&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo*') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:1143:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args) const
  ^
/usr/include/c++/5/functional:1143:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: error: no match for call to '(const std::_Mem_fn<void (Foo::*)(int&&)>) (Foo* const&, const int&)'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const&, std::tuple<> >((* & std::declval<Foo* const&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const&, std::tuple<> >((* & std::declval<Foo* const&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:1157:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args) volatile
  ^
/usr/include/c++/5/functional:1157:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: error: no match for call to '(volatile std::_Mem_fn<void (Foo::*)(int&&)>) (Foo* volatile&, volatile int&)'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* volatile&, std::tuple<> >((* & std::declval<Foo* volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* volatile&, std::tuple<> >((* & std::declval<Foo* volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:1171:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args) const volatile
  ^
/usr/include/c++/5/functional:1171:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: error: no match for call to '(const volatile std::_Mem_fn<void (Foo::*)(int&&)>) (Foo* const volatile&, const volatile int&)'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const volatile&, std::tuple<> >((* & std::declval<Foo* const volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const volatile&, std::tuple<> >((* & std::declval<Foo* const volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
prog.cpp: In instantiation of 'struct runAsyncTerminateOnException(Fn&&, Args&& ...) [with Fn = void (Foo::*)(int&&); Args = {Foo*, int}]::<lambda>':
prog.cpp:9:22:   required from 'auto runAsyncTerminateOnException(Fn&&, Args&& ...) [with Fn = void (Foo::*)(int&&); Args = {Foo*, int}]'
prog.cpp:28:86:   required from here
prog.cpp:9:70: error: no match for call to '(std::_Bind<std::_Mem_fn<void (Foo::*)(int&&)>(Foo*, int)>) ()'
     return std::async(std::launch::async, [=]() -> decltype(make_call()) {
                                                                      ^
In file included from prog.cpp:2:0:
/usr/include/c++/5/functional:1129:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args)
  ^
/usr/include/c++/5/functional:1129:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: error: no match for call to '(std::_Mem_fn<void (Foo::*)(int&&)>) (Foo*&, int&)'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo*&, std::tuple<> >((* & std::declval<Foo*&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo*') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo*&, std::tuple<> >((* & std::declval<Foo*&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo*') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1125:38: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
  = decltype( std::declval<_Functor>()(
                                      ^
/usr/include/c++/5/functional:1143:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args) const
  ^
/usr/include/c++/5/functional:1143:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: error: no match for call to '(const std::_Mem_fn<void (Foo::*)(int&&)>) (Foo* const&, const int&)'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const&, std::tuple<> >((* & std::declval<Foo* const&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const&, std::tuple<> >((* & std::declval<Foo* const&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1139:52: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
          typename add_const<_Functor>::type>::type>()(
                                                    ^
/usr/include/c++/5/functional:1157:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args) volatile
  ^
/usr/include/c++/5/functional:1157:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: error: no match for call to '(volatile std::_Mem_fn<void (Foo::*)(int&&)>) (Foo* volatile&, volatile int&)'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* volatile&, std::tuple<> >((* & std::declval<Foo* volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* volatile&, std::tuple<> >((* & std::declval<Foo* volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1153:69: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
                        typename add_volatile<_Functor>::type>::type>()(
                                                                     ^
/usr/include/c++/5/functional:1171:2: note: candidate: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = std::_Mem_fn<void (Foo::*)(int&&)>; _Bound_args = {Foo*, int}]
  operator()(_Args&&... __args) const volatile
  ^
/usr/include/c++/5/functional:1171:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: error: no match for call to '(const volatile std::_Mem_fn<void (Foo::*)(int&&)>) (Foo* const volatile&, const volatile int&)'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
/usr/include/c++/5/functional:582:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:582:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const volatile&, std::tuple<> >((* & std::declval<Foo* const volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class& {aka Foo&}'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
/usr/include/c++/5/functional:589:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class&&, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:589:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: note:   cannot convert 'std::_Mu<Foo*, false, false>().std::_Mu<_Arg, false, false>::operator()<Foo* const volatile&, std::tuple<> >((* & std::declval<Foo* const volatile&>()), (* & std::declval<std::tuple<>&>()))' (type 'Foo* const volatile') to type 'std::_Mem_fn_base<void (Foo::*)(int&&), true>::_Class&& {aka Foo&&}'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
/usr/include/c++/5/functional:599:2: note: candidate: template<class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::_Class*, _Args&& ...) const [with _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Class* __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:599:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:607:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(_Tp&&, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(_Tp&& __object, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:607:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:618:2: note: candidate: template<class _Tp, class ... _Args, class _Req> std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::result_type std::_Mem_fn_base<_MemFunPtr, __is_mem_fn>::operator()(std::reference_wrapper<_Tp>, _Args&& ...) const [with _Tp = _Tp; _Args = {_Args ...}; _Req = _Req; _MemFunPtr = void (Foo::*)(int&&); bool __is_mem_fn = true]
  operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
  ^
/usr/include/c++/5/functional:618:2: note:   template argument deduction/substitution failed:
/usr/include/c++/5/functional:1167:63: note:   mismatched types 'std::reference_wrapper<_Tp>' and 'Foo*'
                        typename add_cv<_Functor>::type>::type>()(
                                                               ^
prog.cpp: In instantiation of 'auto runAsyncTerminateOnException(Fn&&, Args&& ...) [with Fn = void (Foo::*)(int&&); Args = {Foo*, int}]':
prog.cpp:28:86:   required from here
prog.cpp:9:43: error: could not convert '<brace-enclosed initializer list>()' from '<brace-enclosed initializer list>' to 'std::_Bind<std::_Mem_fn<void (Foo::*)(int&&)>(Foo*, int)>'
     return std::async(std::launch::async, [=]() -> decltype(make_call()) {
                                           ^
prog.cpp: In function 'int main()':
prog.cpp:28:60: error: conversion from 'void' to non-scalar type 'std::future<void>' requested
     std::future<void> future = runAsyncTerminateOnException(&Foo::print<int>, &foo, 2);
                                                            ^
stdout
Standard output is empty