Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-10-10 15:44:35


Terje Slettebø <tslettebo_at_[hidden]> writes:

>>From: "Terje Slettebø" <tslettebo_at_[hidden]>
>>
>> This way, we get:
>>
>> copy<c_list>(std::back_inserter(r_list));
>>
>> Output of a compile-time sequence is also trivial:
>>
>> copy<c_list>(std::ostream_iterator<int>(std::cout,","));
>
> Thinking about this some more, the only reason this works is that the
> sequence consists of elements of the same type (integral_c derived), and
> that it has an implicit conversion to the value type.
>
> However, it would also be possible to support heterogenous sequences, but
> then, the standard iterator adapters aren't sufficient, as they only work
> for homogenous sequences. That's possible to make, though.
>
> For fun, I knocked up this program, which stores values of a variety of
> types in a compile-time sequence (char, int, double, rational_c and
> std::string (wrapped)), prints the sequence out, copies it to a run-time
> sequence (using boost::variant as element type), and prints it out,
> again.

You seem to be treading heavily into the territory of boost::fusion
here, no?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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