Boost logo

Boost :

From: Yitzhak Sapir (yitzhaks_at_[hidden])
Date: 2002-10-07 11:56:49


I had meant to post all future replies with a different mailer that would
do proper formatting. This reply contains newlines :) Sorry about that.
It also contains a little more explanation about how it would work.

> -----Original Message-----
> From: Thorsten Ottosen [mailto:nesotto_at_[hidden]]
> Sent: Monday, October 07, 2002 2:00 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Re: new initialization lib, any interest?
>
>
>
> ----- Original Message -----
> From: "Dirk Gerrits" <dirk_at_[hidden]>
> > vector<int> primes;
> > set_cont( v ) += 1, 2, 3, 5, 7, 11;
> >
> > isn't 'really' an initialization.
> > The vector gets default constructed
> > first.
> that's right. but the term is used in the more broad sence
> "to set up a
> starting configuration".
>

Why not make an iterator adaptor (initialization_iterator?) that holds a
list of values with which to initialize. And then pass it to any of the
STL containers. (I can post my implementation if it's interesting):

        std::list<int> primes(
                make_init_iterator<int>(2)(3)(5)(7)(11)(),
                make_init_iterator<int>());

make_init_iterator<> in this case returns two different things. The
default constructor returns an end-marker iterator. The non-default
constructor returns a special object to which initialization values are
fed in, starting with the value given in the parameter. This special
object has an operator()(void) that returns an iterator containing all
those initialization values. This way () acts as an "end of list" marker
in both cases.


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