4.6.0
Freundlich's C++ toolkit
|
A class that can hold any object from a fixed set of types.
Types | The list of element types. It may not contain dupiicates. |
See fcppt.variant for more information.
Public Types | |
using | this_type = fcppt::variant::object<Types...> |
using | types = fcppt::mpl::list::object<Types...> |
The mpl::list of the possible types. | |
using | std_type = fcppt::mpl::list::as<std::variant,types> |
Public Member Functions | |
template<typename U > requires ( fcppt::mpl::list::contains_v<fcppt::mpl::list::object<Types...>, std::remove_cvref_t<U>>) | |
object (U &&) | |
Constructs the variant from a value. | |
template<typename U > | |
U const & | get_unsafe () const |
Returns a const reference to the held type without any checks. | |
template<typename U > | |
U & | get_unsafe () |
Returns a reference to the held type without any checks. | |
fcppt::variant::size_type | type_index () const |
Returns the index of the held type. | |
bool | is_invalid () const |
Returns if the variant is invalid. | |
std_type & | impl () |
std_type const & | impl () const |
using fcppt::variant::object< Types >::std_type = fcppt::mpl::list::as<std::variant,types> |
using fcppt::variant::object< Types >::this_type = fcppt::variant::object<Types...> |
using fcppt::variant::object< Types >::types = fcppt::mpl::list::object<Types...> |
The mpl::list of the possible types.
|
explicit |
Constructs the variant from a value.
Constructs the variant from value.
U | Must be a type among types |
|
nodiscard |
Returns a reference to the held type without any checks.
U | Must be a type among types |
U
.
|
nodiscard |
Returns a const reference to the held type without any checks.
U | Must be a type among types |
U
.
|
nodiscard |
|
nodiscard |
|
nodiscard |
Returns if the variant is invalid.
This can only happen if an assignment of a different type throws an exception. There is no way to recover from that, except for falling back to heap allocation. An invalid variant should only be destroyed or assigned to.
|
nodiscard |
Returns the index of the held type.
types
of the held type.