Boost logo

Boost Users :

Subject: [Boost-users] [MPL] what is my base class?
From: John Dlugosz (JDlugosz_at_[hidden])
Date: 2010-05-21 12:44:15


I'm writing a class template, say C<T>, that has essentially different features depending on a classification of type T.  So, I implemented Ca and Cb as befitting the two categories, and then make that transparent to the user by making a stub for C that inherits from either of those two, using boost::mpl::if_ to choose between them.

However, the constructors have to be brought down manually.  To "inherit" them, they need to be forwarded to the base class:  C (...args...) : Ca (...args...) {}

The problem is, I can't easily name the base class here in the base initialization list.  I'm not even sure repeating the if_ metaexpression here would work, since the init list doesn't even like typedefs but wants the literal name of the class.

Did I paint myself into a corner?  Please help.

In one case, it was not a problem to use only a default constructor and call an inherited Initialize function from the body. In the other case, I want to keep my reference member initializers.

Thanks,
--John

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