#include <iostream>
template <bool present>
struct base;
template <>
struct base<true> { int x; };
template <bool present>
struct base { };
struct Nothing {};
struct StaticNothing {
static Nothing x;
};
template <bool activate>
struct A : public base<activate>, StaticNothing {
using std::conditional_t<activate, base<true>, StaticNothing>::x;
void print() const;
};
template <bool activate>
void A<activate>::print() const
{
if constexpr (activate) {
std::cout << "x = " << x << std::endl;
} else {
std::cout << "nothing" << std::endl;
}
}
int main()
{
A<true> a;
a.print();
A<false> b;
b.print();
return 0;
}