- C++ 2017 -- win, lose and draw - 10 Updates
- "Distinguishing between maybe-null vs never-null is the important thing" - 4 Updates
- Onwards and upwards - 1 Update
- [ot] set sound on frame - 1 Update
- what happens when prefix a lambda functor with * or + ? - 3 Updates
- Michael Moroney can't/won't read me properly. - 1 Update
- The required minimum omega for double - 1 Update
woodbrian77@gmail.com: Feb 15 09:12AM -0800 > std::string. That seems to still be missing from gcc 7.0 > and clang 3.9.1. That's kind of frustrating. > std::variant == win But why is std::variant<float> allowed? If you have std::variant<float, double> then sometimes it could have a float and other times a double. "to exhibit or undergo change <the sky was constantly varying>" https://www.merriam-webster.com/dictionary/vary Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net Brian Ebenezer Enterprises |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Feb 15 05:36PM > But why is std::variant<float> allowed? If you have > std::variant<float, double> then sometimes it could > have a float and other times a double. Asking why is it allowed is a naive question. Sometimes you might want variant<T, float>, sometimes you might want variant<T, double> and sometimes you might want variant<T, float, double> or even a plain variant<float, double>. Just because you cannot think of a reason why you might want that it doesn't mean that other people can't think of a reason. One example I can think of off the top of my head would be to use a variant to represent types of objects in a scripting language and that scripting language supports both 32-bit and 64-bit floating point types just like C++. /Flibble |
scott@slp53.sl.home (Scott Lurndal): Feb 15 05:51PM >Sometimes you might want variant<T, float>, sometimes you might want >variant<T, double> and sometimes you might want variant<T, float, >double> or even a plain variant<float, double>. While std::variant is very similar to Pascal variant records, personally I don't see any advantage over a plain old union (which when I use them, I generally am using them to access _both_ variants, e.g. if I need access to a subset (say a bitfield) of a larger value or to access the floating point value directly as a collection of bitfields (sign, exponent, mantissa)). e.g. union REGISTER_NAME { uint64_t u; struct REGISTER_NAME_S { #if __BYTE_ORDER == __BIG_ENDIAN uint64_t reserved_48_63: 16; uint64_t vmid : 16; uint64_t base : 32; #else uint64_t base : 32; uint64_t vmid : 16; uint64_t reserved_48_63: 16;
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment