
On 1/16/07, shunsuke <pstade.mb@gmail.com> wrote:
I've been using Boost increasingly in my work and am loving it. There are two utilities I've beens surprised Boost lacks:
First, I would like to see an "insert_const" metafunction that would work like this: template <typename T> struct insert_const<T*> { typedef typename add_const<T>::type* type; };
That is, it would insert a const into the thing pointed to by a pointer type. (I am interfacing with a C-style interface to C++ code. The interface passes around "pFoo" and "pBar" – pointers to Foos and Bars. I've used
above metafunction to create typedefs for const_pFoo and const_pBar,
Ben FrantzDale wrote: the like
so: typedef typename<insert_const<pFoo> >::type const_pFoo; typedef typename<insert_const<pBar> >::type const_pBar; Would this be a desirable addition?
Maybe something like 'constant_iterator' adaptor seems to be more generic?
I'm not sure I follow. Google gives me some hits for "constant_iterator", but not much information. It definitely would be nice to have a way to go from std::vector<foo>::iterator to and from std::vector<foo>::const_iterator and you make a good point that it's the same operation I'm proposing. —Ben