In the below code:
template <typename T>
struct templatedStruct
{
};
template <typename T>
void func(T arg)
{
// How to find out if T is type templatedStruct of any type, ie., templatedStruct<int> or
// templatedStruct<char> etc?
}
int main()
{
templatedStruct<int> obj;
func(obj);
}
Is the only way to inherit templatedStruct from something else?
struct Base {};
template <typename T>
struct templatedStruct : Base
{
};
template <typename T>
void func(T arg)
{
std::is_base_of_v< Base, T>;
std::derived_from<T, Base>; // From C++ 20
}