fork(2) download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. struct foo
  5. {
  6. foo(uint32_t)
  7. { }
  8. };
  9.  
  10. int main() {
  11.  
  12. auto f = std::bind(std::make_shared<foo, uint32_t>, 3U);
  13. auto o = f();
  14.  
  15. return 0;
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:13: error: no match for call to ‘(std::_Bind<std::shared_ptr<foo> (*(unsigned int))(unsigned int&&)>) ()’
  auto o = f();
             ^
In file included from /usr/include/c++/4.8/memory:79:0,
                 from prog.cpp:2:
/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 = std::shared_ptr<foo> (*)(unsigned int&&); _Bound_args = {unsigned int}]
  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 bind ‘unsigned int’ lvalue to ‘unsigned int&&’
  = 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 = std::shared_ptr<foo> (*)(unsigned int&&); _Bound_args = {unsigned int}]
  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: invalid initialization of reference of type ‘unsigned int&&’ from expression of type ‘const unsigned int’
          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 = std::shared_ptr<foo> (*)(unsigned int&&); _Bound_args = {unsigned int}]
  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: invalid initialization of reference of type ‘unsigned int&&’ from expression of type ‘volatile unsigned int’
                        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 = std::shared_ptr<foo> (*)(unsigned int&&); _Bound_args = {unsigned int}]
  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: invalid initialization of reference of type ‘unsigned int&&’ from expression of type ‘const volatile unsigned int’
                        typename add_cv<_Functor>::type>::type>()(
                                                                ^
stdout
Standard output is empty