From 7888341722913030896
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a3a3b60483433a25
X-Google-Attributes: gidf78e5,public
From: Darin Adler <darin@bentspoon.com>
Subject: Re: using std::bind2nd and std::mem_fun_ref
Date: 2000/01/02
Message-ID: <B493EE30.ECD6%darin@bentspoon.com>#1/1
X-Deja-AN: 567522767
X-NNTP-Posting-Host: news.newsdawg.com
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <20000101163239.A19301@ddiworld.com>
X-UID: 0000000001
X-Status: $$$T
Content-Type: text/plain; charset="US-ASCII"
Organization: http://extra.newsguy.com
Mime-Version: 1.0
User-Agent: Microsoft Outlook Express Macintosh Edition - 5.01 (1630)
Newsgroups: comp.std.c++
Originator: clamage@taumet


Joel Reed <jreed@ddiworld.COM> wrote:

> I'm using gcc-2.95.2 and am having problems with std::bind2nd.
> 
> it seems that gcc doesn't like:
> 
>     std::for_each(q.begin(), q.end(),
>     std::bind2nd(std::mem_fun_ref(&person::mature), 2));
> 
> i think its because std::bind2nd takes a const Predicate. (really not sure
> though)

This is a flaw in the C++ Standard, not in gcc. There are no versions of
bind2nd and the related templates where the unbound parameters are
non-const. Thus, when you use mem_fun_ref with a non-const member function,
you get a function object that can't be used with bind2nd.

Bjarne Stroustrup noticed this problem and reported it to the C++ Standards
Committee. It is currently under consideration by the library working group
as issue #109, "Missing binders for non-const sequence elements"
<http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#109>.

Note that this comes up in Josuttis's C++ Library book as well. See the
section 8.2.2 part of <http://www.josuttis.com/libbook/errata1_3.html>.

    -- Darin



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




