Hi, I found the examples of explicit specialization, but I have a vagueness about code: using namespace std; template<class T = float, int i = 5> class A { public: A(); int value; }; template<> class A<> { public: A(); }; template<> class A<double, 10> { public: A(); }; template<class T, int i> A<T, i>::A() : value(i) { cout << "Primary template, " << "non-type argument is " << value << endl; } A<>::A() { cout << "Explicit specialization " << "default arguments" << endl; } A<double, 10>::A() { cout << "Explicit specialization " << "<double, 10>" << endl; } …

Member Avatar
Member Avatar
+0 forum 2

Hi All, Can you please help me to understand why the following code is behaving this way? I think both outputs should be 1 ( 1 means const T), but its not!! [CODE] template <typename T> struct IsConst{ enum {isConst = 0}; }; template <typename T> struct IsConst<const T>{ enum {isConst = 1}; }; template <typename T> void print(T val){ cout << IsConst<T>::isConst << endl; //prints 0 } int main() { const int x = 10; print(x); //why dynamic argument deduction deducting it as normal integer? cout << IsConst<const int>::isConst << endl; //prints 1 return 0; } [/CODE] why dynamic …

Member Avatar
Member Avatar
+1 forum 3

If I have a templated storage class, how can I create a specialized template for nested storage class. I already know how to specialize pointer template, but I don't know how to specialize this. EG: [CODE]template <typename Type> class Array { ///Array class code }; int main() { Array<int> rob; Array<Array<int> > bob;//I need bob to be specialized, but not rob return 0; }[/CODE] Is this possible?

Member Avatar
Member Avatar
+0 forum 1

The End.