Topic: Why no classes for const mem_fun's in <functional> ?
Author: Biju Thomas <bijuthom@ibm.net>
Date: 1998/11/22 Raw View
Dave Lorde wrote:
>
> I recently had need of the STL mem_fun and mem_fun1 functionality for
> adaptor iterators I was writing, but discovered that const member
> functions were not supported (not without a nasty reinterpret_cast).
>
> When I copied the non-const mem_fun classes and functions, and converted
> them to support const member functions, all worked as expected.
>
> Is there a good reason for this omission, or did someone just get fed up
> with it half way through?
>
There are no omissions. There are versions of mem_fun such as the
following in the standard: (20.3/1)
template < class T, class S > class const_mem_fun_t;
template < class T, class S >
const_mem_fun_t<T,S> mem_fun ( S (T::*f)() const );
Similarly for mem_fun1.
(It is not there in CD2, but in the standard, so I think this was a
recent addition, and, probably, your compiler might not have the time to
catch up.)
Regards,
Biju Thomas
[ 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 ]
Author: Dave Lorde <dlorde@cix.compulink.co.uk>
Date: 1998/11/23 Raw View
OK, thanks Biju, looks like I need an updated copy of the Standard
Library docs and an updated copy of the Standard Library code...
Dave
--
Using Virtual Access
http://www.ashmount.com/va
[ 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 ]
Author: sbnaran@localhost.localdomain (Siemel Naran)
Date: 1998/11/24 Raw View
On 23 Nov 1998 02:55:29 GMT, Dave Lorde <dlorde@cix.compulink.co.uk> wrote:
>OK, thanks Biju, looks like I need an updated copy of the Standard
>Library docs and an updated copy of the Standard Library code...
This stuff is explained in Stroustrup III, which is the first book
I'd recommend to a beginner/intermediate/advanced programmer. If
you're into language lawyer stuff, you can get the new standard
for under $20 (half the price of Stroustrup's book) at:
http://webstore.ansi.org/ansidocstore/default.asp
I've found that the text is somewhat difficult to navigate, and
you also can't use copy and paste (ie, copy text from the doc
to somewhere else, like for posting to this newsgroup).
--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.edu)
----------------------------------
---
[ 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 ]
Author: Dave Lorde <dlorde@cix.compulink.co.uk>
Date: 1998/11/20 Raw View
I recently had need of the STL mem_fun and mem_fun1 functionality for
adaptor iterators I was writing, but discovered that const member
functions were not supported (not without a nasty reinterpret_cast).
When I copied the non-const mem_fun classes and functions, and converted
them to support const member functions, all worked as expected.
Is there a good reason for this omission, or did someone just get fed up
with it half way through?
Dave Lorde
dlorde@cix.compulink.co.uk
--
Using Virtual Access
http://www.ashmount.com/va
---
[ 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 ]