This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/5012: cannot instantiate std::binder1st<std::mem_fun1_t<void, unary_functor<const int&, void\>, const int&> >
- From: paolo at gcc dot gnu dot org
- To: a dot metselaar at math dot utwente dot nl, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org
- Date: 26 Dec 2001 11:57:19 -0000
- Subject: Re: libstdc++/5012: cannot instantiate std::binder1st<std::mem_fun1_t<void, unary_functor<const int&, void\>, const int&> >
- Reply-to: paolo at gcc dot gnu dot org, a dot metselaar at math dot utwente dot nl, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: cannot instantiate std::binder1st<std::mem_fun1_t<void, unary_functor<const int&, void\>, const int&> >
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Wed Dec 26 03:57:19 2001
Responsible-Changed-Why:
Taking care of it
State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Wed Dec 26 03:57:19 2001
State-Changed-Why:
As written, your code leads to a "reference to a reference"
problem, which is definitely *not* a library bug
(according to the standard, 20.3.6.1, binder1st has
typename Operation::result_type
operator()(const typename Operation::second_argument_type& x) const;)
Perhaps would serve your needs a variant like:
#include <functional>
using namespace std;
template <class Arg, class Res>
struct unary_functor : public unary_function<Arg,Res>
{
virtual ~unary_functor() {}
virtual Res operator() (Arg x) =0;
binder1st<mem_fun1_t<Res, unary_functor<Arg,Res>, Arg> >
func()
{ return bind1st(mem_fun(&unary_functor<Arg,Res>::operator()),this); }
} ;
class F : public unary_functor<int,void>
{
void operator() (int i) { return; }
} f;
int main()
{
f.func();
}
???
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5012