#include <functional>
#include <iostream>
void print(const char* string)
{
std::cout << string << std::endl;
}
int main(int argc, char ** argv)
{
auto printFunction = std::bind(&print, std::placeholders::_1);
printFunction("hello from print bind");
auto lambda = [] (std::function<void(const char*)> printParamFunc) {
printParamFunc("hello from print from std::function");
};
auto f2 = std::bind(lambda, printFunction);
f2();
}
ICAgICNpbmNsdWRlIDxmdW5jdGlvbmFsPgogICAgI2luY2x1ZGUgPGlvc3RyZWFtPgogICAgIAogICAgdm9pZCBwcmludChjb25zdCBjaGFyKiBzdHJpbmcpCiAgICB7CiAgICAgIHN0ZDo6Y291dCA8PCBzdHJpbmcgPDwgc3RkOjplbmRsOwogICAgfQogICAgIAogICAgaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKiogYXJndikKICAgIHsKICAgICAgYXV0byBwcmludEZ1bmN0aW9uID0gc3RkOjpiaW5kKCZwcmludCwgc3RkOjpwbGFjZWhvbGRlcnM6Ol8xKTsKICAgICAKICAgICAgcHJpbnRGdW5jdGlvbigiaGVsbG8gZnJvbSBwcmludCBiaW5kIik7CiAgICAgCiAgICAgIGF1dG8gbGFtYmRhID0gW10gKHN0ZDo6ZnVuY3Rpb248dm9pZChjb25zdCBjaGFyKik+IHByaW50UGFyYW1GdW5jKSB7CiAgICAgICAgcHJpbnRQYXJhbUZ1bmMoImhlbGxvIGZyb20gcHJpbnQgZnJvbSBzdGQ6OmZ1bmN0aW9uIik7CiAgICAgIH07CiAgICAgCiAgICAgIGF1dG8gZjIgPSBzdGQ6OmJpbmQobGFtYmRhLCBwcmludEZ1bmN0aW9uKTsKICAgICAgZjIoKTsKICAgIH0=
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>()(
^