vari
Loading...
Searching...
No Matches
vari::_vptr< Ts > Class Template Reference

A nullable pointer to one of the types in Ts... More...

#include <vptr.h>

Public Member Functions

template<typename... Us>
requires ( vconvertible_to< typelist< Us... >, types > )
constexpr _vptr (_vptr< Us... > const &p) noexcept
 Copy constructor for any compatible vptr.
 
template<typename... Us>
requires ( vconvertible_to< typelist< Us... >, types > )
constexpr _vptr (_vref< Us... > const &r) noexcept
 Copy constructor for any compatible vref.
 
constexpr _vptr (std::nullptr_t) noexcept
 Construct a pointer in a null state.
 
template<typename U >
requires ( vconvertible_to< typelist< U >, types > )
constexpr _vptr (U *u) noexcept
 Constructs a vptr from a pointer to one of the types that vptr can reference. More...
 
constexpr auto * get () const noexcept
 Returns a pointer to the pointed-to type. More...
 
constexpr index_type index () const noexcept
 Returns the index representing the type currently being pointed-to. More...
 
constexpr operator bool () const noexcept
 Check if the pointer is not null.
 
constexpr auto & operator* () const noexcept
 Dereferences to the pointed-to type. More...
 
constexpr auto * operator-> () const noexcept
 Provides member access to the pointed-to type. More...
 
template<typename... Fs>
constexpr decltype(auto) visit (Fs &&... fs) const
 Calls the appropriate function from the list fs..., based on the type of the current target, or one with empty_t in case of null pointer.
 
constexpr reference vref () const noexcept
 Constructs a variadic reference that points to the same target as this pointer. More...
 

Friends

constexpr void swap (_vptr &lh, _vptr &rh) noexcept
 Swaps vptr with each other.
 

Detailed Description

template<typename... Ts>
class vari::_vptr< Ts >

A nullable pointer to one of the types in Ts...

Constructor & Destructor Documentation

◆ _vptr()

template<typename... Ts>
template<typename U >
requires ( vconvertible_to< typelist< U >, types > )
constexpr vari::_vptr< Ts >::_vptr ( U *  u)
inlineconstexprnoexcept

Constructs a vptr from a pointer to one of the types that vptr can reference.

If pointer is null, vptr is constructed as if nullptr was passed.

Member Function Documentation

◆ get()

template<typename... Ts>
constexpr auto * vari::_vptr< Ts >::get ( ) const
inlineconstexprnoexcept

Returns a pointer to the pointed-to type.

It is T* if there is only one type in Ts..., or void* otherwise. Can be null.

◆ index()

template<typename... Ts>
constexpr index_type vari::_vptr< Ts >::index ( ) const
inlineconstexprnoexcept

Returns the index representing the type currently being pointed-to.

The index of the first type is 0, with subsequent types sequentially numbered. null_index constant is used in case the pointer is null.

◆ operator*()

template<typename... Ts>
constexpr auto & vari::_vptr< Ts >::operator* ( ) const
inlineconstexprnoexcept

Dereferences to the pointed-to type.

It is T& if there is only one type in Ts..., or void& otherwise. Undefined behavior on null pointer.

◆ operator->()

template<typename... Ts>
constexpr auto * vari::_vptr< Ts >::operator-> ( ) const
inlineconstexprnoexcept

Provides member access to the pointed-to type.

It is T* if there is only one type in Ts..., or void* otherwise. Undefined behavior on null pointer.

◆ vref()

template<typename... Ts>
constexpr reference vari::_vptr< Ts >::vref ( ) const
inlineconstexprnoexcept

Constructs a variadic reference that points to the same target as this pointer.

Undefined behavior if the pointer is null.


The documentation for this class was generated from the following files: