This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [1.0.3] "type reference to reference type" gives internal 364
- To: Robert Bihlmeyer <robbe at orcus dot priv dot at>
- Subject: Re: [1.0.3] "type reference to reference type" gives internal 364
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 28 Sep 1998 20:55:58 -300
- Cc: egcs-bugs at cygnus dot com
- References: <ws1zoxts0w.fsf@orcus.priv.at>
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