Boost logo

Boost Users :

Subject: Re: [Boost-users] [MPL] what is my base class?
From: John Dlugosz (JDlugosz_at_[hidden])
Date: 2010-05-25 11:46:54


> 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_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Roman Perepelitsa
Sent: Tuesday, May 25, 2010 3:43 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [MPL] what is my base class?

2010/5/22 Nat Goodspeed <nat_at_[hidden]<mailto:nat_at_[hidden]>>
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.

TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net