|
templated class : constructor specialization Good afternoon, gurus and others! I have a template class that looks like this: template <typename T> class CTemplateClass { private: const T* const mpData; public: CTemplateClass<T>(const T& aData) : mpData(new T(aData)) { } virtual ~CTemplateClass<T>() { delete this->mpData; } };... 10 Apr 2008 16:55
Explicit casts to user-defined types Hey all, Let's say I have a vector type: struct vec { float data[3]; }; and I want to use it to wrap a plain float[3]. So, I want float x[3]; vec * v(x); Or something like that. Is there a way to do this without some crazy reinterpret_cast stuff? Thanks, Jason -- [ See ht... 9 Apr 2008 14:39
Lame question about template ids Hello, suppose I have the following definition template <class T> struct A { template <class U> struct B { }; template <class V> A<B<V> > f(); }; How do I create the definition of f()? I tried template <class T> template <class V> A<typename A<... 6 Apr 2008 10:21
std::map performance Hi folks, for our application i have to cache data. For that purpose i am currently using the vector as a container to store the pointers to objects holding the data. Currently that's ok since the keys for the acces are rather sequential with no bigger gaps in between. But for the future we attempt to use some ... 6 Apr 2008 19:21
Implicitly defined functions properties Those functions are the default constructor, the copy constructor and the assignement operator. In the standard document (section 12), it is written that these functions are implicitly declared, and implicitly defined *if* they are used. Since they are defined on a usage basis, I am guessing that they have inter... 11 Apr 2008 19:05
template args Hi, 1. I have a syntax question (I am not trying to write container independent code). I would like to specify a container and its type, as for example, "something<int,vector>" where the "int" would be passed to the "vector". However, I can't get the syntax right, as apparently the default arguments, i.e.,... 4 Apr 2008 15:11
STL and finding objects by name Hello, Apologies if the answer to this is obvious, I have spent quite some time trying to come up with a solution. I would like to use some sorted STL container (maybe a set ?) to hold a bunch of named objects, that is, objects that posses their own name. I then want to search for objects in the container by nam... 12 Apr 2008 13:30
Is it allowed that std::map equal_range returns more than 1 elements? On Apr 3, 10:07 pm, Alberto Ganesh Barbati <AlbertoBarb...(a)libero.it> wrote: andreas ha scritto: I have seen a piece of code where the key of a std::map is like: struct key { int a; int b; }; The less operator is defined like: bool operator<(con... 7 Apr 2008 11:59
Wishlist: To override "C" pointers with C++ wrappers Greetings: I think it should be possible to override all fundamental pointers with a given class. This is very important and can save a lot of trouble. How about: template <typename T> struct * { ... }; // Specialization template <> struct int * { ... }; The same goe... 7 Apr 2008 11:27
STL map: reverse iterator for lower_bound? Hi, In STL multi-map, the lower_bound, upper_bound,equal_range all return an iterator. Now ifone wants to iterate from an upper bound towards a lower bound, what would be the best way to do it? I tried to interate backwards with an iterator, but the begin() element was not properly included. Thanks fo... 7 Apr 2008 17:48 |