3 ms·
If you look at http://www.boost.org/doc/libs/1_62_0/doc/html/variant/design.html#variant.design.never-empty.optimizations http://www.boost.org/doc/libs/1_62_0/d
by alexeiz 10y ago
If you look at http://www.boost.org/doc/libs/1_62_0/doc/html/variant/design.html#variant.design.never-empty.optimizations http://www.boost.org/doc/libs/1_62_0/doc/html/variant/design..., Boost variant has no performance penalty due to backup storage if any of its bounded type is nothrow default-constructible. In practice, you just need a single nothrow default-constructible type in boost::variant to satisfy that requirement. This can be `int` or `boost::blank`. And that's that - no performance penalty.
- amluto 10y ago> Boost variant has no performance penalty... I have a big project that uses boost::variant. The runtime performance may be fine, but I swear that just compiling the header took about 5 seconds. Pre-C++-11 fake variadic templates are just painful. (IMHO two of the major missing features in Rust that are really need are integer generics and varidic generics. Without integer generics, arrays over 32 elements don't work correctly, and that's really annoying sometimes.)