Hi,
can I define type of a variable based on some other type using templates? For example I have
template <typename T> struct A { T t; U x; };
and I want to define U, such that if T is char, then U will be int, if T is float, then U will be double etc. Is this possible via templates, or do I have to declare something like
struct A_char { char t; int x; };
struct A_float { float t; double x; };
and handle things manually?
can I define type of a variable based on some other type using templates? For example I have
template <typename T> struct A { T t; U x; };
and I want to define U, such that if T is char, then U will be int, if T is float, then U will be double etc. Is this possible via templates, or do I have to declare something like
struct A_char { char t; int x; };
struct A_float { float t; double x; };
and handle things manually?
Comment