>
typedef BaseClass<etc.> super;
It
turns out that this does work under VS2008.
So I
have to give the metafunction expression twice: once for declaring the class’s
parent, and again immediately after for the typedef. But then all the
constructors and others can use the typedef.
In
this case, the base uses the same template parameter as the derived, so I could
not use a typedef beforehand. I’m pretty sure that VS2010 doesn’t
support the enhanced typedef features of C++0x, so it will be in there for a
while.
What
bugs me is that MSVC has a __super keyword, “to deal with injected base
class that you don’t know the name of” due to its non-standard “attribute”
extension. But it doesn’t work with the constructor init list, only
with qualifications.
--John
From:
boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Roman Perepelitsa
Sent: Tuesday, May 25, 2010 3:43 AM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [MPL] what is my base class?
2010/5/22 Nat Goodspeed <nat@lindenlab.com>
Especially when my base class is a template with a number of
parameters, I often do write something like:
class Subclass: BaseClass<etc.>
{
typedef BaseClass<etc.> super;
public:
Subclass(whatever):
super(whatever),
...
{}
...
};
If your compiler implements injected names correctly (gcc
does not), you can use BaseClass instead of super.
namespace some_long_namespace {
template <class T>
struct Base {};
}
struct Derived : some_long_namespace::Base<int> {
Derived() : Base() {}
};
Roman Perepelitsa.