mercredi 30 novembre 2016

Exclude class member by specialization

I have base class template, on that I'm making some another class, which are specialized versions of my base class. I know how to exclude some methods from particular specialization case, but is there any possibility to make that for class's members? Example code, of what I want to achieve:

template<typename T>
class Base {
  This variable exists only when T==integer VARIABLE;
}

template <Typename T>
WithVariable = using Base<int>;

template <Typename T>
Without = using Base<double>

I think that I should use std::enable in some way, but using it makes possible to make VARIABLE of type void, when I don't want that variable. That is still not the situation I want to achieve.

Aucun commentaire:

Enregistrer un commentaire