Thorsten Ottosen wrote:
MB wrote:
Sebastian Redl wrote:
I think 'add_const' is reserved for Boost.TypeTraits.
I post this tiny proposal to Boost.Devel anyway.
When we discussed the wg21 proposal many months ago and I added const_begin() etc to boost.range, Dave Abrahams used this function
template< class T > inline T const& as_const( T const& r ) { return r; }
I found the thread. http://lists.boost.org/Archives/boost/2004/09/72340.php Maybe the time has come? :-) A range algorithm like Boost.StringAlgorithm no longer allows users to call 'const_begin/end'. Now that something like 'as_const' is really needed. boost::for_each( rng | const_qualified | // protect rng! reversed | null_terminated | tab_expanded | utf8_decoded | transformed(toZero()), &do_something ); I think 'const_rbegin' is obviously blob ;-)
Similarly, we might add
as_volatile(); as_const_volatile(); as_mutable();
The latter would be a cast from rvalue to lvalue like it happens in boost.foreach.
Beyond my sight. Is it possible such conversion? Regards, MB p-stade.sourceforge.net