I have an example:
#include <iostream>
#include <type_traits>
template<typename T>
struct A{
A([[maybe_unused]]T t){std::cout<<"contructor 1";}
template<typename X>
A([[maybe_unused]]X x1,[[maybe_unused]]X x2){
std::cout<<std::boolalpha;
std::cout<<std::is_same_v<decltype(x1),int><<std::endl;
std::cout<<"contructor 2"<<std::endl;
std::cout<<x1<<" "<<x2<<std::endl;
}
};
int main()
{
int ax=3;
[[maybe_unused]]A<char> a(ax,ax);
}
which will print out
false
contructor 2
3 3
However I cant understand why should I have a class constructor template. And no matter what the class template type is, the result is unchanged. Can anyone explain the reason of this concept.