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"
38template <
typename... Ts >
42 using types = typelist< Ts... >;
48 template <
typename... Us >
49 requires( vconvertible_to< typelist< Us... >, types > )
57 template <
typename U >
58 requires( vconvertible_to< typelist< U >, types > )
59 constexpr _vref( U& u )
noexcept
80 constexpr auto*
get() const noexcept
87 [[nodiscard]]
constexpr index_type
index() const noexcept
89 return _core.get_index();
94 template <
typename U >
95 requires( vconvertible_to< types, typelist< U > > )
96 constexpr operator U&()
const noexcept
112 template <
typename... Fs >
113 constexpr decltype( auto )
visit( Fs&&... fs )
const
115 typename _check_unique_invocability< types >::template with_pure_ref< Fs... > _{};
116 VARI_ASSERT( _core.ptr );
117 return _core.visit_impl( (Fs&&) fs... );
124 swap( lh._core, rh._core );
128 constexpr _vref() noexcept = default;
130 _ptr_core< types > _core;
132 template < typename... Us >
134 template < typename... Us >
136 template < typename Deleter, typename... Us >
138 template < typename Deleter, typename... Us >
144template < typename... Lhs, typename... Rhs >
145constexpr auto operator<=>(
_vref< Lhs... > const& lh,
_vref< Rhs... > const& rh ) noexcept
147 return lh.
get() <=> rh.
get();
152template <
typename... Lhs,
typename... Rhs >
155 return lh.get() == rh.get();
161template <
typename... Ts >
A nullable owning pointer to one of the types in Ts...
Definition: uvptr.h:43
constexpr pointer get() const noexcept
Returns a pointer to the pointed-to type.
Definition: uvptr.h:167
A nullable pointer to one of the types in Ts...
Definition: vptr.h:42
constexpr auto * get() const noexcept
Returns a pointer to the pointed-to type.
Definition: vptr.h:105
A non-nullable pointer to one of the types in Ts...
Definition: vref.h:40
constexpr _vref(U &u) noexcept
Constructs a vref from a reference to one of the types that vref can reference.
Definition: vref.h:59
constexpr pointer vptr() const &noexcept
Constructs a variadic pointer that points to the same target as the current reference.
Definition: vref.h:103
constexpr auto * operator->() const noexcept
Provides member access to the pointed-to type.
Definition: vref.h:73
constexpr index_type index() const noexcept
Returns the index representing the type currently being referenced.
Definition: vref.h:87
constexpr _vref(_vref< Us... > const &p) noexcept
Copy constructor for any compatible vref.
Definition: vref.h:50
constexpr auto * get() const noexcept
Returns a pointer to the pointed-to type.
Definition: vref.h:80
constexpr decltype(auto) visit(Fs &&... fs) const
Calls the appropriate function from the list fs..., based on the type of the current target.
Definition: vref.h:113
constexpr auto & operator*() const noexcept
Dereferences to the pointed-to type.
Definition: vref.h:66
friend constexpr void swap(_vref &lh, _vref &rh) noexcept
Swaps the current reference with another one.
Definition: vref.h:122
MIT License.
Definition: dispatch.h:32
_define_variadic< _vref, typelist< Ts... > > vref
A non-nullable pointer to types derived out of Ts... list by flattening it and filtering for unique t...
Definition: vref.h:162
_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