Reputation: 5471
I'm trying to do something like this.
template <typename T>
struct thingo {
int always;
T sometimes;
};
thingo <> compile_error; // <- wont compile
thingo <nullptr_t> wastes_space; // compiles but nullptr_t takes space anyway
Is inheriting from an int wrapper the only way to accomplish this?
Upvotes: 0
Views: 1852
Reputation:
What about:
struct None {};
// Or without an extra struct:
// typedef void None;
template <typename T = None>
struct thingo {
int always;
T sometimes;
};
template <>
struct thingo<None> {
int always;
};
Upvotes: 7