MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mbgl::Immutable< T > Class Template Reference

#include <immutable.hpp>

Public Member Functions

template<class S >
 Immutable (Mutable< S > &&s)
 
template<class S >
 Immutable (Immutable< S > s)
 
 Immutable (Immutable &&) noexcept=default
 
 Immutable (const Immutable &)=default
 
template<class S >
Immutableoperator= (Mutable< S > &&s)
 
Immutableoperator= (Immutable &&) noexcept=default
 
Immutableoperator= (const Immutable &)=default
 
const T * get () const
 
const T * operator-> () const
 
const T & operator* () const
 

Friends

template<class S >
class Immutable
 
bool operator== (const Immutable< T > &lhs, const Immutable< T > &rhs)
 
bool operator!= (const Immutable< T > &lhs, const Immutable< T > &rhs)
 
template<class S , class U >
Immutable< S > staticImmutableCast (const Immutable< U > &)
 

Detailed Description

template<class T>
class mbgl::Immutable< T >

Immutable<T> is a non-nullable shared reference to a const T. Construction requires a transfer of unique ownership from a Mutable<T>; once constructed it has the same behavior as std::shared_ptr<const T> but with better indication of intent.

Normally one should not share state between threads because it's difficult to verify the absence of read/write data races. Immutable provides a guarantee that no writes are possible, and instances therefore can be freely transferred and shared between threads.

Definition at line 67 of file immutable.hpp.

Constructor & Destructor Documentation

◆ Immutable() [1/4]

template<class T >
template<class S >
mbgl::Immutable< T >::Immutable ( Mutable< S > &&  s)
inline

Definition at line 70 of file immutable.hpp.

◆ Immutable() [2/4]

template<class T >
template<class S >
mbgl::Immutable< T >::Immutable ( Immutable< S >  s)
inline

Definition at line 74 of file immutable.hpp.

◆ Immutable() [3/4]

template<class T >
mbgl::Immutable< T >::Immutable ( Immutable< T > &&  )
defaultnoexcept

◆ Immutable() [4/4]

template<class T >
mbgl::Immutable< T >::Immutable ( const Immutable< T > &  )
default

Member Function Documentation

◆ get()

template<class T >
const T* mbgl::Immutable< T >::get ( ) const
inline

Definition at line 89 of file immutable.hpp.

◆ operator*()

template<class T >
const T& mbgl::Immutable< T >::operator* ( ) const
inline

Definition at line 91 of file immutable.hpp.

◆ operator->()

template<class T >
const T* mbgl::Immutable< T >::operator-> ( ) const
inline

Definition at line 90 of file immutable.hpp.

◆ operator=() [1/3]

template<class T >
Immutable& mbgl::Immutable< T >::operator= ( const Immutable< T > &  )
default

◆ operator=() [2/3]

template<class T >
Immutable& mbgl::Immutable< T >::operator= ( Immutable< T > &&  )
defaultnoexcept

◆ operator=() [3/3]

template<class T >
template<class S >
Immutable& mbgl::Immutable< T >::operator= ( Mutable< S > &&  s)
inline

Definition at line 81 of file immutable.hpp.

Friends And Related Function Documentation

◆ Immutable

template<class T >
template<class S >
friend class Immutable
friend

Definition at line 107 of file immutable.hpp.

◆ operator!=

template<class T >
bool operator!= ( const Immutable< T > &  lhs,
const Immutable< T > &  rhs 
)
friend

Definition at line 97 of file immutable.hpp.

◆ operator==

template<class T >
bool operator== ( const Immutable< T > &  lhs,
const Immutable< T > &  rhs 
)
friend

Definition at line 93 of file immutable.hpp.

◆ staticImmutableCast

template<class T >
template<class S , class U >
Immutable<S> staticImmutableCast ( const Immutable< U > &  u)
friend

Definition at line 114 of file immutable.hpp.


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