This class:
template <class T>
struct A {
A() : t(T()) {
}
A(const T& t_) : t(t_) {
}
T t;
};
won't compile if T doesn't have default constructor. This one:
template <class T>
struct A {
A(const T& t_) : t(t_) {
}
T t;
};
won't have default constructor even if T has default constructor.
I want to have both - If there's no T() I want no A().
I know that SFINAE have to be used. And that Boost.traits and Boost.enable_if can help, but I can't get it to work. Can Someone give me an example to this simple case?