From: Ross Smith (r-smith_at_[hidden])
Date: 2002-10-08 02:20:58
On Tuesday, 08 October 2002 06:26, Rozental, Gennadiy wrote:
> > 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>());
> I like this idea. But proposed interface look like a waste since all
> of the argument are know at compile time.
> I would rather preper:
> std::list<int> primes(
> make_init_iterator<int, mpl::ct_list<2,3,5,7,11> >(),
> For exact syntax consult MPL list specification.
The big advantage of the (2)(3)(5) notation over both the <2,3,5> and
the "2,3,5" forms is that it works for _any_ (copyable) type. "2,3,5"
only works for numbers and strings (and anything else you explicitly
code a special case for), and <2,3,5> only works for integers.
-- Ross Smith ......... r-smith_at_[hidden] ......... Auckland, New Zealand "I'm deeply concerned about a leader who has ignored the United Nations for all these years, refused to conform to resolution after resolution after resolution, who has weapons of mass destruction." -- George W. Bush, Jr.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk