I have the following class:
#pragma once
#include
#include
class testclass
{
public:
template T item(const s
The problem boils down to the common problem of not having the templates in the header file. The compiler, when processing main
does not see the specialization and it generates its own instantiation of the generic template for std::string
. This is a violation of the ODR, as there are now 2 different specializations for std::string
in the same program, but the compiler is not required to diagnose it.
The simple solution is to declare/define the specialization in the header so that the compiler can either use it, or at least will know not to generate the specialization from the generic version when processing main