dex++ 0.3.1
C++ and C API reference
Loading...
Searching...
No Matches
dex::model::Shared< T > Class Template Reference

An immutable value held by a shared pointer. More...

#include <model/types.hpp>

Public Member Functions

 Shared ()=default
 
template<class U = T>
requires (!std::is_same_v<std::remove_cvref_t<U>, Shared> && std::is_constructible_v<T, U &&>)
 Shared (U &&value)
 Hold a T built from value: Shared<std::string> s = "text".
 
template<class A , class B , class... Rest>
requires std::is_aggregate_v<T>
 Shared (A &&a, B &&b, Rest &&...rest)
 Build an aggregate T in place: Shared<MethodId>{"La;", "run", "()V"}.
 
const T & get () const noexcept
 
const T & operator* () const noexcept
 
const T * operator-> () const noexcept
 

Friends

bool operator== (const Shared &a, const Shared &b)
 

Detailed Description

template<class T>
class dex::model::Shared< T >

An immutable value held by a shared pointer.

Copies share one allocation, but a Shared compares by value and can never be changed in place — to change it, assign a new value — so the sharing is invisible except for memory use. Instruction operands use it: a large method refers to the same few strings, types and members thousands of times.

A default-constructed (or moved-from) Shared holds T{}.

Constructor & Destructor Documentation

◆ Shared() [1/3]

template<class T >
dex::model::Shared< T >::Shared ( )
default

◆ Shared() [2/3]

template<class T >
template<class U = T>
requires (!std::is_same_v<std::remove_cvref_t<U>, Shared> && std::is_constructible_v<T, U &&>)
dex::model::Shared< T >::Shared ( U &&  value)
inline

Hold a T built from value: Shared<std::string> s = "text".

◆ Shared() [3/3]

template<class T >
template<class A , class B , class... Rest>
requires std::is_aggregate_v<T>
dex::model::Shared< T >::Shared ( A &&  a,
B &&  b,
Rest &&...  rest 
)
inline

Build an aggregate T in place: Shared<MethodId>{"La;", "run", "()V"}.

Member Function Documentation

◆ get()

template<class T >
const T & dex::model::Shared< T >::get ( ) const
inlinenoexcept

◆ operator*()

template<class T >
const T & dex::model::Shared< T >::operator* ( ) const
inlinenoexcept

◆ operator->()

template<class T >
const T * dex::model::Shared< T >::operator-> ( ) const
inlinenoexcept

Friends And Related Symbol Documentation

◆ operator==

template<class T >
bool operator== ( const Shared< T > &  a,
const Shared< T > &  b 
)
friend

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