std::holds_alternative (3) - Linux Manuals
std::holds_alternative: std::holds_alternative
NAME
std::holds_alternative - std::holds_alternative
Synopsis
Defined in header <variant>
template <class T, class... Types> (since C++17)
constexpr bool holds_alternative(const std::variant<Types...>& v) noexcept;
Checks if the variant v holds the alternative T. The call is ill-formed if T does not appear exactly once in Types...
Parameters
v - variant to examine
Return value
true if the variant currently holds the alternative T, false otherwise.
Example
// Run this code
Output:
See also
index (public member function)
std::get(std::variant) reads the value of the variant given the index or the type (if the type is unique), throws on error
(C++17)