I have a question regarding "optional" inheritance in regards to template.
This is not compiled code.
template<typename T, typename P1 = Invalid<1>, typename P2 = Invalid<2>,
typename P3 = Invalid<3> >
class Mgr : public T,
public virtual Mgmt<P1>,
public virtual Mgmt<P2>,
public virtual Mgmt<P3>
{
public:
// .....
};
Now if the user sends the following:
class Mgr1;
class My1;
class My2;
Mgr<Mgr1, My1> MyMgr1; // I want the Mgr template to inherit from Mgr1 and
Mgmt<My1>, not Mgmt<Invalid<2>> or
Mgmt<Invalid<3>>
Mgr<Mgr1, My1, My2> MyMgr2; // I want the Mgr template to inherit from Mgr1,
Mgmt<My1>, and Mgmt<My2>, not Mgmt<Invalid<3> >
Is this possible to that?
Thanks. 1 1642
skscpp wrote in news:3a**************************@posting.google.c om: I have a question regarding "optional" inheritance in regards to template. This is not compiled code.
template<typename T, typename P1 = Invalid<1>, typename P2 = Invalid<2>, typename P3 = Invalid<3> > class Mgr : public T, public virtual Mgmt<P1>, public virtual Mgmt<P2>, public virtual Mgmt<P3> { public: // ..... };
Now if the user sends the following: class Mgr1; class My1; class My2;
Mgr<Mgr1, My1> MyMgr1; // I want the Mgr template to inherit from Mgr1 and Mgmt<My1>, not Mgmt<Invalid<2>> or Mgmt<Invalid<3>>
Mgr<Mgr1, My1, My2> MyMgr2; // I want the Mgr template to inherit from Mgr1, Mgmt<My1>, and Mgmt<My2>, not Mgmt<Invalid<3> >
Is this possible to that?
Typed into newsreader ...
struct invalid {};
template<
typename T,
typename P1 = invalid,
typename P2 = invalid ,
typename P3 = invalid
struct manage_base : T, P1, P2, P3
{
};
template<
typename T
struct manage_base< T, invalid, invalid, invalid > : T
{
};
template<
typename T, typename P2
struct manage_base< T, P2, invalid, invalid > : T, P2
{
};
// etc ...
template<
typename T,
typename P1 = invalid,
typename P2 = invalid,
typename P3 = invalid
class Mgr : public manage_base< T, P1, P2, P3 >
{
// some code ??
};
If for some reason you want to have Mgr inherit directly from
T, P1 ... then you'll have to specialize Mgr directly.
HTH
Rob.
-- http://www.victim-prime.dsl.pipex.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bearophileHUGS |
last post by:
Adding Optional Static Typing to Python looks like a quite complex
thing, but useful too:
http://www.artima.com/weblogs/viewpost.jsp?thread=85551
I have just a couple of notes:
Boo...
|
by: Milan |
last post by:
How do I write a class with "optional" interface like the following one:
class A
{
:
// inteface_a
// interface_b
};
void main()
|
by: William Ryan |
last post by:
I just picked up a copy of John Robbins' debugging book and started to look
at disassembled code. Anyway, I hate optional Parameters in VB, but I was
checking them out to see what IL is created. ...
|
by: ad |
last post by:
Does C#2.0 support optional parameters like VB.NET:
Function MyFunction(Optional ByVal isCenter As Boolean = False)
|
by: cody |
last post by:
I got a similar idea a couple of months ago, but now this one will require
no change to the clr, is relatively easy to implement and would be a great
addition to C# 3.0 :)
so here we go..
To...
| |
by: ReGenesis0 |
last post by:
Hey all- I'm just astarting out, and this is what I'm running into--
given XML
<container>
<subject>
<name>John Smith</name>
<age>22</age>
</subject>
<subject>
|
by: Tookelso |
last post by:
Hello,
I would like to have a group of elements which are *required* in one
context, but each one is *optional* in another context.
For example:
I have a configuration file which has a...
|
by: pamelafluente |
last post by:
Hi guys,
In the past I have used several time optional parameters in my
function.
But Now I am more inclined to think that they are more dangerous than
useful, and probably better to be...
|
by: jamesclose |
last post by:
My problem is this (apologies if this is a little long ... hang in there):
I can define a function in VB.NET with optional parameters that wraps a SQL procedure:
Sub Test(Optional ByVal Arg1...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |