-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Server Programmability
-
SP Prioritized List
I'd like to be able to mark a struct somehow, so that the only way to construct it is with the designated initializer syntax.
Hypothetical example:
struct FooArgs { REQUIRE_DESIGNATED_INIT(Foo) int apple; int banana; int cherry; int durian; // ... }; void runFoo(FooArgs); int main() { runFoo({5}); // error: you're supposed to use named arguments runFoo({.banana = 3, .cherry = 4}); // good }
mathias@mongodb.com suggested this and wrote a POC, and I would find this useful for an upcoming project.