You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct A
{
int a;
int b;
};
void test()
{
A v{10, 20};
}
// should be changed into:
void test()
{
A v{.a = 10, .b=20};
}
Rationale: It's very easy to introduce bug when adding some field in middle of struct, or changing order of fields, with this we can always be sure that such objects are constructed correctly.
Check name: modernize-use-designated-initializers.
Check should enforce that all aggregates should be initialized with designated initializers.
There can be config to ignore aggregates that have only 1 argument.
There can be config to reduce check to only trivial types, in such case it could be used on older standards with compiler extensions.