www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/07/07:30:06

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Alex Vinokur <alexvn AT bigfoot DOT com>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: Error with bind2nd() and ptr_fun()
Date: Thu, 07 Feb 2002 14:18:24 +0200
Lines: 53
Message-ID: <3C62708F.18766A42@bigfoot.com>
References: <3C624DA4 DOT CDAF6FC3 AT bigfoot DOT com> <3C62529F DOT D7F259FA AT bigfoot DOT com> <J%t88.50321$8d1 DOT 13189767 AT news1 DOT rdc1 DOT md DOT home DOT com>
NNTP-Posting-Host: 62.90.123.5
Mime-Version: 1.0
X-Trace: fu-berlin.de 1013084298 44693658 62.90.123.5 (16 [79865])
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


David Hilsee wrote:

> <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]

>
>
> 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.
>
>

[snip]

Thanks.


We can see that function
 void foo1 (AAA& a)  {a.set_value (a.get_value() + 100);}
can be used in for_each  ()

So, what about
void foo2 (AAA& a, int n) { a.set_value (a.get_value() + n); } ?

Is there any way to do what I want to ?

  ===========================
  Alex Vinokur
    mailto:alexvn AT bigfoot DOT com
    mailto:alexvnw AT yahoo DOT com
    http://up.to/alexvn
    http://go.to/alexv_math
  ===========================


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019