3 ms·
Indeed, a structure is a named tuple. I think there's a subset of C++ users who pride themselves on creating massively complex solutions, as if they're trying t
by userbinator 11y ago
Indeed, a structure is a named tuple. I think there's a subset of C++ users who pride themselves on creating massively complex solutions, as if they're trying to use as much of the features of the language as they can, instead of going for the simple, straightforward solution. AFAIK std::tuple does compile into the same code as if you declared a struct yourself, but I'd like to see what this convoluted solution compiles to... if I'm reading it correctly, this turns into an O(n) structure member access!?
What if You by mistake switch ‘GPA’ and ‘grade’ inside your function? Nothing will happen to inform You that something went wrong.
I don't know if there's a specific name for it, but "what if you did X" arguments like this fail to convince me.
- scriptdevil 11y agoDoes O(n) even matter when you only store a small number of elmeents in the tuple anyway?
- tcbawo 11y agoThat variadic expansion happens at compile time, so it's still O(1) access. In my experience, the effects of something like this won't be immediately visible. You might start to notice compile times creeping up as the project grows. YMMV.
- KayEss 11y agoThis does seem a bit crazy, but it's worth remembering that the named tuple is copied from Python. Although I suppose the excuse there is a lack of structs.