mapbox / variant

C++11/C++14 Variant
BSD 3-Clause "New" or "Revised" License
371 stars 101 forks source link

std::variant_alternative #161

Closed strasdat closed 6 years ago

strasdat commented 7 years ago

Is there an equivalent to std::variant_alternative (http://en.cppreference.com/w/cpp/utility/variant/variant_alternative)?

I could not find it, but maybe I just did not look hard enough ;)

artemp commented 7 years ago

@strasdat - there are some meta-functions to get index for a particular type but not other way around. If you have a compelling use-case for variant_alternative could you share it here, so it can be used as inspiration to add support, pls.

artemp commented 7 years ago

@strasdat - could you try and let me know if variant_alternative works for you https://github.com/mapbox/variant/pull/162

strasdat commented 7 years ago

Thanks; motivation is serialization/deserialization; using frameworks such as boost serialization or cereal.

I will see whether I find some time to try this out tonight...

artemp commented 6 years ago

variant_size and variant_alternative are now in master.