C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Newbie needs help with traits

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Dick Bridges
Guest





PostPosted: Mon Sep 29, 2003 6:15 pm    Post subject: Newbie needs help with traits Reply with 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.



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Back to top
red floyd
Guest





PostPosted: Mon Sep 29, 2003 7:00 pm    Post subject: Re: Newbie needs help with traits Reply with quote



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





PostPosted: Mon Sep 29, 2003 8:39 pm    Post subject: Re: help with traits - help from mpl? Reply with quote




"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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.