[Bug libstdc++/38238] New: std::tr1::bind fails to compile with pointer to member function
fuscated at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Nov 23 15:56:00 GMT 2008
The following example fails to compile:
#include <tr1/functional>
#include <stdio.h>
using namespace std::tr1::placeholders;
class player
{
public:
void play(int time) { printf("player::play(%d);\n", time);}
void stop() { printf("player::stop();\n"); }
};
int main()
{
player thePlayer;
std::tr1::bind(&player::play, &thePlayer, _1)(2);
return 0;
}
Here is the output of the compiler:
test_bind.cpp: In function Âint main()Â:
test_bind.cpp:19: error: no match for call to
Â(std::tr1::_Bind<std::tr1::_Mem_fn<void (player::*)(int)> ()(player*,
std::tr1::_Placeholder<1>)>) (int)Â
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/tr1_impl/functional:1190:
note: candidates are: typename std::tr1::result_of<_Functor ()(typename
std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value > 0)>
()(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor ()(_Bound_args ...)>::operator()(_Args& ...) [with
_Args = int, _Functor = std::tr1::_Mem_fn<void (player::*)(int)>, _Bound_args =
player*, std::tr1::_Placeholder<1>]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/tr1_impl/functional:1201:
note: typename std::tr1::result_of<const _Functor ()(typename
std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value > 0)>
()(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor ()(_Bound_args ...)>::operator()(_Args& ...) const
[with _Args = int, _Functor = std::tr1::_Mem_fn<void (player::*)(int)>,
_Bound_args = player*, std::tr1::_Placeholder<1>]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/tr1_impl/functional:1213:
note: typename std::tr1::result_of<volatile _Functor
()(typename std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value > 0)>
()(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor ()(_Bound_args ...)>::operator()(_Args& ...) volatile
[with _Args = int, _Functor = std::tr1::_Mem_fn<void (player::*)(int)>,
_Bound_args = player*, std::tr1::_Placeholder<1>]
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/tr1_impl/functional:1226:
note: typename std::tr1::result_of<const volatile _Functor
()(typename std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value > 0)>
()(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor ()(_Bound_args ...)>::operator()(_Args& ...) const
volatile [with _Args = int, _Functor = std::tr1::_Mem_fn<void
(player::*)(int)>, _Bound_args = player*, std::tr1::_Placeholder<1>]
The example compiles fine by replacing tr1::bind with boost::bind.
Best regards,
Teodor Petrov
--
Summary: std::tr1::bind fails to compile with pointer to member
function
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fuscated at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38238
More information about the Gcc-bugs
mailing list