fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. void print(const char* string)
  5. {
  6. std::cout << string << std::endl;
  7. }
  8.  
  9. int main(int argc, char ** argv)
  10. {
  11. auto printFunction = std::bind(&print, std::placeholders::_1);
  12.  
  13. printFunction("hello from print bind");
  14.  
  15. auto lambda = [] (std::function<void(const char*)> printParamFunc) {
  16. printParamFunc("hello from print from std::function");
  17. };
  18.  
  19. auto f2 = std::bind(lambda, printFunction);
  20. f2();
  21. }
Compilation error #stdin compilation error #stdout 0s 3296KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:20:10: error: no match for call to ‘(std::_Bind<main(int, char**)::__lambda0(std::_Bind<void (*(std::_Placeholder<1>))(const char*)>)>) ()’
       f2();
          ^
In file included from prog.cpp:1:0:
/usr/include/c++/4.8/functional:1280:11: note: candidates are:
     class _Bind<_Functor(_Bound_args...)>
           ^
/usr/include/c++/4.8/functional:1351:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}; _Result = _Result; _Functor = main(int, char**)::__lambda0; _Bound_args = {std::_Bind<void (*(std::_Placeholder<1>))(const char*)>}]
  operator()(_Args&&... __args)
  ^
/usr/include/c++/4.8/functional:1351:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1349:40: error: no match for call to ‘(std::_Mu<std::_Bind<void (*(std::_Placeholder<1>))(const char*)>, true, false>) (std::_Bind<void (*(std::_Placeholder<1>))(const char*)>&, std::tuple<>&)’
       std::declval<tuple<_Args...>&>() )... ) )>
                                        ^
/usr/include/c++/4.8/functional:1131:11: note: candidate is:
     class _Mu<_Arg, true, false>
           ^
/usr/include/c++/4.8/functional:1136:2: note: template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>]
  operator()(_CVArg& __arg,
  ^
/usr/include/c++/4.8/functional:1136:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional: In substitution of ‘template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>] [with _CVArg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>; _Args = {}]’:
/usr/include/c++/4.8/functional:1349:40:   required from here
/usr/include/c++/4.8/functional:1138:39: error: no match for call to ‘(std::_Bind<void (*(std::_Placeholder<1>))(const char*)>) ()’
  -> decltype(__arg(declval<_Args>()...))
                                       ^
/usr/include/c++/4.8/functional:1280:11: note: candidates are:
     class _Bind<_Functor(_Bound_args...)>
           ^
/usr/include/c++/4.8/functional:1351:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args)
  ^
/usr/include/c++/4.8/functional:1351:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1347:37: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
  = decltype( std::declval<_Functor>()(
                                     ^
/usr/include/c++/4.8/functional:1365:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const
  ^
/usr/include/c++/4.8/functional:1365:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1361:53: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
          typename add_const<_Functor>::type>::type>()(
                                                     ^
/usr/include/c++/4.8/functional:1379:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) volatile
  ^
/usr/include/c++/4.8/functional:1379:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1375:70: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_volatile<_Functor>::type>::type>()(
                                                                      ^
/usr/include/c++/4.8/functional:1393:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const volatile
  ^
/usr/include/c++/4.8/functional:1393:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1389:64: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_cv<_Functor>::type>::type>()(
                                                                ^
/usr/include/c++/4.8/functional:1365:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}; _Result = _Result; _Functor = main(int, char**)::__lambda0; _Bound_args = {std::_Bind<void (*(std::_Placeholder<1>))(const char*)>}]
  operator()(_Args&&... __args) const
  ^
/usr/include/c++/4.8/functional:1365:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1363:40: error: no match for call to ‘(std::_Mu<std::_Bind<void (*(std::_Placeholder<1>))(const char*)>, true, false>) (const std::_Bind<void (*(std::_Placeholder<1>))(const char*)>&, std::tuple<>&)’
       std::declval<tuple<_Args...>&>() )... ) )>
                                        ^
/usr/include/c++/4.8/functional:1131:11: note: candidate is:
     class _Mu<_Arg, true, false>
           ^
/usr/include/c++/4.8/functional:1136:2: note: template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>]
  operator()(_CVArg& __arg,
  ^
/usr/include/c++/4.8/functional:1136:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional: In substitution of ‘template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>] [with _CVArg = const std::_Bind<void (*(std::_Placeholder<1>))(const char*)>; _Args = {}]’:
/usr/include/c++/4.8/functional:1363:40:   required from here
/usr/include/c++/4.8/functional:1138:39: error: no match for call to ‘(const std::_Bind<void (*(std::_Placeholder<1>))(const char*)>) ()’
  -> decltype(__arg(declval<_Args>()...))
                                       ^
/usr/include/c++/4.8/functional:1280:11: note: candidates are:
     class _Bind<_Functor(_Bound_args...)>
           ^
/usr/include/c++/4.8/functional:1351:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args)
  ^
/usr/include/c++/4.8/functional:1351:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1347:37: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
  = decltype( std::declval<_Functor>()(
                                     ^
/usr/include/c++/4.8/functional:1365:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const
  ^
/usr/include/c++/4.8/functional:1365:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1361:53: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
          typename add_const<_Functor>::type>::type>()(
                                                     ^
/usr/include/c++/4.8/functional:1379:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) volatile
  ^
/usr/include/c++/4.8/functional:1379:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1375:70: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_volatile<_Functor>::type>::type>()(
                                                                      ^
/usr/include/c++/4.8/functional:1393:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const volatile
  ^
/usr/include/c++/4.8/functional:1393:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1389:64: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_cv<_Functor>::type>::type>()(
                                                                ^
/usr/include/c++/4.8/functional:1379:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = main(int, char**)::__lambda0; _Bound_args = {std::_Bind<void (*(std::_Placeholder<1>))(const char*)>}]
  operator()(_Args&&... __args) volatile
  ^
/usr/include/c++/4.8/functional:1379:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1377:40: error: no match for call to ‘(std::_Mu<std::_Bind<void (*(std::_Placeholder<1>))(const char*)>, true, false>) (volatile std::_Bind<void (*(std::_Placeholder<1>))(const char*)>&, std::tuple<>&)’
       std::declval<tuple<_Args...>&>() )... ) )>
                                        ^
/usr/include/c++/4.8/functional:1131:11: note: candidate is:
     class _Mu<_Arg, true, false>
           ^
/usr/include/c++/4.8/functional:1136:2: note: template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>]
  operator()(_CVArg& __arg,
  ^
/usr/include/c++/4.8/functional:1136:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional: In substitution of ‘template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>] [with _CVArg = volatile std::_Bind<void (*(std::_Placeholder<1>))(const char*)>; _Args = {}]’:
/usr/include/c++/4.8/functional:1377:40:   required from here
/usr/include/c++/4.8/functional:1138:39: error: no match for call to ‘(volatile std::_Bind<void (*(std::_Placeholder<1>))(const char*)>) ()’
  -> decltype(__arg(declval<_Args>()...))
                                       ^
/usr/include/c++/4.8/functional:1280:11: note: candidates are:
     class _Bind<_Functor(_Bound_args...)>
           ^
/usr/include/c++/4.8/functional:1351:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args)
  ^
/usr/include/c++/4.8/functional:1351:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1347:37: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
  = decltype( std::declval<_Functor>()(
                                     ^
/usr/include/c++/4.8/functional:1365:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const
  ^
/usr/include/c++/4.8/functional:1365:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1361:53: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
          typename add_const<_Functor>::type>::type>()(
                                                     ^
/usr/include/c++/4.8/functional:1379:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) volatile
  ^
/usr/include/c++/4.8/functional:1379:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1375:70: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_volatile<_Functor>::type>::type>()(
                                                                      ^
/usr/include/c++/4.8/functional:1393:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const volatile
  ^
/usr/include/c++/4.8/functional:1393:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1389:64: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_cv<_Functor>::type>::type>()(
                                                                ^
/usr/include/c++/4.8/functional:1393:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = main(int, char**)::__lambda0; _Bound_args = {std::_Bind<void (*(std::_Placeholder<1>))(const char*)>}]
  operator()(_Args&&... __args) const volatile
  ^
/usr/include/c++/4.8/functional:1393:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1391:40: error: no match for call to ‘(std::_Mu<std::_Bind<void (*(std::_Placeholder<1>))(const char*)>, true, false>) (const volatile std::_Bind<void (*(std::_Placeholder<1>))(const char*)>&, std::tuple<>&)’
       std::declval<tuple<_Args...>&>() )... ) )>
                                        ^
/usr/include/c++/4.8/functional:1131:11: note: candidate is:
     class _Mu<_Arg, true, false>
           ^
/usr/include/c++/4.8/functional:1136:2: note: template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>]
  operator()(_CVArg& __arg,
  ^
/usr/include/c++/4.8/functional:1136:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional: In substitution of ‘template<class _CVArg, class ... _Args> decltype (__arg((declval<_Args>)()...)) std::_Mu<_Arg, true, false>::operator()(_CVArg&, std::tuple<_Args2 ...>&) const volatile [with _CVArg = _CVArg; _Args = {_Args ...}; _Arg = std::_Bind<void (*(std::_Placeholder<1>))(const char*)>] [with _CVArg = const volatile std::_Bind<void (*(std::_Placeholder<1>))(const char*)>; _Args = {}]’:
/usr/include/c++/4.8/functional:1391:40:   required from here
/usr/include/c++/4.8/functional:1138:39: error: no match for call to ‘(const volatile std::_Bind<void (*(std::_Placeholder<1>))(const char*)>) ()’
  -> decltype(__arg(declval<_Args>()...))
                                       ^
/usr/include/c++/4.8/functional:1280:11: note: candidates are:
     class _Bind<_Functor(_Bound_args...)>
           ^
/usr/include/c++/4.8/functional:1351:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args)
  ^
/usr/include/c++/4.8/functional:1351:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1347:37: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
  = decltype( std::declval<_Functor>()(
                                     ^
/usr/include/c++/4.8/functional:1365:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const
  ^
/usr/include/c++/4.8/functional:1365:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1361:53: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
          typename add_const<_Functor>::type>::type>()(
                                                     ^
/usr/include/c++/4.8/functional:1379:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) volatile
  ^
/usr/include/c++/4.8/functional:1379:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1375:70: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_volatile<_Functor>::type>::type>()(
                                                                      ^
/usr/include/c++/4.8/functional:1393:2: note: template<class ... _Args, class _Result> _Result std::_Bind<_Functor(_Bound_args ...)>::operator()(_Args&& ...) const volatile [with _Args = {_Args ...}; _Result = _Result; _Functor = void (*)(const char*); _Bound_args = {std::_Placeholder<1>}]
  operator()(_Args&&... __args) const volatile
  ^
/usr/include/c++/4.8/functional:1393:2: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/functional:1389:64: error: cannot convert ‘std::_No_tuple_element’ to ‘const char*’ in argument passing
                        typename add_cv<_Functor>::type>::type>()(
                                                                ^
stdout
Standard output is empty