I want to make a class which can convert to any type/class.
struct any{
template<typename T>
operator T(){
return T();
}
};
struct S{};
void f(const S&){}
f(any()); //ok
//but if no default constructor will make error
struct S{
S()=delete;
};
void f(const S&){}
f(any()); //error
How can i solve this problem to make a class which can convert to any type/class?
Aucun commentaire:
Enregistrer un commentaire