Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-07-08 17:40:22

"David B. Held" <dheld_at_[hidden]> wrote in message

> The difference is that the component is called sp<>::nested<>.
> It's not called sp_nested<>, because they might want to typedef
> sp<> and instantiate the nested class over various types. By
> also exposing sp_nested<>, I'm asking them to call it by two
> different names depending on usage. It isn't totally evil, but
> it's less pleasant:
> typedef sp<p1, p2> my_sp;
> my_sp::nested<foo> p;
> my_sp::nested<bar> q;
> less<my_sp::nested<foo> > comp;

Got it. One last try -- a variation on Brian's:

    struct nested_base { };

    template <class P1, class P2>
    struct sp
         template <typename T>
         struct nested : nested_base {
             typedef P1 p1;
             typedef P1 p2;
             typedef T t;

    template <typename T, typename Enabler = void>
    struct less { };

    template<typename T>
    struct enable_if_nested
        : boost::enable_if<
              boost::is_base_and_derived<nested_base, T>
        { };

    template <typename T>
    struct less< T, typename enable_if_nested<T>::type >
    { ... };


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