Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-02-28 16:47:16


Gavin Collings wrote:
> 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
>

Cool :). I thought about inheriting 'xxx_traits_builder' from 'xxx_traits'
and then typedef-ing the latter to something like 'result', but for some
reason I didn't realize that the inheritance is not necessary here at all.
Your version is more clear both in code and from the conceptual point of
view (it separates the builder class from the result), thanks!

Aleksey


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