Boost logo

Boost :

From: gcollings_at_[hidden]
Date: 2001-02-28 10:52:03


--- In boost_at_y..., Aleksey Gurtovoy <alexy_at_m...> wrote:
> Jeremy Siek wrote:
> > Another variation:
> >
> > boost::iterator_adaptor<int*, reverse_iterator_policies,
> > iterator_traits_builder
> > ::Reference<int>::Pointer<int*>::Distance<std::ptrdiff_t>
> > ::Value<int>::Category<std::input_iterator_tag>
> > >

> I like this version! (well, would like to get rid of mixed case,
> though, but don't see any better way to spell 'reference' without
> hiding the nested typedef too...)

A slight tweek will do the trick: separating the traits and builder
classes: -

template <typename A, typename B, typename C>
struct xxx_traits
{
   typedef A a_type;
   typedef B b_type;
   typedef C c_type;
};

template <typename A = a_t, typename B = b_t, typename C = c_t>
struct xxx_traits_builder
{
   template<typename AA> struct a_type : xxx_traits_builder<AA,B,C>{};
   template<typename BB> struct b_type : xxx_traits_builder<A,BB,C>{};
   template<typename CC> struct c_type : xxx_traits_builder<A,B,CC>{};

   typedef xxx_traits<A, B, C> traits;
};

this can be used like

   boost::iterator_adaptor<int*, reverse_iterator_policies,
     iterator_traits_builder
       ::reference<int>::pointer<int*>::distance<std::ptrdiff_t>
       ::value<int>::category<std::input_iterator_tag>::traits

Gavin


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