Spicy
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
hilti::rt::Tuple< Ts > Class Template Reference

#include <tuple.h>

Inheritance diagram for hilti::rt::Tuple< Ts >:
hilti::rt::TupleBase

Public Types

using Base = std::tuple< Ts... >
 

Public Member Functions

 Tuple ()
 
template<typename... Us>
 Tuple (tuple::ValueTag, Us &&... us)
 
template<typename... Us>
 Tuple (tuple::OptionalTag, Optional< Us > &&... us)
 
 Tuple (const Tuple &other)=default
 
 Tuple (Tuple &&other)=default
 
template<typename... Us>
 Tuple (Tuple< Us... > &&other)
 
template<typename K , typename V >
 requires (sizeof...(Ts)==2) explicit Tuple(std
 
template<std::size_t Idx>
const auto & get () const
 
template<std::size_t Idx>
auto & get ()
 
Tupleoperator= (const Tuple &other)=default
 
Tupleoperator= (Tuple &&other)=default
 
- Public Member Functions inherited from hilti::rt::TupleBase
constexpr bool hasValue (size_t idx) const noexcept
 

Static Public Member Functions

template<std::size_t Idx>
static ptrdiff_t elementOffset ()
 

Friends

template<typename... Us>
std::weak_ordering operator<=> (const Tuple< Ts... > &t1, const Tuple< Us... > &t2)
 

Additional Inherited Members

- Protected Member Functions inherited from hilti::rt::TupleBase
 TupleBase () noexcept=default
 
 TupleBase (tuple::detail::AllSetTag, uint64_t num_elements)
 
 TupleBase (const TupleBase &other) noexcept=default
 
 TupleBase (TupleBase &&other) noexcept=default
 
void set (size_t idx)
 
TupleBaseoperator= (const TupleBase &other)=default
 
TupleBaseoperator= (TupleBase &&other)=default
 
- Static Protected Attributes inherited from hilti::rt::TupleBase
static constexpr size_t MaxElements = 64
 

Detailed Description

template<typename... Ts>
class hilti::rt::Tuple< Ts >

Runtime representation of HILTI's tuple type. Different from std::tuple, tuple elements can remain unset. If an unset element is accessed, an UnsetTupleElement exception is thrown.

For efficiency, we currently limit the maximum number of tuple elements to

  1. This could be changed if deemed necessary.
Template Parameters
Tstypes of the tuple elements

Constructor & Destructor Documentation

◆ Tuple() [1/6]

template<typename... Ts>
hilti::rt::Tuple< Ts >::Tuple ( )
inline

Default constructor creating an empty tuple with all elements unset.

◆ Tuple() [2/6]

template<typename... Ts>
template<typename... Us>
hilti::rt::Tuple< Ts >::Tuple ( tuple::ValueTag  ,
Us &&...  us 
)
inlineexplicit

Constructor creating a tuple from provided values, with all elements set.

Parameters
tagtag to select this constructor
usvalues for the tuple elements

◆ Tuple() [3/6]

template<typename... Ts>
template<typename... Us>
hilti::rt::Tuple< Ts >::Tuple ( tuple::OptionalTag  ,
Optional< Us > &&...  us 
)
inlineexplicit

Constructor creating a tuple from provided values, with some elements potentially left unset.

Parameters
tagtag to select this constructor
usvalues for the tuple elements wrapped into optionals, with unset optionals leaving the corresponding tuple element unset

◆ Tuple() [4/6]

template<typename... Ts>
hilti::rt::Tuple< Ts >::Tuple ( const Tuple< Ts > &  other)
default

Copy constructor.

◆ Tuple() [5/6]

template<typename... Ts>
hilti::rt::Tuple< Ts >::Tuple ( Tuple< Ts > &&  other)
default

Move constructor.

◆ Tuple() [6/6]

template<typename... Ts>
template<typename... Us>
hilti::rt::Tuple< Ts >::Tuple ( Tuple< Us... > &&  other)
inline

Move constructor from another tuple type having elements of types that convert to ours.

Member Function Documentation

◆ elementOffset()

template<typename... Ts>
template<std::size_t Idx>
static ptrdiff_t hilti::rt::Tuple< Ts >::elementOffset ( )
inlinestatic

Returns the binary offset of a particular element inside the tuple's storage. The offset refers is to the start of the tuple.

Template Parameters
Idxindex of the element to return

◆ get() [1/2]

template<typename... Ts>
template<std::size_t Idx>
auto& hilti::rt::Tuple< Ts >::get ( )
inline

Accessor to retrieve a particular element, assuming it's set.

Template Parameters
Idxindex of the element to retrieve
Returns
reference to the element at index Idx
Exceptions
<tt>UnsetTupleElement</tt>if the element at index Idx is not set

◆ get() [2/2]

template<typename... Ts>
template<std::size_t Idx>
const auto& hilti::rt::Tuple< Ts >::get ( ) const
inline

Accessor to retrieve a particular element, assuming it's set.

Template Parameters
Idxindex of the element to retrieve
Returns
reference to the element at index Idx
Exceptions
<tt>UnsetTupleElement</tt>if the element at index Idx is not set

◆ requires()

template<typename... Ts>
template<typename K , typename V >
hilti::rt::Tuple< Ts >::requires ( sizeof...  Ts = = 2)
inline

Constructor from a std::map::value_type (std::pair<const K, V>), with both elements set. const_cast is safe here because p is &&.


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