mercredi 27 septembre 2017

template function specialization with static keyword

I have this kind of code that worked fine with gcc 4.14 and VS but when I compile with C++11 compiler it is giving following error. "explicit template specialization cannot have a storage class". If i remove the static keyword it works perfectly fine. is there any other way so that i don't have to remove the static keyword?.

#include <iostream>
using namespace std;

namespace Asad{
template <typename T>
static void foo(const T param)
{}

template <>
static void foo<int>(const int param)
{}

template <>
static void foo<bool>(const bool param)
 {}
}

int main() {
 cout<<"aaaaaaaaaaaa"<<endl;    
 return 0;
}

Aucun commentaire:

Enregistrer un commentaire