Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > default typedefs initlisation

Reply
Thread Tools

default typedefs initlisation

 
 
Abhishek Saksena
Guest
Posts: n/a
 
      06-07-2005
Does anybody know how I can achieve the following

I have different flavors of base class :-
========================
class base //empty class
{

};

class base //base class with x_type defination
{
public:
typedef int x_type;
}

class base //base class with y_type defination
{
public:
typedef int y_ype;
}

class base //base class with x_type and y_type defination
{
public:
typedef int x_type;
typedef int y_ype;
}
==========================

now I want to use one of these base class as a template parameter to some
other class. Something like

template<typaname T>
class xyz
{
typedef typename T:_type x_type;
typedef typename T::y_type y_type;
};

The issue is that if the both or one of the types not defined in the base
class then I would like to initialize the x_type and y_type (defined in
class xyz) to some default type like bool.(without generating the
compile-time error)


Abhishek



 
Reply With Quote
 
 
 
 
Me
Guest
Posts: n/a
 
      06-07-2005
> The issue is that if the both or one of the types not defined in the base
> class then I would like to initialize the x_type and y_type (defined in
> class xyz) to some default type like bool.(without generating the
> compile-time error)


http://www.boost.org/libs/utility/enable_if.html

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
too many typedefs cppaddict C++ 2 06-19-2004 04:07 AM
using declarations with nested typedefs Dave C++ 4 12-05-2003 11:45 PM
Templates and Typedefs dwrayment C++ 6 08-14-2003 05:52 AM
STL typedefs and base class pointer problem emerth C++ 3 08-08-2003 05:47 AM
Re: visibility of typedefs Alexander Stippler C++ 5 06-25-2003 09:34 AM



Advertisments