std::bad_variant_access
Min standard notice:
Header: <variant>
std::bad_variant_access is the type of the exception thrown in the following situations:
# Declarations
class bad_variant_access : public std::exception
(since C++17)
# Parameters
other: another exception object to copy
# Return value
*this
# Notes
Implementations are allowed but not required to override what().
# Example
#include <iostream>
#include <variant>
int main()
{
std::variant<int, float> v;
v = 12;
try
{
std::get<float>(v);
}
catch (const std::bad_variant_access& e)
{
std::cout << e.what() << '\n';
}
}