6 ms·
If the code base supports designated initializers I'll use them as a way of getting named parameters like so: struct SomeArgs { bool normalize{false};
by einburger 2y ago
If the code base supports designated initializers I'll use them as a way of getting named parameters like so:
struct SomeArgs {
bool normalize{false};
int stride{2};
char ch{'x'};
... some other stuff
};
void someFn(SomeArgs args);
someFn({ .stride = 1, .ch = 'y' });
someFn({ .normalize = true });
not as simple as python but it's close-ish and more readable than:
someFn(false, 2, 'c');