Nested std::tr1::bind problem

Peter Dimov pdimov@mmltd.net
Thu Mar 13 13:48:00 GMT 2008


Rodolfo Lima:

> Hi, I'm playing a little bit with std::tr1::bind and found that the 
> following code doesn't compile:
>
> bind(std::multiplies<int>(), _1, bind(std::minus<int>(), 6, _2))(1,2);
>
> but the following does:
>
> int one=1, two=2;
> bind(std::multiplies<int>(), _1, bind(std::minus<int>(), 6, _2))(one,two);
>
> The error in the first code is:
>
> error: no match for call to '(std::_Bind<std::multiplies<int> 
> ()(std::_Placeholder<1>, std::_Bind<std::minus<int> ()(int, 
> std::_Placeholder<2>)>)>) (int, int)'
> /usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/tr1_impl/functional:1189: 
> note: candidates are: typename std::result_of<_Functor ()(typename 
> std::result_of<std::_Mu<_Bound_args, std::is_bind_expression::value, 
> (std::is_placeholder::value > 0)> ()(_Bound_args, std::tuple<_UElements 
> ...>)>::type ...)>::type std::_Bind<_Functor ()(_Bound_args 
> ...)>::operator()(_Args& ...) [with _Args = int, int, _Functor = 
> std::multiplies<int>, _Bound_args = std::_Placeholder<1>, 
> std::_Bind<std::minus<int> ()(int, std::_Placeholder<2>)>]

_Args&... should probably be changed to _Args&&..., with the appropriate 
std::forward<_Args> inserted in the body if it isn't there already. 



More information about the Libstdc++ mailing list