3 ms·
Why would you want to create a named tuple by invoking convoluted code (and arguable with the end result being also not trivial to use) instead of just declarin
by temac 11y ago
Why would you want to create a named tuple by invoking convoluted code (and arguable with the end result being also not trivial to use) instead of just declaring a structure?
This article is interesting to explore the technical capabilities of modern C++, but not to use the result...
- bpicolo 11y agoLightweight, low-overhead to use, iterable, self-documenting object
- temac 11y agoGiven the implementation, there is nothing lightweight and low-overhead to use at build time, and at runtime how exactly is this lighter than a struct? As for self-documenting, I don't even know what it would mean here. Remains "iterable". Given how modern compiler works, I'm still convinced you should convert plain tuples back and to a struct for source code simplicity and build time speed -- because it won't even do extra copies in most cases (and even if it does, who cares?)
- seivan 11y agoBecause I don't know what I want until I want it. I do a similar Tuple a couple of times I know I am going to need a container class/struct to avoid rewriting the same Tuple over and over again and it would also make things clearer as I know got a class/struct for that particular use case. Now until I know I need one, it's unnecessary to clutter the namespace with yet another container class/struct. Named Tuple has a few benefits, that's all. Until they don't.