typedef

What is the right way to typedef a type and the same type's pointer?

What is the right way to typedef a type and the same type's pointer? Here is what I mean. Should I do this: typedef unsigned int delay; typedef unsigned int * delayp; Or should I do this: typedef unsigned int delay; typedef delay * delayp; Or perhaps I should not typedef pointer at all and just use delay * instead of delayp everywh...

Return number of Enum Values. ( Size of Enum typedef )

Is there a built in function or a way to query the size of an emun typedef? typedef enum difficultyTypes { kEasy, kMedium, kHard } difficultyType; I would like a way to query and have it ( in this case ) return 3. I could even deal with it returning 2 as the highest value ( 0,1,2 ). Or am I forced to use another int variable that I s...

Can not get example compiled with typedef in template class

Hi, I have this example code: #include template<class T> class Class { public: typedef boost::shared_ptr<Class<T> > Ref; }; template<class T> class Class2 { public: Class<T>::Ref getAReference() {return Class<T>::Ref(new Class<T>);}; }; int main(){} When I try to compile it, I get: test.cpp:14: error: type ‘Class<T>’ i...

Can you lookup where a typedef is being defined?

Is it possible to lookup where a typedef is being defined? I am running into this very evasive problem that is producing the following compiler error: /usr/include/stdint.h: At global scope: /usr/include/stdint.h:57: error: duplicate 'unsigned' /usr/include/stdint.h:57: error: declaration does not declare anything where /usr/include/...

How to check if a datatype is "defined" with typedef

I faced this problem today and just wondering how to check if a new type defined with typedef is really defined somewhere. To give an example, I started using Xerces-c3 library that I built from source code and wrote a xml2text converter. But I couldnt find Xerces-c3 port on fbsd so installed Xerces-c2 library. When I tried to recompil...

The C++ Programming language, Definitions vs Declarations exercise (simple, if tedious help needed XD).

Hi there. I've been working through Bjarne Stroustrup's "The C++ Programming Language" (2nd edition - I know I should really get a new copy but this is a library book!), and had a few questions about one of his simpler questions. In Chapter 2, when talking about Declarations and Constants, he lists a set of declarations, some of which ar...

Standard for typedef'ing

Hello, gcc 4.4.4 c89 I am just wondering is there any standard that should be followed when creating types. for example: typedef struct date { } date_t; I have also seen people put a capital like this: typedef struct date { } Date; Or for variables typedef unsigned int Age; or this typedef unsigned int age_t; Is there any ...

Typedef issue with bison and gnu flex

In my parser, I have %union { SYMTABLE *p_entry ; QUAD *p_quad ; } ; Now, SYMTABLE is the typedef for a struct. The struct and typedef are in an included file. There are no issues with this. QUAD is the typedef for a struct (typedef struct quad QUAD). The struct and typedef are in an included file. There is no problem doing: b...

Typedef a container of function pointers

Simple question; right now I have something like this: typedef void(*MyFunctionPointer)(int); typedef std::vector < MyFunctionPointer > MyFunctionPointerContainer; However, I want to typedef this container in one row, skipping the first typedef, how can I do this? ...

Typedef-equivalent in C#?

I know this exact question has been asked, but the solution posted there doesn't seem to work for me. Here's the code I'm trying: namespace ConsoleApplication5 { class Program { enum Tile { Empty, White, Black }; using Board = Tile[8,8]; And the error I get: Invalid token 'using' in class, struct, or interf...

What's the point of boost::multi_index_container::index<Tag>::type ?

If you have a boost::multi_index_container< > with multiple indices, there are obviously multiple ways to iterate over it - each index defines a way. For instance, if you have an index with tag T, you can iterate from container.get<T>().begin() to container.get<T>().end(). If you try to do so in a for-loop (and do not have C++0x auto),...

iPhone SDK << meaning?

Hi another silly simple question. I have noticed that in certain typedefs in Apple's frameworks use the symbols "<<" can anyone tell me what that means?: enum { UIViewAutoresizingNone = 0, UIViewAutoresizingFlexibleLeftMargin = 1 << 0, UIViewAutoresizingFlexibleWidth = 1 << 1, UIViewAutoresizin...

typedef inheritance from a pure abstract base

Edit: Found duplicate I've whittled down some problem code to the simplest working case to illustrate the following: my typedef in a pure abstract base class is not being inherited by the derived class. In the code below I'd like to inherit the system_t typedef into the ConcreteTemplateMethod: #include <iostream> // pure abstract te...

Compile time checking existance of stdint.h

I'm working with legacy embedded C code which defines the types uint8_t, uint16_t and uint32_t in a header file using the typedef keyword. For discussion, let us say the file typedefs.h contains these definitions. In my new C source module, I include stdint.h. I also include other header files which include typedefs.h somewhere in t...

what does this typedef mean? a function prototype ?

typedef int (fc_name) (void); here fc_name is any valid C symbol. how different is this from a function pointer typedef ? ...

Get typedef of current class

Hi there, I'm currently using boost::intrusive_ptr together with my GUI classes. Although this is more or less a convenience question, is there a proper way to get the typename of the current class? The reason I'm asking is that I have a macro for typedef'ing the different pointer types: #define INTRUSIVE_PTR_TYPEDEFS(CLASSNAME) typede...

Alternative to template declaration of typedef

I'm trying to accomplish namespace NTL { typedef std::valarray vector; } through standard C++. I know it's not allowed, but I need a quick and easy way (without reimplementing all functions, operators, overloads, etc.) to get a template typedef. I am now doing a template class Vector which has a valarray as data member, but that ...

function pointer without typedef

Is it posible to use the type of a prefiously declared function as a function pointer without using a typedef? function declaration: int myfunc(float); use the function declaration by some syntax as function pointer myfunc* ptrWithSameTypeAsMyFunc = 0; ...

How to use an unknown (int-like) type as index into std::vector?

I'm using a type Id which is defined in another part of the code I'm using: typedef int Id; Now I am provided many objects, each of which comes with such an Id, and I would like to use the Id as index into a std::vector that stores these objects. It may look something like this: std::vector<SomeObj*> vec(size); std::pair<Id, SomeObj*...

error: using typedef-name after class

I can't figure out what the actual problem is with this. typedef struct _actor { ... } _actor, Actor; class Actor { ... }; I get this weird error message actor.cpp:31: error: using typedef-name ‘Actor’ after ‘class’. Any idea what I did wrong here? Thank you :) ...