vari
Loading...
Searching...
No Matches
vari::_uvptr< Deleter, Ts > Class Template Reference

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

#include <uvptr.h>

Inherits vari::_deleter_box< Deleter >.

Public Member Functions

template<typename Deleter2 , typename... Us>
requires ( vconvertible_to< typelist< Us... >, types > && convertible_deleter< Deleter2, Deleter > )
constexpr _uvptr (_uvptr< Deleter2, Us... > &&p) noexcept
 Constructs an uvptr by transfering ownership from uvptr with compatible types.
 
template<typename Deleter2 , typename... Us>
requires ( vconvertible_to< typelist< Us... >, types > && convertible_deleter< Deleter2, Deleter > )
constexpr _uvptr (_uvref< Deleter2, Us... > &&p) noexcept
 Constructs an uvptr by transfering ownership from uvref with compatible types.
 
constexpr _uvptr (std::nullptr_t) noexcept
 Construct a pointer in a null state.
 
template<typename U >
requires ( vconvertible_type< U, types > )
constexpr _uvptr (U *u) noexcept
 Constructs an uvptr which owns a pointer to one of the types that uvptr can reference. More...
 
template<typename U >
requires ( vconvertible_type< U, types > && move_constructible_deleter< Deleter > )
constexpr _uvptr (U *u, Deleter &&d) noexcept
 Constructs an uvptr which owns a pointer to one of the types that uvptr can reference. More...
 
template<typename U >
requires ( vconvertible_type< U, types > && copy_constructible_deleter< Deleter > )
constexpr _uvptr (U *u, Deleter const &d) noexcept
 Constructs an uvptr which owns a pointer to one of the types that uvptr can reference. More...
 
constexpr pointer get () const noexcept
 Returns a pointer to the pointed-to type.
 
Deleter const & get_deleter () const noexcept
 Getter to the internal deleter.
 
Deleter & get_deleter () noexcept
 Getter to the internal deleter.
 
constexpr index_type index () const noexcept
 Returns the index representing the type currently being pointed-to. More...
 
template<typename... Us>
constexpr operator _vptr< Us... > () &&=delete
 Conversion operator from rvalue reference to vptr is forbidden.
 
template<typename... Us>
requires ( vconvertible_to< types, typelist< Us... > > )
constexpr operator _vptr< Us... > () &noexcept
 Conversion operator from lvalue reference to types-compatible vptr
 
template<typename... Us>
requires ( vconvertible_to< types, typelist< Us... > > )
constexpr operator _vptr< Us... > () const &noexcept
 Conversion operator from lvalue const reference to types-compatible vptr
 
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 Deleter2 , typename... Us>
requires ( vconvertible_to< typelist< Us... >, types > && convertible_deleter< Deleter2, Deleter > )
constexpr _uvptroperator= (_uvptr< Deleter2, Us... > &&p) noexcept
 Move assignment operator transfering ownership from uvptr with compatible types. More...
 
constexpr _uvptroperator= (std::nullptr_t) noexcept
 nullptr assignment operator resets this pointer.
 
constexpr pointer release () noexcept
 Release the ownership of managed object, if any. More...
 
template<typename... Fs>
constexpr decltype(auto) take (Fs &&... fs) &&
 Constructs an owning reference to currently pointed-to type and transfers ownership to it. More...
 
template<typename... Fs>
constexpr decltype(auto) visit (Fs &&... f) 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 owning_reference vref () &&noexcept
 Constructs an owning variadic reference and trasnfers ownership of current target to the reference. More...
 
constexpr reference vref () const &noexcept
 Constructs a variadic reference that points to the same target as this pointer. More...
 
constexpr ~_uvptr ()
 Destroys the owned object, if any.
 

Friends

constexpr void swap (_uvptr &lh, _uvptr &rh) noexcept
 Swaps uvptr with each other.
 

Detailed Description

template<typename Deleter, typename... Ts>
class vari::_uvptr< Deleter, Ts >

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

Constructor & Destructor Documentation

◆ _uvptr() [1/3]

template<typename Deleter , typename... Ts>
template<typename U >
requires ( vconvertible_type< U, types > )
constexpr vari::_uvptr< Deleter, Ts >::_uvptr ( U *  u)
inlineconstexprnoexcept

Constructs an uvptr which owns a pointer to one of the types that uvptr can reference.

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

◆ _uvptr() [2/3]

template<typename Deleter , typename... Ts>
template<typename U >
requires ( vconvertible_type< U, types > && copy_constructible_deleter< Deleter > )
constexpr vari::_uvptr< Deleter, Ts >::_uvptr ( U *  u,
Deleter const &  d 
)
inlineconstexprnoexcept

Constructs an uvptr which owns a pointer to one of the types that uvptr can reference.

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

Internal Deleter is copy-constructed from d.

◆ _uvptr() [3/3]

template<typename Deleter , typename... Ts>
template<typename U >
requires ( vconvertible_type< U, types > && move_constructible_deleter< Deleter > )
constexpr vari::_uvptr< Deleter, Ts >::_uvptr ( U *  u,
Deleter &&  d 
)
inlineconstexprnoexcept

Constructs an uvptr which owns a pointer to one of the types that uvptr can reference.

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

Internal Deleter is move-constructed from d.

Member Function Documentation

◆ index()

template<typename Deleter , typename... Ts>
constexpr index_type vari::_uvptr< Deleter, 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 Deleter , typename... Ts>
constexpr auto & vari::_uvptr< Deleter, 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 Deleter , typename... Ts>
constexpr auto * vari::_uvptr< Deleter, 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.

◆ operator=()

template<typename Deleter , typename... Ts>
template<typename Deleter2 , typename... Us>
requires ( vconvertible_to< typelist< Us... >, types > && convertible_deleter< Deleter2, Deleter > )
constexpr _uvptr & vari::_uvptr< Deleter, Ts >::operator= ( _uvptr< Deleter2, Us... > &&  p)
inlineconstexprnoexcept

Move assignment operator transfering ownership from uvptr with compatible types.

Deleter is move-constructed from the other uvptr.

◆ release()

template<typename Deleter , typename... Ts>
constexpr pointer vari::_uvptr< Deleter, Ts >::release ( )
inlineconstexprnoexcept

Release the ownership of managed object, if any.

Returns pointer to the managed object, it is reponsibility of caller to clean it up.

◆ take()

template<typename Deleter , typename... Ts>
template<typename... Fs>
constexpr decltype(auto) vari::_uvptr< Deleter, Ts >::take ( Fs &&...  fs) &&
inlineconstexpr

Constructs an owning reference to currently pointed-to type and transfers ownership to it.

Moves it to the appropriate function from the list fs.... In case the this is null calls overload with empty_t.

◆ vref() [1/2]

template<typename Deleter , typename... Ts>
constexpr owning_reference vari::_uvptr< Deleter, Ts >::vref ( ) &&
inlineconstexprnoexcept

Constructs an owning variadic reference and trasnfers ownership of current target to the reference.

Undefined behavior if the pointer is null.

◆ vref() [2/2]

template<typename Deleter , typename... Ts>
constexpr reference vari::_uvptr< Deleter, 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: