lundi 5 janvier 2015

C++: How to prevent specialization of a template?

The compiler doesn't complain when I do this ;-)



// Myfile.h
#include <iostream>
#include <vector>

namespace std
{

template<> class vector<int>
{
public:
vector ()
{
std::cout << "Happy Halloween !!!\n";
}
};

}


Is there any way to prevent this kind of undesirable specialization of a class/function template?


--EDIT--


I just used std:: as an example. What I'm looking for is a way to prevent this from happening to a template class which I write and ship as part of a library..


Aucun commentaire:

Enregistrer un commentaire