Topic: Why no const variants of mem_fun?
Author: bs@research.att.com (Bjarne Stroustrup)
Date: 1997/10/04 Raw View
Jean-Louis Leroy <jll@skynet.be>
> the mem_fun family of adapters and helper functions all work only with
> non-const member functions, it seems. Why is it so?
An oversight. I expect the const versions will be added (as they already
are in some (most?) implementations.
- Bjarne
Bjarne Stroustrup, AT&T Labs, http://www.research.att.com/~bs
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Jean-Louis Leroy <jll@skynet.be>
Date: 1997/10/06 Raw View
In article <EHJrDE.FH0@research.att.com>, Bjarne Stroustrup wrote:
> I expect the const versions will be added (as they already
> are in some (most?) implementations.
Neither the Visual C++ 5.0 nor the latest version of Kai C++ have them.
Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Jean-Louis Leroy <jll@skynet.be>
Date: 1997/10/01 Raw View
Hello,
the mem_fun family of adapters and helper functions all work only with
non-const member functions, it seems. Why is it so? `const' versions
seem
a good thing to have, especially for functions taking no argument. For
example:
class person
{
public:
string name() const;
// ...
};
vector<person*> simpsons;
// ...
transform(simpsons.begin(), simpsons.end(),
ostream_iterator<string>(cout, "\n"), mem_fun(&person::name));
I wrote a const_mem_fun family myself, but it seems that this omission
may discourage some people from using `const'.
Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]