I am writing a templated class with one type paramenter and one boolean, here is the code:
template<class T, bool p = true>
class A
{
private:
T* ptr;
public:
A();
};
template<class T>
A<T,true>::A()
{
ptr = 0xbaadf00d;
}
int main()
{
A<int> obj;
A<int, false> o;
return(0);
}
And I am getting these compilation errors:
Error 1 error C3860: template argument list following class template name must list parameters in the order used in template parameter list tst.cpp 15
Error 2 error C2976: 'A<T,p>' : too few template arguments tst.cpp 15
What am I doing wrong? Or is it for some reason forbidden to specialize non-type parameters partially?
At the same time if I use the boolean parameter in an if statement, I'm getting this warning:
Warning 1 warning C4127: conditional expression is constant
So I am supposed to do specializations for this kind of things...
Any help would be highly appreciated! :)
Thanks in advance!!!!