473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

default typedefs initlisation

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::x_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

Jul 23 '05 #1
1 1074
Me
> 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

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: emerth | last post by:
Suppose I have these 4 typedefs, where each of the 2nd parameter in each is a simple class that just contains a different number of strings: typedef map < char*, cctrlrec_data, ltstr >...
2
by: Levent | last post by:
Please consider the following Parent and Child template classes: template <class T> class Parent { public: typedef T type; typedef T& ref; /* pack of typedefs */ };
9
by: Andy Lomax | last post by:
gcc 3.3 allowed a typedef for a function pointer to contain default argument specifications; for example: typedef int (*foo) (int, int, int=0, bar=0); However, it turns out that this is...
6
by: Erica | last post by:
Hi, I am currently working on a Pascal-to-C translation, and I am getting an error that I can't seem to debug. I have a globals.h file, and here is a snippet from it: -- typedef char...
9
by: bubbakittee | last post by:
I am designing a package of functions to be used by people with very little programming experience (if any) and very little patience. I don't want to scare them with programmerish words like...
6
by: Danilo Horta | last post by:
Hi Folks I'm making a class Vec (aka Vector) using template and operator overloading just to use what I'm learning from the Stroustrup's book. See: template<class T> class Vec : public...
30
by: junky_fellow | last post by:
I was looking at the source code of linux or open BSD. What I found that lots of typedefs were used. For example, consider the offset in a file. It was declared as off_t offset; and off_t is...
12
by: claudiu | last post by:
Hi, I'll go straight to the first question. Why does the code below compile? void f(int i = 0); int main() { (&f)();
2
by: =?Utf-8?B?VGhlQ3VyaW91c09uZQ==?= | last post by:
I have this situation where I need to access the #defines and typedefs defined in a C++ header file from a .NET Project (specifically C#). The C++ header file is from a medical device manufacturer...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.