std::holds_alternative

From cppreference.com
< cpp‎ | utility‎ | variant
 
 
 
 
Defined in header <variant>
template <class T, class... Types>
constexpr bool holds_alternative(const std::variant<Types...>& v)
(since C++17)

Checks if the variant v holds the alternative T. The call is ill-formed if T appears more than once in Types...

Parameters

v - variant to examine

Return value

true if the variant currently holds the alternative T, false otherwise.

Exceptions

noexcept specification:  
noexcept