I have a question regarding "optional" inheritance in regards to template.
This is not compiled code.
template<typena me 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 1646
skscpp wrote in news:3a******** *************** ***@posting.goo gle.com: I have a question regarding "optional" inheritance in regards to template. This is not compiled code.
template<typena me 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 (http://boo.codehaus.org/) is a different language, but I like its
"as" instead of ":" and "->", to have:
def min(a as iterable(T)) as T:
Instead of:
|
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. I've done this before with
Modules, and saw that <gasp> they behave just like sealed classes with only
static members.
Anyway, it looks like...
|
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 make things simpler and better readable I'd make all default parameters
named parameters so that you can decide for yourself which one to pass and...
| |
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 <defaultselement. There are
5 settings which *must* be defined in the <defaultssection.
The configuration file also has <databaseelements. A database...
|
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 avoided.
I'd like to hear your various opinions on this matter.
|
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 As Integer = 0, _
Optional ByVal Arg2 As Integer = 0, _
Optional ByVal Arg3 As Integer = 0)
' Call my SQL proc with the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
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 we have to send another system
| |