This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++/5012: cannot instantiate std::binder1st<std::mem_fun1_t<void, unary_functor<const int&, void\>, const int&> >


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]