Original Post
I'm trying to do specialized templates, but am getting an error that it's compiled multiple times: should the specialized method be in a cpp file - then should i define it somehow inside the class?
Error 1 error LNK2005: "public: static unsigned int __cdecl
Axiverse::DictionaryHasher::Hash<int>(int const &)"
(??$Hash@H@DictionaryHasher@Axiverse@@SAIABH@Z) already defined in Ethereum.obj Main.obj
Because it's a template, i've defined the whole thing, even the specialized template method. It seems that only the specialized template has multiple definitions, while general ones are okay.
class DictionaryHasher
{
public:
// Methods
template <class type>
static unsigned int Hash(const type& value);
private:
// Constructor / Destructor
DictionaryHasher() {};
};
template <>
unsigned int DictionaryHasher::Hash<int>(const int &value)
{
return value;
}
template <class type>
unsigned int DictionaryHasher::Hash(const type &value)
{
return value.Hash();
}