Mail Archives: djgpp/2002/02/07/07:15:10
<snip>
> Here is a program and compilation results.
>
> The compiler detects some error
> and informs about "Internal compiler error".
>
> Is there an error in my program?
>
<snip>
> for_each(vect.begin(), vect.end(), bind2nd(ptr_fun(foo2), 200)); //
> Line#53
<snip>
> d:/sys/djgpp/lang/cxx/stl_function.h: In instantiation of
> `binder2nd<pointer_to_binary_function<AAA &,int,int> >':
> d:/sys/djgpp/lang/cxx/stl_function.h:231: instantiated from
> `bind2nd<pointer_to_binary_function<AAA &,int,int>, int>(const
> pointer_to_binary_function<AAA &,int,int> &, const int &)'
> aaa.c:53: instantiated from here
> d:/sys/djgpp/lang/cxx/stl_function.h:223: forming reference to reference
> type `AAA &const'
<snip>
This message pretty mch says it: you're forming a reference to a reference.
The problem is that the binder that results from bind2nd tries to take the
argument in its operator() (the first parameter of the function) by
reference. That parameter, in your code, is already a reference, and that
makes it try to generate a reference to a reference, which isn't allowed.
Boost tries to overcome this, BTW, and has a brief section explaining
references to references.
http://www.boost.org/libs/functional/index.html
--
David Hilsee
- Raw text -