J
Jayden Shui
Hello All,
I give every class a tag by specialize the following template
function:
template<class T>
std::string Tag();
However, when working on a class in a namespace such as
namespace S
{
class A { /*codes for A*/ };
template<>
std::string Tag<A>()
{
return "A";
}
// other codes
}
The compiler give an error. I have to specialize it in global scope
like
namespace S
{
class A { /*codes for A*/ };
}
template<>
std::string Tag<S::A>()
{
return "A";
}
namespace S
{
// other codes
}
I don't want split the namespace scope by the tag specialization.
Anyway I can make it work without the splitting?
Thank you very much for your kind help!
Best regards,
Jayden
I give every class a tag by specialize the following template
function:
template<class T>
std::string Tag();
However, when working on a class in a namespace such as
namespace S
{
class A { /*codes for A*/ };
template<>
std::string Tag<A>()
{
return "A";
}
// other codes
}
The compiler give an error. I have to specialize it in global scope
like
namespace S
{
class A { /*codes for A*/ };
}
template<>
std::string Tag<S::A>()
{
return "A";
}
namespace S
{
// other codes
}
I don't want split the namespace scope by the tag specialization.
Anyway I can make it work without the splitting?
Thank you very much for your kind help!
Best regards,
Jayden