 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dick Bridges Guest
|
Posted: Mon Sep 29, 2003 6:15 pm Post subject: Newbie needs help with traits |
|
|
I'm still struggling with templates [and mpl?]. If someone could point me
toward books or articles or tutorials that discuss how to achieve the
following, I'd very much appreciate it.
I'd like to create a traits template [MyClsTraits] to be used by some class
[MyCls]. For example, suppose I've inherited (i.e., have no control over)
the following #defineS.
#define X_ONE 1
#define X_TWO 2
#define Y_ONE 1
#define Y_TWO 2
And I'd like to be able to declare an instance like this.
MyClsTraits<X_TWO, Y_ONE> t;
such that t has two traits: X_ and Y_ that are then used by MyCls<t>.
Additionally, I need to be able to control the allowable combinations. IOW:
X_TWO/Y_ONE is legal but X_ONE/Y_TWO is not a valid combination and produces
a compilation or link error.
TIA Any relevant references would be appreciated.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
|
|
| Back to top |
|
 |
red floyd Guest
|
Posted: Mon Sep 29, 2003 7:00 pm Post subject: Re: Newbie needs help with traits |
|
|
Dick Bridges wrote:
| Quote: | I'm still struggling with templates [and mpl?]. If someone could point me
toward books or articles or tutorials that discuss how to achieve the
following, I'd very much appreciate it.
I'd like to create a traits template [MyClsTraits] to be used by some class
[MyCls]. For example, suppose I've inherited (i.e., have no control over)
the following #defineS.
#define X_ONE 1
#define X_TWO 2
#define Y_ONE 1
#define Y_TWO 2
And I'd like to be able to declare an instance like this.
MyClsTraits<X_TWO, Y_ONE> t;
such that t has two traits: X_ and Y_ that are then used by MyCls<t>.
Additionally, I need to be able to control the allowable combinations. IOW:
X_TWO/Y_ONE is legal but X_ONE/Y_TWO is not a valid combination and produces
a compilation or link error.
TIA Any relevant references would be appreciated.
|
create a specialization for MyClsTraits<X_ONE,Y_TWO> with any and all constructors private?
|
|
| Back to top |
|
 |
Dick Bridges Guest
|
Posted: Mon Sep 29, 2003 8:39 pm Post subject: Re: help with traits - help from mpl? |
|
|
"red floyd" <no.spam (AT) here (DOT) dude> wrote
| Quote: | Dick Bridges wrote:
I'm still struggling with templates [and mpl?]. If someone could point
me
toward books or articles or tutorials that discuss how to achieve the
following, I'd very much appreciate it.
I'd like to create a traits template [MyClsTraits] to be used by some
class
[MyCls]. For example, suppose I've inherited (i.e., have no control
over)
the following #defineS.
#define X_ONE 1
#define X_TWO 2
#define Y_ONE 1
#define Y_TWO 2
And I'd like to be able to declare an instance like this.
MyClsTraits<X_TWO, Y_ONE> t;
such that t has two traits: X_ and Y_ that are then used by MyCls<t>.
Additionally, I need to be able to control the allowable combinations.
IOW:
X_TWO/Y_ONE is legal but X_ONE/Y_TWO is not a valid combination and
produces
a compilation or link error.
TIA Any relevant references would be appreciated.
create a specialization for MyClsTraits<X_ONE,Y_TWO> with any and all
constructors private?
|
Thanks for the response.
Thing is, the 'real' traits has four sets of values and each set has ~20 to
~40 possible values. Is there no way to accomplish this with something
like, for example, mpl typelists?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|