I need to check if the nth element of a tuple is an optional of some type. It has to be an std::optional and not a std::variant (which could have made the code simpler).
My first instinct is the following. But this throws a compiler error.
template<int N, typename TupleToCheck>
void StaticCheck() {
using NthType = typename tuple_element<N, TupleToCheck>::type;
static_assert(std::is_same<NthType, std::optional<NthType::value_type>>);
}
I suspect that this is because the compiler does not know if NthType could have a type value_type
defined within it.
Is there a way to achieve this?