Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-04-23 16:13:21

> > This is a much simpler idiom than what I saw on clcm. That's great,
> > because it can have tons of cool applications.
> >
> > Who invented it?

Be careful though Andrei. Some implementations don't like it if there is a
nested template named the same as what you are looking for. I had to really
jump through some huge hoops to get this to work either way on Comeau C++ -- I
don't know about anything else.

For instance, given the implementation before, Comeau C++ will currently give a
compile time error for the following:

struct Y {
    template<class> class nested { }; // i.e. nested is a template, not a type

Comeau C++ also has a problem with the reverse scenario to detect if a
*template* exists:

template<class T> class has_unary_template_nested {
        template<class U> static small_t check(
            typename U::template nested<null_t>* );
        template<class U> static large_t check(...);
        enum { value = sizeof(check<T>(0)) == sizeof(small_t) };

This also works fine until you pass a type like the following to it:

struct Y {
    struct nested { };

I guess you can't have everything--yet. :)

Paul Mensonides

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