Hi everyone,I'd like to get a feel for whether or not a type_trait would be welcome for checking if a variant type can hold a type T.Currently, we have `holds_alternative`, which requires an object, and can't be evaluated at compile-time for all expressions.We also have `variant_alternative_t`, but this requires indexing, and leaves implementing a check to the programmer(s) that need it.This would be really handy for constraining classes to only accept types their variants actually take.
Would it be a good idea to think of some good cases for zero and multiple matches, and then come back?
Cheers,
Chris
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh8DEnmoKd6v4E2M17M-c7SdkUtbwfGy6v_bK4kuhC5%3DwC0SA%40mail.gmail.com.
If you really wanted to write your Foo class template today in C++17, I'd argue for writing it like this:template <typename T, typename Enabled = decltype(std::get<T>(std::declval<Example>()))>class Foo {