Namespaces
Variants
Views
Actions

std::bad_variant_access

From cppreference.com
< cpp‎ | utility‎ | variant
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
 
Defined in header <variant>
class bad_variant_access : public std::exception
(since C++17)

std::bad_variant_access is the type of the exception thrown in the following situations:

(since C++26)

All member functions of std::bad_variant_access are constexpr: it is possible to create and use std::bad_variant_access objects in the evaluation of a constant expression.

However, std::bad_variant_access objects generally cannot be constexpr, because any dynamically allocated storage must be released in the same evaluation of constant expression.

(since C++26)

Contents