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]

Re: [1.0.3] "type reference to reference type" gives internal 364


Robert Bihlmeyer <robbe@orcus.priv.at> writes:

> #include <algorithm>
> #include <functional>
> #include <vector>

> void frob(int &a,int b) { a=b-a; }

> int main() { vector<int> v;
>   for_each(v.begin(),v.end(),bind2nd(ptr_fun(frob),4)); }

> Compiling with 1.1b only gives normal errors:

If you know the problem is fixed in egcs 1.1, why are you submitting a 
bug report?

> P.S.: I am conviced that something like the above code *should* be
> possible, but this limitation is in the STL code.

for_each is a non-modifying algorithm, so I wouldn't expect it to
support reference types.  In fact, functors in general don't support
references.  At least, bind* functors don't.

How about:

    transform(v.begin(),v.end(),v.begin(),bind2nd(plus<int>,4));

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



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