CETL 2.1.0
 
Loading...
Searching...
No Matches
cetl Namespace Reference

Namespaces

namespace  pf17
 
namespace  pf20
 
namespace  pmr
 

Classes

class  bad_optional_access
 
class  bad_unbounded_variant_access
 
class  bad_variant_access
 
class  basic_string_view
 
struct  conjunction
 
struct  disjunction
 
struct  in_place_index_t
 
struct  in_place_t
 
struct  in_place_type_t
 
struct  is_nothrow_swappable
 
struct  is_swappable
 
struct  monostate
 
struct  negation
 
struct  nullopt_t
 
class  optional
 
struct  overloaded
 
struct  overloaded< T >
 
struct  overloaded< T, Ts... >
 
class  rtti
 
struct  rtti_helper
 
class  T
 
class  unbounded_variant
 
class  variable_length_array
 
class  variable_length_array< bool, Allocator >
 
class  variant
 
struct  variant_alternative
 
struct  variant_size
 

Typedefs

using byte = cetl::pf17::byte
 
template<typename T, std::size_t Extent = dynamic_extent>
using span = cetl::pf20::span<T, Extent>
 
using type_id = std::array<std::uint8_t, type_id_size>
 
template<std::uint8_t... Bytes>
using type_id_type = std::integer_sequence<std::uint8_t, Bytes...>
 
template<typename ValueType>
using unbounded_variant_like
 
template<typename...>
using void_t
 
template<size_t N, typename V>
using variant_alternative_t
 
using string_view
 

Functions

template<typename TypeIDType>
constexpr type_id type_id_type_value () noexcept
 
template<typename T>
constexpr type_id type_id_getter () noexcept
 
template<>
constexpr type_id type_id_getter< void > () noexcept
 
template<typename _u>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _u >, bool > is_instance_of (const _u &obj, const type_id &id) noexcept
 
template<typename _u>
CETL_NODISCARD std::enable_if_t<!is_rtti_convertible< _u > &&has_type_id< _u >, bool > is_instance_of (const _u &, const type_id &id) noexcept
 
template<typename Q, typename _u>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _u >||has_type_id< _u >, bool > is_instance_of (const _u &obj) noexcept
 
template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename... Args, typename = detail::enable_if_not_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant make_unbounded_variant (Args &&... args)
 
template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename Up, typename... Args, typename = detail::enable_if_not_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant make_unbounded_variant (std::initializer_list< Up > list, Args &&... args)
 
template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename... Args, typename = detail::enable_if_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant make_unbounded_variant (typename UnboundedVariant::pmr_type *const mem_res, Args &&... args)
 
template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename Up, typename... Args, typename = detail::enable_if_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant make_unbounded_variant (typename UnboundedVariant::pmr_type *const mem_res, std::initializer_list< Up > list, Args &&... args)
 
template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD std::add_pointer_t< std::add_const_t< ValueType > > get_if (const UbVar< Footprint, Copyable, Movable, Alignment, Pmr > *const operand) noexcept
 
template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD std::add_pointer_t< ValueType > get_if (UbVar< Footprint, Copyable, Movable, Alignment, Pmr > *const operand) noexcept
 
template<typename ValueType, template< std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD const ValueType & get (const UbVar< Footprint, Copyable, Movable, Alignment, Pmr > &operand)
 
template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD ValueType & get (UbVar< Footprint, Copyable, Movable, Alignment, Pmr > &operand)
 
template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD ValueType get (UbVar< Footprint, Copyable, Movable, Alignment, Pmr > &&operand)
 
template<typename... Ts>
constexpr overloaded< Ts... > make_overloaded (Ts &&... ts)
 
template<typename InputIt, typename ForwardIt>
ForwardIt uninitialized_move (InputIt first, InputIt last, ForwardIt destination)
 
template<typename T>
CETL_NODISCARD constexpr T * launder (T *const p) noexcept
 
template<typename T>
constexpr optional< std::decay_t< T > > make_optional (T &&value)
 
template<std::size_t Ix, typename... Ts>
CETL_NODISCARD constexpr variant_alternative_t< Ix, variant< Ts... > > & get (variant< Ts... > &var)
 
template<std::size_t Ix, typename... Ts>
CETL_NODISCARD constexpr std::add_pointer_t< variant_alternative_t< Ix, variant< Ts... > > > get_if (variant< Ts... > *const var) noexcept
 
template<typename Fun, typename... Vs>
constexpr decltype(auto) visit (Fun &&fun, Vs &&... vars)
 
template<typename T, typename... Ts>
CETL_NODISCARD constexpr bool holds_alternative (const variant< Ts... > &var) noexcept
 
template<>
constexpr type_id type_id_getter< bool > () noexcept
 
template<>
constexpr type_id type_id_getter< char > () noexcept
 
template<>
constexpr type_id type_id_getter< signed char > () noexcept
 
template<>
constexpr type_id type_id_getter< unsigned char > () noexcept
 
template<>
constexpr type_id type_id_getter< wchar_t > () noexcept
 
template<>
constexpr type_id type_id_getter< char16_t > () noexcept
 
template<>
constexpr type_id type_id_getter< char32_t > () noexcept
 
template<>
constexpr type_id type_id_getter< short > () noexcept
 
template<>
constexpr type_id type_id_getter< unsigned short > () noexcept
 
template<>
constexpr type_id type_id_getter< int > () noexcept
 
template<>
constexpr type_id type_id_getter< unsigned int > () noexcept
 
template<>
constexpr type_id type_id_getter< long > () noexcept
 
template<>
constexpr type_id type_id_getter< unsigned long > () noexcept
 
template<>
constexpr type_id type_id_getter< long long > () noexcept
 
template<>
constexpr type_id type_id_getter< unsigned long long > () noexcept
 
template<>
constexpr type_id type_id_getter< float > () noexcept
 
template<>
constexpr type_id type_id_getter< double > () noexcept
 
template<>
constexpr type_id type_id_getter< long double > () noexcept
 
template<>
constexpr type_id type_id_getter< std::nullptr_t > () noexcept
 
template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, T > rtti_cast (_from *const obj) noexcept
 
template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, const std::remove_pointer_t< T > * > rtti_cast (const _from *const obj) noexcept
 
template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t<!is_rtti_convertible< _from > &&has_type_id< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, T > rtti_cast (_from *const obj) noexcept
 
template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t<!is_rtti_convertible< _from > &&has_type_id< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, const std::remove_pointer_t< T > * > rtti_cast (const _from *const obj) noexcept
 

Variables

constexpr std::size_t dynamic_extent = cetl::pf20::dynamic_extent
 
constexpr std::size_t type_id_size = 16
 
template<typename T>
constexpr bool has_type_id
 
template<typename T>
constexpr bool is_rtti_convertible = decltype(detail::has_cast_impl<std::decay_t<T>>(0))::value
 
template<typename T>
constexpr type_id type_id_value = type_id_getter<std::remove_cv_t<std::remove_reference_t<T>>>()
 
constexpr in_place_t in_place
 
template<typename T>
constexpr in_place_type_t< T > in_place_type
 
template<std::size_t I>
constexpr in_place_index_t< I > in_place_index
 
constexpr nullopt_t nullopt
 
template<typename T>
constexpr bool is_swappable_v
 
template<typename T>
constexpr bool is_nothrow_swappable_v
 
template<typename... Ts>
constexpr bool conjunction_v
 
template<typename... Ts>
constexpr bool disjunction_v
 
template<typename T>
constexpr bool negation_v
 
template<typename V>
constexpr size_t variant_size_v
 
constexpr std::size_t variant_npos
 

Detailed Description

This namespace contains types specific to CETL and nested namespaces that contain types adhering to target C++ specifications.

Typedef Documentation

◆ type_id

A 16-byte UUID (GUID) that uniquely identifies a type.

The user is responsible for ensuring that each type that has opted into this RTTI capability has a unique type ID exposed via a public method static constexpr cetl::type_id get_type_id() noexcept.

◆ type_id_type

template<std::uint8_t... Bytes>
using cetl::type_id_type = std::integer_sequence<std::uint8_t, Bytes...>

This is used for representing the type ID of a type as a type, similar to std::integral_constant.

The bytes of the UUID are given as a list of template parameters; there shall be at most 16 of them; if any are missing, they are assumed to be 0. For conversion to type_id use cetl::type_id_type_value. Please don't use empty or all zeros bytes (reserved for type_id_value<void> specialization).

◆ unbounded_variant_like

template<typename ValueType>
using cetl::unbounded_variant_like
Initial value:
unbounded_variant<sizeof(ValueType),
alignof(ValueType)>
The class unbounded_variant describes a type-safe container for single values of unbounded_variant co...
Definition unbounded_variant.hpp:1029

Typealias for unbounded_variant with the given ValueType with the default footprint, copyability, movability, and alignment of the ValueType.

In use by cetl::make_unbounded_variant overloads.

◆ variant_alternative_t

template<size_t N, typename V>
using cetl::pf17::variant_alternative_t

Implementation of std::variant_alternative_t.

This implementation also accepts other typelist-parameterized classes, such as std::variant.

◆ void_t

template<typename...>
using cetl::pf17::void_t

Implementation of std::void_t.

Function Documentation

◆ get() [1/4]

template<typename ValueType, template< std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD const ValueType & cetl::get ( const UbVar< Footprint, Copyable, Movable, Alignment, Pmr > & operand)

Performs type-safe access to the contained object.

Parameters
operandTarget unbounded_variant object.
Returns
Returns std::static_cast<ValueType>(*cetlget_if<const U>(&operand)), where let U be std::remove_cv_t<std::remove_reference_t<ValueType>>.

References CETL_NODISCARD, and get_if().

◆ get() [2/4]

template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD ValueType cetl::get ( UbVar< Footprint, Copyable, Movable, Alignment, Pmr > && operand)

Performs type-safe access to the contained object.

Parameters
operandTarget unbounded_variant object.
Returns
Returns std::static_cast<ValueType>(std::move(*cetlget_if<U>(&operand))), where let U be std::remove_cv_t<std::remove_reference_t<ValueType>>.

References CETL_NODISCARD, and get_if().

◆ get() [3/4]

template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD ValueType & cetl::get ( UbVar< Footprint, Copyable, Movable, Alignment, Pmr > & operand)

Performs type-safe access to the contained object.

Parameters
operandTarget unbounded_variant object.
Returns
Returns std::static_cast<ValueType>(*cetlget_if<U>(&operand)), where let U be std::remove_cv_t<std::remove_reference_t<ValueType>>.

References CETL_NODISCARD, and get_if().

◆ get() [4/4]

template<std::size_t Ix, typename... Ts>
CETL_NODISCARD constexpr variant_alternative_t< Ix, variant< Ts... > > & cetl::pf17::get ( variant< Ts... > & var)
constexpr

Implementation of std::get(std::variant).

◆ get_if() [1/3]

template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD std::add_pointer_t< std::add_const_t< ValueType > > cetl::get_if ( const UbVar< Footprint, Copyable, Movable, Alignment, Pmr > *const operand)
noexcept

Performs type-safe access to the const contained object.

Template Parameters
ValueTypeType of the requested value; may not be a reference.
UbVarTemplate type of the unbounded_variant object.
Parameters
operandTarget constant unbounded_variant object.
Returns
If operand is not a null pointer, and the typeid of the requested ValueType matches that of the contents of operand, a pointer to the value contained by operand, otherwise a null pointer.

References CETL_NODISCARD.

Referenced by cetl::pmr::function< Result(Args...), Footprint, Pmr >::function(), get(), get(), get(), cetl::pmr::function< Result(Args...), Footprint, Pmr >::operator=(), cetl::pmr::function< Result(Args...), Footprint, Pmr >::operator=(), cetl::pmr::function< Result(Args...), Footprint, Pmr >::operator=(), and cetl::pmr::function< Result(Args...), Footprint, Pmr >::swap().

Here is the caller graph for this function:

◆ get_if() [2/3]

template<typename ValueType, template< std::size_t, bool, bool, std::size_t, typename > class UbVar, std::size_t Footprint, bool Copyable, bool Movable, std::size_t Alignment, typename Pmr, typename = std::enable_if_t<std::is_same<UbVar<Footprint, Copyable, Movable, Alignment, Pmr>, unbounded_variant<Footprint, Copyable, Movable, Alignment, Pmr>>::value>>
CETL_NODISCARD std::add_pointer_t< ValueType > cetl::get_if ( UbVar< Footprint, Copyable, Movable, Alignment, Pmr > *const operand)
noexcept

Performs type-safe access to the contained object.

Template Parameters
ValueTypeType of the requested value; may not be a reference.
UbVarTemplate type of the unbounded_variant object.
Parameters
operandTarget unbounded_variant object.
Returns
If operand is not a null pointer, and the typeid of the requested ValueType matches that of the contents of operand, a pointer to the value contained by operand, otherwise a null pointer.

References CETL_NODISCARD.

◆ get_if() [3/3]

template<std::size_t Ix, typename... Ts>
CETL_NODISCARD constexpr std::add_pointer_t< variant_alternative_t< Ix, variant< Ts... > > > cetl::pf17::get_if ( variant< Ts... > *const var)
constexprnoexcept

Implementation of std::get_if(std::variant).

◆ holds_alternative()

template<typename T, typename... Ts>
CETL_NODISCARD constexpr bool cetl::pf17::holds_alternative ( const variant< Ts... > & var)
constexprnoexcept

Implementation of std::holds_alternative.

◆ is_instance_of() [1/3]

template<typename _u>
CETL_NODISCARD std::enable_if_t<!is_rtti_convertible< _u > &&has_type_id< _u >, bool > cetl::is_instance_of ( const _u & ,
const type_id & id )
noexcept

Detects whether the given object of a type that has a type ID but does not implement cetl::rtti::_cast_ (such as a non-polymorphic or built-in type) is an instance of the type with the given type ID.

Such an object is an instance of its own static type only.

References CETL_NODISCARD, has_type_id, and type_id_value.

◆ is_instance_of() [2/3]

template<typename Q, typename _u>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _u >||has_type_id< _u >, bool > cetl::is_instance_of ( const _u & obj)
noexcept

Detects whether the given object is an instance of the given type.

Q shall satisfy cetl::has_type_id. Refer to the non-template overloads for details.

References CETL_NODISCARD, has_type_id, is_instance_of(), and type_id_value.

◆ is_instance_of() [3/3]

template<typename _u>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _u >, bool > cetl::is_instance_of ( const _u & obj,
const type_id & id )
noexcept

Detects whether the given polymorphic object is an instance of the type with the given type ID.

For example, given a polymorphic type hierarchy A<-B<-C, is_instance_of(C{}, get_type_id<X>())==true for X in {A,B,C}; while is_instance_of(A{}, get_type_id<X>())==true only for X=A.

Note that the type of the object argument is not rtti& but the actual type of the object, because in the presence of multiple inheritance implicit conversion to the base class is ambiguous.

References CETL_NODISCARD.

Referenced by is_instance_of().

Here is the caller graph for this function:

◆ launder()

template<typename T>
CETL_NODISCARD constexpr T * cetl::pf17::launder ( T *const p)
constexprnoexcept

Returns a pointer to the object of type T that is located at the address p holds.

Since C++17 (P0137R1) a pointer obtained by casting the address of some storage does not point to an object that was later created in that storage with placement new; it has to be passed through std::launder first. This is std::launder where the standard library provides it. Before C++17 the cast pointer already points to the object, so this returns p unchanged.

Template Parameters
TThe type of the object. Must not be a function type or (cv-qualified) void.
Parameters
pThe address of an object of type T that is within its lifetime.
Returns
A pointer to that object.

◆ make_optional()

template<typename T>
optional< std::decay_t< T > > cetl::pf17::make_optional ( T && value)
constexpr

An implementation of C++17 std::make_optional.

◆ make_overloaded()

template<typename... Ts>
overloaded< Ts... > cetl::make_overloaded ( Ts &&... ts)
constexpr

Returns an instance of overloaded that can be used with visit.

The usage is as follows:

[](const auto&) { return "fallback"; },
[](double) { return "double"; },
[](const std::string&) { return "string"; }
An implementation of std::variant.
Definition variant.hpp:871
constexpr decltype(auto) visit(Fun &&fun, Vs &&... vars)
Implementation of std::visit.
Definition variant.hpp:1217
constexpr overloaded< Ts... > make_overloaded(Ts &&... ts)
Returns an instance of overloaded that can be used with visit.
Definition visit_helpers.hpp:58

References std::forward().

◆ make_unbounded_variant() [1/4]

template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename... Args, typename = detail::enable_if_not_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant cetl::make_unbounded_variant ( Args &&... args)

Makes an unbounded_variant object with in place constructed value.

Size of the value must be less than or equal to Footprint. Any failure during the construction will result in the "valueless by exception" state.

Template Parameters
ValueTypeType of the value to be stored. Its size must be less than or equal to Footprint.
UnboundedVariantTemplate type of the result unbounded variant.
ArgsTypes of arguments to be passed to the constructor of ValueType.
Parameters
argsArguments to be forwarded to the constructor of ValueType.

References CETL_NODISCARD, and std::forward().

◆ make_unbounded_variant() [2/4]

template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename Up, typename... Args, typename = detail::enable_if_not_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant cetl::make_unbounded_variant ( std::initializer_list< Up > list,
Args &&... args )

Makes an unbounded_variant object with in place constructed value and initializer list.

Size of the value must be less than or equal to Footprint. Any failure during the construction will result in the "valueless by exception" state.

Template Parameters
ValueTypeType of the value to be stored. Its size must be less than or equal to Footprint.
UnboundedVariantTemplate type of the result unbounded variant.
UpType of the elements of the initializer list.
ArgsTypes of arguments to be passed to the constructor of ValueType.
Parameters
mem_resPointer to a memory resource to be used by the variant.
listInitializer list to be forwarded to the constructor of ValueType.
argsArguments to be forwarded to the constructor of ValueType.

References CETL_NODISCARD, and std::forward().

◆ make_unbounded_variant() [3/4]

template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename... Args, typename = detail::enable_if_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant cetl::make_unbounded_variant ( typename UnboundedVariant::pmr_type *const mem_res,
Args &&... args )

Makes a PMR-enabled unbounded_variant object with in place constructed value.

Size of the value must be less than or equal to Footprint to benefit small object optimization, otherwise the value will be stored into PMR allocated storage. Any failure during the construction will result in the "valueless by exception" state.

Template Parameters
ValueTypeType of the value to be stored. Its size must be less than or equal to Footprint.
UnboundedVariantTemplate type of the result unbounded variant.
ArgsTypes of arguments to be passed to the constructor of ValueType.
Parameters
mem_resPointer to a memory resource to be used by the variant.
listInitializer list to be forwarded to the constructor of ValueType.
argsArguments to be forwarded to the constructor of ValueType.

References CETL_NODISCARD, and std::forward().

◆ make_unbounded_variant() [4/4]

template<typename ValueType, typename UnboundedVariant = unbounded_variant_like<ValueType>, typename Up, typename... Args, typename = detail::enable_if_pmr_t<typename UnboundedVariant::pmr_type>>
CETL_NODISCARD UnboundedVariant cetl::make_unbounded_variant ( typename UnboundedVariant::pmr_type *const mem_res,
std::initializer_list< Up > list,
Args &&... args )

Makes a PMR-enabled unbounded_variant object with in place constructed value and initializer list.

Size of the value must be less than or equal to Footprint to benefit small object optimization, otherwise the value will be stored into PMR allocated storage. Any failure during the construction will result in the "valueless by exception" state.

Template Parameters
ValueTypeType of the value to be stored. Its size must be less than or equal to Footprint.
UnboundedVariantTemplate type of the result unbounded variant.
UpType of the elements of the initializer list.
ArgsTypes of arguments to be passed to the constructor of ValueType.
Parameters
mem_resPointer to a memory resource to be used by the variant.
listInitializer list to be forwarded to the constructor of ValueType.
argsArguments to be forwarded to the constructor of ValueType.

References CETL_NODISCARD, and std::forward().

◆ rtti_cast() [1/4]

template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, T > cetl::rtti_cast ( _from *const obj)
noexcept

Performs a safe dynamic type up-/down-conversion in constant time by invoking cetl::rtti::_cast_.

T shall be a pointer and std::remove_pointer_t<T> shall satisfy cetl::has_type_id. Returns nullptr if a safe dynamic type conversion to T is not possible.

References type_id_value.

◆ rtti_cast() [2/4]

template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t<!is_rtti_convertible< _from > &&has_type_id< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, T > cetl::rtti_cast ( _from *const obj)
noexcept

Performs a safe type conversion for types that have a type ID but do not implement cetl::rtti::_cast_, such as non-polymorphic types and built-in types.

Such types carry no runtime type information beyond their static type, so the conversion succeeds iff std::remove_pointer_t<T> is the static type of the object, ignoring cv-qualifiers (which can be added but not removed). Matching type IDs are not sufficient because a derived type may inherit the _get_type_id_() of its base; conversion to a base class is not supported. Returns nullptr if the object pointer is null or the static types differ.

◆ rtti_cast() [3/4]

template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t< is_rtti_convertible< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, const std::remove_pointer_t< T > * > cetl::rtti_cast ( const _from *const obj)
noexcept

Performs a safe dynamic type up-/down-conversion in constant time by invoking cetl::rtti::_cast_.

T shall be a pointer and std::remove_pointer_t<T> shall satisfy cetl::has_type_id. Returns nullptr if a safe dynamic type conversion to T is not possible.

References type_id_value.

◆ rtti_cast() [4/4]

template<typename T, typename _from>
CETL_NODISCARD std::enable_if_t<!is_rtti_convertible< _from > &&has_type_id< _from > &&std::is_pointer< T >::value &&has_type_id< std::remove_pointer_t< T > >, const std::remove_pointer_t< T > * > cetl::rtti_cast ( const _from *const obj)
noexcept

Performs a safe type conversion for types that have a type ID but do not implement cetl::rtti::_cast_, such as non-polymorphic types and built-in types.

Such types carry no runtime type information beyond their static type, so the conversion succeeds iff std::remove_pointer_t<T> is the static type of the object, ignoring cv-qualifiers (which can be added but not removed). Matching type IDs are not sufficient because a derived type may inherit the _get_type_id_() of its base; conversion to a base class is not supported. Returns nullptr if the object pointer is null or the static types differ.

◆ type_id_getter()

template<typename T>
type_id cetl::type_id_getter ( )
constexprnoexcept

The type ID getter for the given type.

This helper is provided for regularity; it returns the same value as T::_get_type_id_(). The type shall satisfy cetl::has_type_id. Specialize this getter to add RTTI support to types where it is not possible to define a static method (e.g., pointers, third-party classes, etc). The built-in types are already specialized by CETL below. Specialize it only for cv-unqualified non-reference types; cetl::type_id_value strips the qualifiers.

◆ type_id_getter< bool >()

template<>
type_id cetl::type_id_getter< bool > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< char >()

template<>
type_id cetl::type_id_getter< char > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< char16_t >()

template<>
type_id cetl::type_id_getter< char16_t > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< char32_t >()

template<>
type_id cetl::type_id_getter< char32_t > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< double >()

template<>
type_id cetl::type_id_getter< double > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< float >()

template<>
type_id cetl::type_id_getter< float > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< int >()

template<>
type_id cetl::type_id_getter< int > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< long >()

template<>
type_id cetl::type_id_getter< long > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< long double >()

template<>
type_id cetl::type_id_getter< long double > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< long long >()

template<>
type_id cetl::type_id_getter< long long > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< short >()

template<>
type_id cetl::type_id_getter< short > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< signed char >()

template<>
type_id cetl::type_id_getter< signed char > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< std::nullptr_t >()

template<>
type_id cetl::type_id_getter< std::nullptr_t > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< unsigned char >()

template<>
type_id cetl::type_id_getter< unsigned char > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< unsigned int >()

template<>
type_id cetl::type_id_getter< unsigned int > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< unsigned long >()

template<>
type_id cetl::type_id_getter< unsigned long > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< unsigned long long >()

template<>
type_id cetl::type_id_getter< unsigned long long > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< unsigned short >()

template<>
type_id cetl::type_id_getter< unsigned short > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_getter< void >()

template<>
type_id cetl::type_id_getter< void > ( )
constexprnoexcept

The type ID getter specialization reserved for void type - returns all zeros.

◆ type_id_getter< wchar_t >()

template<>
type_id cetl::type_id_getter< wchar_t > ( )
constexprnoexcept

Type ID getter specializations for the built-in (fundamental) types, which cannot define _get_type_id_().

These make the built-in types usable with cetl::unbounded_variant and the RTTI helpers out of the box. The values are fixed UUIDs that are part of the CETL API; they will not change between releases.

◆ type_id_type_value()

template<typename TypeIDType>
type_id cetl::type_id_type_value ( )
constexprnoexcept

A helper that converts cetl::type_id_type to cetl::type_id.

Referenced by cetl::rtti_helper< TypeIDType, Bases >::_get_type_id_().

Here is the caller graph for this function:

◆ uninitialized_move()

template<typename InputIt, typename ForwardIt>
ForwardIt cetl::pf17::uninitialized_move ( InputIt first,
InputIt last,
ForwardIt destination )

Polyfill for std::uninitialized_move.

Implements the sequential, three-argument overload. Constructs objects from [first, last) in uninitialized storage starting at destination. Execution-policy overloads and uninitialized_move_n are not provided.

Lvalue sources are moved from, even when copying could avoid a throwing move constructor. Other source expressions retain their value category, as specified by LWG 3918. The destination value type must be constructible from std::move(*first) for lvalue source expressions, or from *first otherwise, under the active C++ language version's initialization rules.

The source range must be valid and must not overlap the destination range. The destination must provide sufficient, suitably aligned uninitialized storage for every source element. Destruction of destination objects must not throw. The caller owns the destination storage; this function neither allocates nor deallocates it. On success, all constructed objects remain alive and the caller is responsible for destroying them.

When dereferencing the source produces a prvalue of the destination type, C++17 and newer require no copy/move constructor for destination construction. In C++14, the selected copy/move constructor must be accessible and not deleted, and callers must not assume that its invocation will be elided.

Source elements may already have been moved from when an exception occurs; their original values are not restored. When compiled with exceptions disabled, no exception rollback is provided.

Complexity is linear in the number of source elements, with one destination construction per element on success.

Template Parameters
InputItSource iterator type meeting the input iterator requirements.
ForwardItDestination iterator type meeting the forward iterator requirements. Assignment, comparison, increment, and indirection through valid iterators must not throw, and indirection must yield a reference to the iterator's value_type.
Parameters
firstBeginning of the source range.
lastEnd of the source range.
destinationBeginning of the destination storage.
Returns
Iterator immediately past the constructed destination range, or destination if the source range is empty.
Exceptions
...With exceptions enabled, propagates any exception from construction or a source iterator operation. Every destination object successfully constructed by this call is destroyed exactly once before propagation, in an unspecified order. The object whose constructor failed is not destroyed.

◆ visit()

template<typename Fun, typename... Vs>
decltype(auto) cetl::pf17::visit ( Fun && fun,
Vs &&... vars )
constexpr

Implementation of std::visit.

Variable Documentation

◆ conjunction_v

template<typename... Ts>
bool cetl::pf17::conjunction_v
constexpr

Implementation of std::conjunction_v.

◆ disjunction_v

template<typename... Ts>
bool cetl::pf17::disjunction_v
constexpr

Implementation of std::disjunction_v.

◆ has_type_id

template<typename T>
bool cetl::has_type_id
constexpr
Initial value:
=
decltype(detail::has_type_id_impl<std::decay_t<T>>(0))::value || detail::has_builtin_type_id<std::decay_t<T>>

True iff T has a public static method _get_type_id_() or is a built-in type for which CETL provides a cetl::type_id_getter specialization.

CV-qualifiers and references are ignored. User-provided cetl::type_id_getter specializations are not detected.

Referenced by is_instance_of(), and is_instance_of().

◆ in_place

in_place_t cetl::pf17::in_place
constexpr

Polyfill for std::in_place.

◆ in_place_index

template<std::size_t I>
in_place_index_t<I> cetl::pf17::in_place_index
constexpr

Implementation of std::in_place_index.

◆ in_place_type

template<typename T>
in_place_type_t<T> cetl::pf17::in_place_type
constexpr

Implementation of std::in_place_type.

◆ is_nothrow_swappable_v

template<typename T>
bool cetl::pf17::is_nothrow_swappable_v
constexpr

Implementation of std::is_nothrow_swappable_v.

◆ is_rtti_convertible

template<typename T>
bool cetl::is_rtti_convertible = decltype(detail::has_cast_impl<std::decay_t<T>>(0))::value
constexpr

True iff T has a public method _cast_().

◆ is_swappable_v

template<typename T>
bool cetl::pf17::is_swappable_v
constexpr

Implementation of std::is_swappable_v.

◆ negation_v

template<typename T>
bool cetl::pf17::negation_v
constexpr

Implementation of std::negation_v.

◆ nullopt

nullopt_t cetl::pf17::nullopt
constexpr

An implementation of C++17 std::nullopt.

◆ type_id_size

std::size_t cetl::type_id_size = 16
constexpr

This many bytes are used to represent a type ID. This is enough to hold a standard UUID (GUID).

◆ type_id_value

template<typename T>
type_id cetl::type_id_value = type_id_getter<std::remove_cv_t<std::remove_reference_t<T>>>()
constexpr

The type ID value of the given type.

This helper is provided for regularity; it has the same value as T::_get_type_id_(). The type shall satisfy cetl::has_type_id or have a cetl::type_id_getter specialization. CV-qualifiers and references are ignored, so type_id_value<const int&> equals type_id_value<int>.

Referenced by is_instance_of(), is_instance_of(), rtti_cast(), and rtti_cast().

◆ variant_npos

std::size_t cetl::pf17::variant_npos
constexpr

Implementation of std::variant_npos.

◆ variant_size_v

template<typename V>
size_t cetl::pf17::variant_size_v
constexpr

Implementation of std::variant_size_v.

This implementation also accepts other typelist-parameterized classes, such as std::variant.