Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-04-29 07:33:15

Alexander Nasonov wrote:
> Alternatively, you can implement MPL conformant sequence
> tuple_sequence<Tuple>. It's not so hard as you can imagine.

It's not indeed:

template< typename Tuple > struct tuple_iterator
    typedef mpl::forward_iterator_tag category;
    typedef typename Tuple::head_type type;
    typedef tuple_iterator<typename Tuple::tail_type> next;

// end iterator
template<> struct tuple_iterator<boost::tuples::null_type>
    typedef mpl::forward_iterator_tag category;

template< typename Tuple > struct tuple_sequence
    : mpl::iterator_range<
        , tuple_iterator<boost::tuples::null_type>

// test
typedef boost::tuples::tuple<int,char const*,bool> t;

BOOST_STATIC_ASSERT( mpl::size< tuple_sequence<t> >::type::value == 3 );
    , mpl::list<int,char const*,bool>
>::type::value ));

> (Question to MPL's authors: when it will be documented?).

How to write your own iterator is partially documented here -
And then there is a reference doc -

And of course, anyone is always welcome to contribute more tutorials - it's
for sure will be appreciated.


Boost list run by bdawes at, gregod at, cpdaniel at, john at