Recently I end up using structs everywhere as functions parameters to basically get named function parameters and better default arguments. Are there any downsides to this? So far the only annoying thing is to have to define those structs.
struct FunParams{
int i = 5;
float f = 3.14f;
std::string s = "hello";
};
void Fun(const FunParams& params){}
int main(){
Fun({.s = "hi there"});
}
It’s a bit annoying but why is it a problem? You still can skip arguments where you just want the default value. Compared to function arguments you also get defined evaluation order.