Internal typedefs in C++ – good style or bad style?

Something I have found myself doing often lately is declaring typedefs relevant to a particular class inside that class, i.e. class Lorem { typedef boost::shared_ptr<Lorem> ptr; typedef std::vector<Lorem::ptr> vector; // // … // }; These types are then used elsewhere in the code: Lorem::vector lorems; Lorem::ptr lorem( new Lorem() ); lorems.push_back( lorem ); Reasons I … Read more

Equivalent of typedef in C#

Is there a typedef equivalent in C#, or someway to get some sort of similar behaviour? I’ve done some googling, but everywhere I look seems to be negative. Currently I have a situation similar to the following: class GenericClass<T> { public event EventHandler<EventData> MyEvent; public class EventData : EventArgs { /* snip */ } // … Read more

C++ template typedef

I have a class template<size_t N, size_t M> class Matrix { // …. }; I want to make a typedef which creates a Vector (column vector) which is equivalent to a Matrix with sizes N and 1. Something like that: typedef Matrix<N,1> Vector<N>; Which produces compile error. The following creates something similar, but not exactly … Read more