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

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "David Hilsee" <davidhilseenews AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
References: <3C624DA4 DOT CDAF6FC3 AT bigfoot DOT com> <3C62529F DOT D7F259FA AT bigfoot DOT com>
Subject: Re: Error with bind2nd() and ptr_fun()
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <J%t88.50321$8d1.13189767@news1.rdc1.md.home.com>
Date: Thu, 07 Feb 2002 12:00:41 GMT
NNTP-Posting-Host: 68.49.80.44
X-Complaints-To: abuse AT home DOT net
X-Trace: news1.rdc1.md.home.com 1013083241 68.49.80.44 (Thu, 07 Feb 2002 04:00:41 PST)
NNTP-Posting-Date: Thu, 07 Feb 2002 04:00:41 PST
Organization: Excite AT Home - The Leader in Broadband http://home.com/faster
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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


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