Boost logo

Boost :

From: Ben FrantzDale (benfrantzdale_at_[hidden])
Date: 2007-01-29 23:46:34


On 1/16/07, shunsuke <pstade.mb_at_[hidden]> wrote:
>
> Ben FrantzDale 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
> the
> > above metafunction to create typedefs for const_pFoo and const_pBar,
> 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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk