MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin::library::PropagateConst< T > Class Template Reference

A compiler-support agnostic implementation of std::propagate_const More...

#include <marvin_PropagateConst.h>

Public Member Functions

constexpr PropagateConst ()=default
 
constexpr PropagateConst (PropagateConst &&p)=default
 
template<class U>
requires std::is_constructible<T, U>::value && std::is_convertible<U, T>::value
constexpr PropagateConst (PropagateConst< U > &&pu)
 
template<class U>
requires std::is_constructible<T, U>::value && (!std::is_convertible<U, T>::value)
constexpr PropagateConst (PropagateConst< U > &&pu)
 
template<class U>
requires std::is_constructible<T, U>::value && (!is_specialisation<std::decay_t<U>>::value)
constexpr PropagateConst (U &&u)
 
template<class U>
requires std::is_constructible<T, U>::value && (!is_specialisation<std::decay_t<U>>::value) && (!std::is_convertible<U, T>::value)
constexpr PropagateConst (U &&u)
 
constexpr PropagateConstoperator= (PropagateConst &&)=default
 
template<class U>
requires std::is_convertible<U, T>::value
constexpr PropagateConstoperator= (PropagateConst< U > &&pu)
 
template<class U>
requires std::is_convertible<U, T>::value && (!is_specialisation<std::decay_t<U>>::value)
constexpr PropagateConstoperator= (U &&u)
 
PropagateConstoperator= (const PropagateConst &other)=delete
 
constexpr void swap (PropagateConst &pt) noexcept
 
constexpr element_type * get ()
 
constexpr const element_type * get () const
 
constexpr operator bool () const
 
constexpr element_type & operator* ()
 
constexpr const element_type & operator* () const
 
constexpr element_type * operator-> ()
 
constexpr const element_type * operator-> () const
 
constexpr operator element_type * ()
 
constexpr operator const element_type * ()
 

Friends

template<class U>
constexpr bool operator== (const PropagateConst< U > &, std::nullptr_t)
 
template<class U>
constexpr bool operator== (std::nullptr_t, const PropagateConst< U > &)
 
template<class U>
constexpr bool operator!= (const PropagateConst< U > &, std::nullptr_t)
 
template<class U>
constexpr bool operator!= (std::nullptr_t, const PropagateConst< U > &)
 
template<class U>
constexpr bool operator== (const PropagateConst< T > &pt, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator!= (const PropagateConst< T > &pt, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator< (const PropagateConst< T > &pt, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator> (const PropagateConst< T > &pt, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator<= (const PropagateConst< T > &pt, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator>= (const PropagateConst< T > &pt, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator== (const PropagateConst< T > &pt, const U &u)
 
template<class U>
constexpr bool operator!= (const PropagateConst< T > &pt, const U &u)
 
template<class U>
constexpr bool operator== (const T &t, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator!= (const T &t, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator< (const PropagateConst< T > &pt, const U &u)
 
template<class U>
constexpr bool operator> (const PropagateConst< T > &pt, const U &u)
 
template<class U>
constexpr bool operator<= (const PropagateConst< T > &pt, const U &u)
 
template<class U>
constexpr bool operator>= (const PropagateConst< T > &pt, const U &u)
 
template<class U>
constexpr bool operator< (const T &t, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator> (const T &t, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator<= (const T &t, const PropagateConst< U > &pu)
 
template<class U>
constexpr bool operator>= (const T &t, const PropagateConst< U > &pu)
 

Detailed Description

template<typename T>
requires SmartPointerType<T> || std::is_pointer_v<T>
class marvin::library::PropagateConst< T >

A compiler-support agnostic implementation of std::propagate_const

The raison d'etre being that certain popular compilers (cough Apple-Clang cough) are horrifically slow at implementing stdlib features, and std::propagate_const is pretty desirable for anything using a PImpl pattern.
For more information about what std::propagate_const actually does, see here: https://en.cppreference.com/w/cpp/experimental/propagate_const

Constructor & Destructor Documentation

◆ PropagateConst() [1/6]

template<typename T>
marvin::library::PropagateConst< T >::PropagateConst ( )
constexprdefault

Constructs a PropagateConst, default initialising the internal pointer variable.

◆ PropagateConst() [2/6]

template<typename T>
marvin::library::PropagateConst< T >::PropagateConst ( PropagateConst< T > && p)
constexprdefault

Explicitly defaulted move constructor that move constructs the internal pointer variable with p

Parameters
pAnother PropagateConst object to move from.

◆ PropagateConst() [3/6]

template<typename T>
template<class U>
requires std::is_constructible<T, U>::value && std::is_convertible<U, T>::value
marvin::library::PropagateConst< T >::PropagateConst ( PropagateConst< U > && pu)
inlineconstexpr

Initialises the internal pointer variable as if from the expression std::move(pu.t_). Implicit if std::is_convertible_v<U, T>

Parameters
puAnother PropagateConst object of a different specialization to move from.

◆ PropagateConst() [4/6]

template<typename T>
template<class U>
requires std::is_constructible<T, U>::value && (!std::is_convertible<U, T>::value)
marvin::library::PropagateConst< T >::PropagateConst ( PropagateConst< U > && pu)
inlineexplicitconstexpr

Initialises the internal pointer variable as if from the expression std::move(pu.t_). Explicit if !std::is_convertible_v<U, T>

Parameters
puAnother PropagateConst object of a different specialization to move from.

◆ PropagateConst() [5/6]

template<typename T>
template<class U>
requires std::is_constructible<T, U>::value && (!is_specialisation<std::decay_t<U>>::value)
marvin::library::PropagateConst< T >::PropagateConst ( U && u)
inlineconstexpr

Initialises the internal pointer variable with the expression std::forward<U>(u). Implicit if std::is_convertible_v<U, T>.

Parameters
uAnother object to initialise the internal pointer variable with.

◆ PropagateConst() [6/6]

template<typename T>
template<class U>
requires std::is_constructible<T, U>::value && (!is_specialisation<std::decay_t<U>>::value) && (!std::is_convertible<U, T>::value)
marvin::library::PropagateConst< T >::PropagateConst ( U && u)
inlineexplicitconstexpr

Initialises the internal pointer variable with the expression std::forward<U>(u). Explicit if !std::is_convertible_v<U, T>.

Parameters
uAnother object to initialise the internal pointer variable with.

Member Function Documentation

◆ get() [1/2]

template<typename T>
element_type * marvin::library::PropagateConst< T >::get ( )
inlineconstexpr

Returns a pointer to the object pointed to by the wrapped internal pointer-like variable.

Returns
If T is an object pointer type, then the internal pointer variable. Otherwise, a .get() call on the internal pointer variable.

◆ get() [2/2]

template<typename T>
const element_type * marvin::library::PropagateConst< T >::get ( ) const
inlineconstexpr

Returns a pointer to the object pointed to by the wrapped internal pointer-like variable.

Returns
If T is an object pointer type, then the internal pointer variable. Otherwise, a .get() call on the internal pointer variable.

◆ operator bool()

template<typename T>
marvin::library::PropagateConst< T >::operator bool ( ) const
inlineexplicitconstexpr

Checks whether the internal pointer variable is null.

Returns
true if the internal pointer variable is not null, otherwise false.

◆ operator const element_type *()

template<typename T>
marvin::library::PropagateConst< T >::operator const element_type * ( )
inlineconstexpr

Provides implicit conversion to const element_type*

Returns
A pointer to the object pointed to by the internal pointer variable.

◆ operator element_type *()

template<typename T>
marvin::library::PropagateConst< T >::operator element_type * ( )
inlineconstexpr

Provides implicit conversion to element_type*

Returns
A pointer to the object pointed to by the internal pointer variable.

◆ operator*() [1/2]

template<typename T>
element_type & marvin::library::PropagateConst< T >::operator* ( )
inlineconstexpr

Dereferences the internal pointer variable - undefined behaviour if its null!

Returns
The value stored at the internal pointer variable.

◆ operator*() [2/2]

template<typename T>
const element_type & marvin::library::PropagateConst< T >::operator* ( ) const
inlineconstexpr

Dereferences the internal pointer variable - undefined behaviour if its null!

Returns
The value stored at the internal pointer variable.

◆ operator->() [1/2]

template<typename T>
element_type * marvin::library::PropagateConst< T >::operator-> ( )
inlineconstexpr

Provides access into the internal pointer variable - undefined behaviour if its null!

Returns
A pointer to the object pointed to by the internal pointer variable.

◆ operator->() [2/2]

template<typename T>
const element_type * marvin::library::PropagateConst< T >::operator-> ( ) const
inlineconstexpr

Provides access into the internal pointer variable - undefined behaviour if its null!

Returns
A pointer to the object pointed to by the internal pointer variable.

◆ operator=() [1/4]

template<typename T>
PropagateConst & marvin::library::PropagateConst< T >::operator= ( const PropagateConst< T > & other)
delete

Deleted - non copyable.

◆ operator=() [2/4]

template<typename T>
PropagateConst & marvin::library::PropagateConst< T >::operator= ( PropagateConst< T > && )
constexprdefault

Explicitly defaulted move-assign that move-assigns the internal pointer variable from other's internal pointer variable.

◆ operator=() [3/4]

template<typename T>
template<class U>
requires std::is_convertible<U, T>::value
PropagateConst & marvin::library::PropagateConst< T >::operator= ( PropagateConst< U > && pu)
inlineconstexpr

Assigns a std::move of pu's internal pointer variable to this instance's internal pointer variable.

Parameters
puAnother PropagateConst object of a different specialization to move from.
Returns
*this.

◆ operator=() [4/4]

template<typename T>
template<class U>
requires std::is_convertible<U, T>::value && (!is_specialisation<std::decay_t<U>>::value)
PropagateConst & marvin::library::PropagateConst< T >::operator= ( U && u)
inlineconstexpr

Assigns a std::forward of u to the internal pointer variable.

Parameters
uAnother object to assign to the internal pointer variable.
Returns
*this.

◆ swap()

template<typename T>
void marvin::library::PropagateConst< T >::swap ( PropagateConst< T > & pt)
inlineconstexprnoexcept

Swaps the internal pointer variable with that of pt. UB if lvalues of T do not satisfy swappable.

Parameters
ptAnother PropagateConst object to swap with.

Friends And Related Symbol Documentation

◆ operator!= [1/5]

template<typename T>
template<class U>
bool operator!= ( const PropagateConst< T > & pt,
const PropagateConst< U > & pu )
friend

◆ operator!= [2/5]

template<typename T>
template<class U>
bool operator!= ( const PropagateConst< T > & pt,
const U & u )
friend

◆ operator!= [3/5]

template<typename T>
template<class U>
bool operator!= ( const PropagateConst< U > & ,
std::nullptr_t  )
friend

◆ operator!= [4/5]

template<typename T>
template<class U>
bool operator!= ( const T & t,
const PropagateConst< U > & pu )
friend

◆ operator!= [5/5]

template<typename T>
template<class U>
bool operator!= ( std::nullptr_t ,
const PropagateConst< U > &  )
friend

◆ operator< [1/3]

template<typename T>
template<class U>
bool operator< ( const PropagateConst< T > & pt,
const PropagateConst< U > & pu )
friend

◆ operator< [2/3]

template<typename T>
template<class U>
bool operator< ( const PropagateConst< T > & pt,
const U & u )
friend

◆ operator< [3/3]

template<typename T>
template<class U>
bool operator< ( const T & t,
const PropagateConst< U > & pu )
friend

◆ operator<= [1/3]

template<typename T>
template<class U>
bool operator<= ( const PropagateConst< T > & pt,
const PropagateConst< U > & pu )
friend

◆ operator<= [2/3]

template<typename T>
template<class U>
bool operator<= ( const PropagateConst< T > & pt,
const U & u )
friend

◆ operator<= [3/3]

template<typename T>
template<class U>
bool operator<= ( const T & t,
const PropagateConst< U > & pu )
friend

◆ operator== [1/5]

template<typename T>
template<class U>
bool operator== ( const PropagateConst< T > & pt,
const PropagateConst< U > & pu )
friend

◆ operator== [2/5]

template<typename T>
template<class U>
bool operator== ( const PropagateConst< T > & pt,
const U & u )
friend

◆ operator== [3/5]

template<typename T>
template<class U>
bool operator== ( const PropagateConst< U > & ,
std::nullptr_t  )
friend

◆ operator== [4/5]

template<typename T>
template<class U>
bool operator== ( const T & t,
const PropagateConst< U > & pu )
friend

◆ operator== [5/5]

template<typename T>
template<class U>
bool operator== ( std::nullptr_t ,
const PropagateConst< U > &  )
friend

◆ operator> [1/3]

template<typename T>
template<class U>
bool operator> ( const PropagateConst< T > & pt,
const PropagateConst< U > & pu )
friend

◆ operator> [2/3]

template<typename T>
template<class U>
bool operator> ( const PropagateConst< T > & pt,
const U & u )
friend

◆ operator> [3/3]

template<typename T>
template<class U>
bool operator> ( const T & t,
const PropagateConst< U > & pu )
friend

◆ operator>= [1/3]

template<typename T>
template<class U>
bool operator>= ( const PropagateConst< T > & pt,
const PropagateConst< U > & pu )
friend

◆ operator>= [2/3]

template<typename T>
template<class U>
bool operator>= ( const PropagateConst< T > & pt,
const U & u )
friend

◆ operator>= [3/3]

template<typename T>
template<class U>
bool operator>= ( const T & t,
const PropagateConst< U > & pu )
friend

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