Boost logo

Boost :

From: shunsuke (pstade.mb_at_[hidden])
Date: 2007-01-16 21:08:26


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?

> Second, I often find myself wanting to iterate over every element in a
> nested container. For example, a vector<list<double> >. I've made a
> partly-functional nested_iterator class that models ForwardIterator. My
> implementation defaults to use ".begin()" and ".end()" to find the inner
> range, but can be adapted with a function object.
>
> Has anyone considered adding this sort of iterator to Boost?

It seems the one known as "segmented-iterator".
The "boostified" implementation is not found yet, AFAIK.
Adobe implementation is here... http://tinyurl.com/2hmcrw
, and my implementation is here :-)... http://tinyurl.com/35xg2m
Anyway you can upload yours to Vault.

Regards,

-- 
Shunsuke Sogame

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