I have a templated class A
Late but a very elegant solution: C++ 2020 introduced Constraints and Concepts. You can now conditionally enable and disable constructors and destructors!
#include
#include
template
struct constructor_specialized
{
constructor_specialized() requires(std::is_same_v)
{
std::cout << "Specialized Constructor\n";
};
constructor_specialized()
{
std::cout << "Generic Constructor\n";
};
};
int main()
{
constructor_specialized int_constructor;
constructor_specialized float_constructor;
};
Run the code here.