I have a struct with many members of the same type, like this
struct VariablePointers {
VariablePtr active;
VariablePtr wasactive;
VariablePtr filename;
Here is a trick which triggers a linker error if a required initializer is missing:
struct init_required_t {
template
operator T() const; // Left undefined
} static const init_required;
Usage:
struct Foo {
int bar = init_required;
};
int main() {
Foo f;
}
Outcome:
/tmp/ccxwN7Pn.o: In function `Foo::Foo()':
prog.cc:(.text._ZN3FooC2Ev[_ZN3FooC5Ev]+0x12): undefined reference to `init_required_t::operator int() const'
collect2: error: ld returned 1 exit status
Caveats:
Foo
from being an aggregate at all.