#include <iostream>
#include <memory>
struct foo
{
foo(uint32_t)
{ }
};
int main() {
auto f = std::bind(std::make_shared<foo, uint32_t>, 3U);
auto o = f();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5PgoKc3RydWN0IGZvbwp7Cglmb28odWludDMyX3QpCgl7IH0KfTsKCmludCBtYWluKCkgewoJCglhdXRvIGYgPSBzdGQ6OmJpbmQoc3RkOjptYWtlX3NoYXJlZDxmb28sIHVpbnQzMl90PiwgM1UpOwoJYXV0byBvID0gZigpOwoJCglyZXR1cm4gMDsKfQ==
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>()(
^