4 ms·
http://www.goldsborough.me/cpp/2018/05/22/00-32-43-type_erasure_for_unopinionated_interfaces_in_c++/ http://www.goldsborough.me/cpp/2018/05/22/00-32-43-type_era
by FrozenVoid 6y ago
http://www.goldsborough.me/cpp/2018/05/22/00-32-43-type_erasure_for_unopinionated_interfaces_in_c++/ http://www.goldsborough.me/cpp/2018/05/22/00-32-43-type_eras...
https://www.oreilly.com/content/c17-upgrades-you-should-be-using-in-your-code/ https://www.oreilly.com/content/c17-upgrades-you-should-be-u...
- arc-in-space 6y agoI hope dang forgives me my tone, and my compulsion to respond to everything. I'm getting the sense you have no idea what's being talked about here, and what tuple is actually for. Instead of saying anything at all you give me two links, one of which is a 30 minute read(are you serious?) that seems to have little to do with the topic, and the other is literally just an explanation of what std::any is(really, are you serious?). I'll try to be at least somewhat charitable, and explain where I'm coming from. Tuple is a statically-typed container, that is useful in a generic context - which, crucially, doesn't mean polymorphic at runtime! - because its members' types can be inspected at compile time, unlike a struct. This makes it useful for implementing all sorts of template magic. You can also use it like a anonymous struct, for a quick-and-dirty way to return multiple values from a function, though a struct is often better. std::any, on the other hand, is, uh, not like that at all, whether it is in a vector or not. It holds a single value that is polymorphic at runtime, by erasing its type, which has nothing to do with tuples, and helps with none of the above.