Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2005-03-30 17:05:03


"David Abrahams" <dave_at_[hidden]> wrote
> Peder Holt <peder.holt_at_[hidden]> writes:
>
> > On Wed, 30 Mar 2005 11:22:22 -0500, David Abrahams
> > <dave_at_[hidden]> wrote:
> >> "Arkadiy Vertleyb" <vertleyb_at_[hidden]> writes:
> >>
> >> > "David Abrahams" <dave_at_[hidden]> wrote
> >> >> > This actually makes it possible to properly implement remove_xxx
for
> >> >> > VC6.5 and VC7.0 without any form of registration :)
> >> >>
> >> >> Whoa. That is *major*... at least for those
> >> >> hopefully-soon-to-be-obsolete compilers it is. Awesome! Is this a
> >> >> full replacement for partial specialization?
> >> >
> >> > This implementtion doesn't use any template specialzation.
> >>
> >> I know that. I just asked if the mechanism _replaces_ partial
> >> specialization. Of course it doesn't do that fully, since partial
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >> specialization can be used non-intrusively.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > When developing typeof-support for VC6, I also implemented remove_xxx
> > based on typeof, so, yes. The new implementation of remove_xxx +
> > typeof is a full replacement for partial specialization.
>
> ?? I think I answered my own question to the contrary.

This mechanism works similarly to template specialization, but of course it
cannot substitute it, since it has to be applied in the specific way,
something like this:

template<int ID> struct base
{
    struct nested; // not defined
};

template<class T, int ID> struct derived
{
    struct base::nested // define base's nested class here -- totally
non-conformant
    {
        typedef T type; // we know T here
    };
};

Now, when derived<T, ID> is instantiated, base<ID> is also instantiated.
But, at this point it gets its nested struct, and it contains the magic
typedef...

Now base<ID>::nested::type is the type we need.

Not exactly template specialization. Rather "template re-definition at the
point of instantiation" :-)

Regards,
Arkadiy


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