26#include "vari/bits/assert.h"
27#include "vari/bits/ptr_core.h"
28#include "vari/bits/typelist.h"
29#include "vari/bits/util.h"
30#include "vari/forward.h"
40template <
typename... Ts >
44 using types = typelist< Ts... >;
48 constexpr _vptr() =
default;
51 constexpr _vptr& operator=(
_vptr const& ) =
default;
52 constexpr _vptr& operator=(
_vptr&& )
noexcept =
default;
56 constexpr _vptr( std::nullptr_t )
noexcept
62 template <
typename... Us >
63 requires( vconvertible_to< typelist< Us... >, types > )
71 template <
typename... Us >
72 requires( vconvertible_to< typelist< Us... >, types > )
81 template <
typename U >
82 requires( vconvertible_to< typelist< U >, types > )
83 constexpr _vptr( U* u )
noexcept
105 constexpr auto*
get() const noexcept
113 [[nodiscard]]
constexpr index_type
index() const noexcept
115 return _core.get_index();
120 constexpr explicit operator bool() const noexcept
122 return _core.ptr !=
nullptr;
129 VARI_ASSERT( _core.ptr );
138 template <
typename... Fs >
139 constexpr decltype( auto )
visit( Fs&&... fs )
const
141 typename _check_unique_invocability< types >::template with_nullable_pure_ref<
144 if ( _core.ptr ==
nullptr )
145 return _dispatch_fun( empty, (Fs&&) fs... );
146 return _core.visit_impl( (Fs&&) fs... );
154 swap( lh._core, rh._core );
158 _ptr_core< types > _core;
160 template <
typename... Us >
162 template <
typename... Us >
164 template <
typename Deleter,
typename... Us >
166 template <
typename Deleter,
typename... Us >
172template <
typename... Lhs,
typename... Rhs >
175 return lh.get() <=> rh.get();
180template <
typename... Lhs,
typename... Rhs >
183 return lh.get() == rh.get();
188template <
typename... Ts >
A nullable owning pointer to one of the types in Ts...
Definition: uvptr.h:43
A nullable pointer to one of the types in Ts...
Definition: vptr.h:42
constexpr decltype(auto) visit(Fs &&... fs) const
Calls the appropriate function from the list fs..., based on the type of the current target,...
Definition: vptr.h:139
constexpr auto * get() const noexcept
Returns a pointer to the pointed-to type.
Definition: vptr.h:105
constexpr reference vref() const noexcept
Constructs a variadic reference that points to the same target as this pointer.
Definition: vptr.h:127
constexpr auto * operator->() const noexcept
Provides member access to the pointed-to type.
Definition: vptr.h:98
constexpr _vptr(U *u) noexcept
Constructs a vptr from a pointer to one of the types that vptr can reference.
Definition: vptr.h:83
constexpr _vptr(_vptr< Us... > const &p) noexcept
Copy constructor for any compatible vptr.
Definition: vptr.h:73
constexpr _vptr(_vref< Us... > const &r) noexcept
Copy constructor for any compatible vref.
Definition: vptr.h:64
constexpr index_type index() const noexcept
Returns the index representing the type currently being pointed-to.
Definition: vptr.h:113
constexpr auto & operator*() const noexcept
Dereferences to the pointed-to type.
Definition: vptr.h:91
constexpr _vptr(std::nullptr_t) noexcept
Construct a pointer in a null state.
Definition: vptr.h:56
friend constexpr void swap(_vptr &lh, _vptr &rh) noexcept
Swaps vptr with each other.
Definition: vptr.h:152
A non-nullable pointer to one of the types in Ts...
Definition: vref.h:40
MIT License.
Definition: dispatch.h:32
_define_variadic< _vptr, typelist< Ts... > > vptr
A nullable pointer to types derived out of Ts... list by flattening it and filtering for unique types...
Definition: vptr.h:189
_vptr_apply_t< T, unique_typelist_t< flatten_t< TL > >, Extra... > _define_variadic
Given a templated type T and typelist of types TL, aliases T<Us...> where Us... is flattend version o...
Definition: util.h:61
A non-nullable owning pointer to one of the types in Ts...
Definition: uvref.h:43