Given this template:
template <class A>
struct Something {
... // members common to all template instantiations for all A types
SpecialType member; // but not this - I want this to be conditional...
}
...I want to use "enable_if" to have the SpecialType member exist conditionally; that is, only when the template is instantiated with A=SpecialCase1 or SpecialCase2 types. In all other cases, I want the SpecialType member to be missing.
In case you're wondering why, this is about optimization - i.e. not carrying useless payload in the struct. I am a newbie in template metaprogramming, but I understand I need "enable_if" and two "is_same" somehow - not sure exactly how, though...
EDIT: Doing it with generic C++ (i.e. without Boost-specifics) would be a plus.
if_
is usually calledstd::conditional
. – Pacify