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

#include <immutable.hpp>

Public Member Functions

 Mutable (Mutable &&) noexcept=default
 
Mutableoperator= (Mutable &&) noexcept=default
 
 Mutable (const Mutable &)=delete
 
Mutableoperator= (const Mutable &)=delete
 
T * get ()
 
T * operator-> ()
 
T & operator* ()
 

Friends

template<class S >
class Immutable
 
template<class S , class... Args>
Mutable< S > makeMutable (Args &&...)
 
template<class S , class U >
Mutable< S > staticMutableCast (const Mutable< U > &)
 

Detailed Description

template<class T>
class mbgl::Mutable< T >

Mutable<T> is a non-nullable uniquely owning reference to a T. It can be efficiently converted to Immutable<T>.

The lifecycle of Mutable<T> and Immutable<T> is as follows:

  1. Create a Mutable<T> using makeMutable(...)
  2. Mutate it freely
  3. When you're ready to freeze its state and enable safe cross-thread sharing, move assign or move construct it to Immutable<T>

The reason that Mutable<T> exists, rather than simply using a std::unique_ptr<T>, is to take advantage of the underlying single-allocation optimization provided by std::make_shared.

Definition at line 22 of file immutable.hpp.

Constructor & Destructor Documentation

◆ Mutable() [1/2]

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

◆ Mutable() [2/2]

template<class T >
mbgl::Mutable< T >::Mutable ( const Mutable< T > &  )
delete

Member Function Documentation

◆ get()

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

Definition at line 30 of file immutable.hpp.

◆ operator*()

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

Definition at line 32 of file immutable.hpp.

◆ operator->()

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

Definition at line 31 of file immutable.hpp.

◆ operator=() [1/2]

template<class T >
Mutable& mbgl::Mutable< T >::operator= ( const Mutable< T > &  )
delete

◆ operator=() [2/2]

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

Friends And Related Function Documentation

◆ Immutable

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

Definition at line 40 of file immutable.hpp.

◆ makeMutable

template<class T >
template<class S , class... Args>
Mutable<S> makeMutable ( Args &&  ...)
friend

◆ staticMutableCast

template<class T >
template<class S , class U >
Mutable<S> staticMutableCast ( const Mutable< U > &  u)
friend

Definition at line 53 of file immutable.hpp.


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