Suppose I have the following class:
template<typename T>
class Dummy {
public:
Dummy() {}
template<bool U>
bool something(); // line 10
};
I want to specialize the method Dummy<T>::something
. I've tried:
template<typename T>
bool Dummy<T>::something<true>() { // line 14
return true;
}
template<typename T>
bool Dummy<T>::something<false>() { // line 19
return false;
}
But I receive these errors:
test.h:14:32: error: template-id ‘something<true>’ in declaration of primary template
bool Dummy<T>::something<true>() {
^
test.h:14:6: error: prototype for ‘bool Dummy<T>::something()’ does not match any in class ‘Dummy<T>’
bool Dummy<T>::something<true>() {
^
test.h:10:8: error: candidate is: template<class T> template<bool b> bool Dummy<T>::something()
bool something();
^
test.h:19:33: error: template-id ‘something<false>’ in declaration of primary template
bool Dummy<T>::something<false>() {
^
test.h:19:6: error: prototype for ‘bool Dummy<T>::something()’ does not match any in class ‘Dummy<T>’
bool Dummy<T>::something<false>() {
^
test.h:10:8: error: candidate is: template<class T> template<bool b> bool Dummy<T>::something()
bool something();
Is this occurring because it is a form of partial specialization (which I know is not allowed in C++11) or for some other reason? Note that I in no way intend to use the code described above. It is simply to demonstrate something similar which exists in my original code.