I would like to exclude or include some members in a template class, based on the value of its template parameter. Here's an example:
enum t_chooser {A, B, all};
template <t_chooser choice>
class C {
// include if choice==A
int v1;
// include if choice==B
long v2;
// include if choice==B
int v3;
// include for every value of choice
bool v4;
};
If the template parameter choice
is equal to all
, all members should be included.
Is there a way to achieve this in C++11, maybe even using std::enable_if
?
I have seen a solution for member functions here: std::enable_if to conditionally compile a member function