This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/50320] New: Calling tr1 binder with constant expression fails
- From: "martinhaefner at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Sep 2011 12:41:03 +0000
- Subject: [Bug libstdc++/50320] New: Calling tr1 binder with constant expression fails
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50320
Bug #: 50320
Summary: Calling tr1 binder with constant expression fails
Classification: Unclassified
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: martinhaefner@web.de
The following code fragment does yield a compiler error:
#include <tr1/functional>
void f(int i)
{
// do something
}
template<typename BinderT>
void call(BinderT b)
{
// int i = 42; b(i); // <--- would be ok
b(42); // <--- compiler error
}
int main()
{
call(std::tr1::bind(f, std::tr1::placeholders::_1));
return 0;
}
mmes@ubuntu:~$ g++-4.4 bind.cpp
bind.cpp: In function âvoid call(BinderT) [with BinderT = std::tr1::_Bind<void
(*(std::tr1::_Placeholder<1>))(int)>]â:
bind.cpp:17: instantiated from here
bind.cpp:12: error: no match for call to â(std::tr1::_Bind<void
(*(std::tr1::_Placeholder<1>))(int)>) (int)â
/usr/include/c++/4.4/tr1_impl/functional:1189: 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 = void (*)(int), _Bound_args = std::tr1::_Placeholder<1>]
/usr/include/c++/4.4/tr1_impl/functional:1200: 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 = void (*)(int), _Bound_args = std::tr1::_Placeholder<1>]
/usr/include/c++/4.4/tr1_impl/functional:1212: 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 = void (*)(int), _Bound_args =
std::tr1::_Placeholder<1>]
/usr/include/c++/4.4/tr1_impl/functional:1225: 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 = void (*)(int), _Bound_args =
std::tr1::_Placeholder<1>]
While calling the binder with a variable works perfectly. I am expecting that
binding a constant expression also works (as done by boost binders).
Regards,
Martin