PropagateConst< Wrapped > Class Template Reference

Wrapper for a pointer to propagate const to the pointed to value. More...

#include <ArmarXCore/core/util/PropagateConst.h>

Public Types

using ElementType
 

Public Member Functions

ElementTypeget ()
 
const ElementTypeget () const
 
constexpr operator bool () const
 
template<class T = Wrapped, typename std::enable_if< std::is_pointer< T >::value||std::is_convertible< T, const ElementType * >::value, bool >::type = true>
constexpr operator const ElementType * () const
 
template<class T = Wrapped, typename std::enable_if< std::is_pointer< T >::value||std::is_convertible< T, const ElementType * >::value, bool >::type = true>
constexpr operator ElementType * ()
 
ElementTypeoperator* ()
 
const ElementTypeoperator* () const
 
ElementTypeoperator-> ()
 
const ElementTypeoperator-> () const
 
PropagateConstoperator= (PropagateConst &&)=default
 
template<class T, typename std::enable_if< std::is_convertible< T &&, Wrapped >::value, bool >::type = true>
constexpr PropagateConstoperator= (PropagateConst< T > &&p)
 
template<class T, typename std::enable_if< std::is_convertible< T &&, Wrapped >::value &&!meta::TypeTemplateTraits::IsInstanceOf< PropagateConst, typename std::decay< T >::type >::value, bool >::type = true>
constexpr PropagateConstoperator= (T &&p)
 
constexpr PropagateConst ()=default
 
constexpr PropagateConst (PropagateConst &&)=default
 
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&std::is_convertible< T &&, Wrapped >::value, bool >::type = true>
constexpr PropagateConst (PropagateConst< T > &&p)
 
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&!std::is_convertible< T &&, Wrapped >::value, bool >::type = true>
constexpr PropagateConst (PropagateConst< T > &&p)
 
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&std::is_convertible< T &&, Wrapped >::value &&!meta::TypeTemplateTraits::IsInstanceOf< PropagateConst, typename std::decay< T >::type >::value, bool >::type = true>
constexpr PropagateConst (T &&p)
 
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&!std::is_convertible< T &&, Wrapped >::value &&!meta::TypeTemplateTraits::IsInstanceOf< PropagateConst, typename std::decay< T >::type >::value, bool >::type = true>
constexpr PropagateConst (T &&p)
 
constexpr PropagateConst (Wrapped &p)
 
constexpr void swap (PropagateConst &pt) noexcept(noexcept(std::swap(std::declval< Wrapped & >(), std::declval< Wrapped & >())))
 

Friends

template<class wrapped>
constexpr const wrapped & GetUnderlying (const PropagateConst< wrapped > &pt) noexcept
 
template<class wrapped>
constexpr wrapped & GetUnderlying (PropagateConst< wrapped > &pt) noexcept
 

Detailed Description

template<class Wrapped>
class armarx::PropagateConst< Wrapped >

Wrapper for a pointer to propagate const to the pointed to value.

\url{http://en.cppreference.com/w/cpp/experimental/propagate_const} Only difference: the armarx coding style is used (CamelCase instead of snake case) and some constexpr were deleted to work with gcc4.8

struct T
{
void f() {std::cout<<"non const\n";}
void f() const {std::cout<<" const\n";}
};
T inst;
struct Test
{
T * nc{&inst};
const T * c{&inst};
armarx::PropagateConst<T *> pc{&inst};
};
int main()
{
Test t;
t.nc->f(); // non const
t. c->f(); // const
t.pc->f(); // non const
const Test tc;
tc.nc->f();// non const
tc. c->f();// const
tc.pc->f();// const
}
constexpr T c

Definition at line 69 of file PropagateConst.h.

Member Typedef Documentation

◆ ElementType

template<class Wrapped>
using ElementType
Initial value:
typename std::remove_reference<decltype(*std::declval<Wrapped&>())>::type

Definition at line 88 of file PropagateConst.h.

Constructor & Destructor Documentation

◆ PropagateConst() [1/7]

template<class Wrapped>
PropagateConst ( )
constexprdefault

◆ PropagateConst() [2/7]

template<class Wrapped>
PropagateConst ( PropagateConst< Wrapped > && )
constexprdefault

◆ PropagateConst() [3/7]

template<class Wrapped>
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&std::is_convertible< T &&, Wrapped >::value, bool >::type = true>
PropagateConst ( PropagateConst< T > && p)
inlineconstexpr

Definition at line 105 of file PropagateConst.h.

◆ PropagateConst() [4/7]

template<class Wrapped>
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&!std::is_convertible< T &&, Wrapped >::value, bool >::type = true>
PropagateConst ( PropagateConst< T > && p)
inlineexplicitconstexpr

Definition at line 113 of file PropagateConst.h.

◆ PropagateConst() [5/7]

template<class Wrapped>
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&std::is_convertible< T &&, Wrapped >::value &&!meta::TypeTemplateTraits::IsInstanceOf< PropagateConst, typename std::decay< T >::type >::value, bool >::type = true>
PropagateConst ( T && p)
inlineconstexpr

Definition at line 131 of file PropagateConst.h.

◆ PropagateConst() [6/7]

template<class Wrapped>
template<class T, typename std::enable_if< std::is_constructible< Wrapped, T && >::value &&!std::is_convertible< T &&, Wrapped >::value &&!meta::TypeTemplateTraits::IsInstanceOf< PropagateConst, typename std::decay< T >::type >::value, bool >::type = true>
PropagateConst ( T && p)
inlineexplicitconstexpr

Definition at line 142 of file PropagateConst.h.

◆ PropagateConst() [7/7]

template<class Wrapped>
PropagateConst ( Wrapped & p)
inlineconstexpr

Definition at line 146 of file PropagateConst.h.

Member Function Documentation

◆ get() [1/2]

template<class Wrapped>
ElementType * get ( )
inline

Definition at line 196 of file PropagateConst.h.

◆ get() [2/2]

template<class Wrapped>
const ElementType * get ( ) const
inline

Definition at line 190 of file PropagateConst.h.

+ Here is the caller graph for this function:

◆ operator bool()

template<class Wrapped>
operator bool ( ) const
inlineexplicitconstexpr

Definition at line 233 of file PropagateConst.h.

◆ operator const ElementType *()

template<class Wrapped>
template<class T = Wrapped, typename std::enable_if< std::is_pointer< T >::value||std::is_convertible< T, const ElementType * >::value, bool >::type = true>
operator const ElementType * ( ) const
inlineconstexpr

Definition at line 273 of file PropagateConst.h.

◆ operator ElementType *()

template<class Wrapped>
template<class T = Wrapped, typename std::enable_if< std::is_pointer< T >::value||std::is_convertible< T, const ElementType * >::value, bool >::type = true>
operator ElementType * ( )
inlineconstexpr

Definition at line 283 of file PropagateConst.h.

◆ operator*() [1/2]

template<class Wrapped>
ElementType & operator* ( )
inline

Definition at line 247 of file PropagateConst.h.

◆ operator*() [2/2]

template<class Wrapped>
const ElementType & operator* ( ) const
inline

Definition at line 241 of file PropagateConst.h.

◆ operator->() [1/2]

template<class Wrapped>
ElementType * operator-> ( )
inline

Definition at line 261 of file PropagateConst.h.

◆ operator->() [2/2]

template<class Wrapped>
const ElementType * operator-> ( ) const
inline

Definition at line 255 of file PropagateConst.h.

◆ operator=() [1/3]

template<class Wrapped>
PropagateConst & operator= ( PropagateConst< Wrapped > && )
default

◆ operator=() [2/3]

template<class Wrapped>
template<class T, typename std::enable_if< std::is_convertible< T &&, Wrapped >::value, bool >::type = true>
PropagateConst & operator= ( PropagateConst< T > && p)
inlineconstexpr

Definition at line 158 of file PropagateConst.h.

◆ operator=() [3/3]

template<class Wrapped>
template<class T, typename std::enable_if< std::is_convertible< T &&, Wrapped >::value &&!meta::TypeTemplateTraits::IsInstanceOf< PropagateConst, typename std::decay< T >::type >::value, bool >::type = true>
PropagateConst & operator= ( T && p)
inlineconstexpr

Definition at line 171 of file PropagateConst.h.

◆ swap()

template<class Wrapped>
void swap ( PropagateConst< Wrapped > & pt)
inlineconstexprnoexcept

Definition at line 179 of file PropagateConst.h.

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ GetUnderlying [1/2]

template<class Wrapped>
template<class wrapped>
const wrapped & GetUnderlying ( const PropagateConst< wrapped > & pt)
friend

◆ GetUnderlying [2/2]

template<class Wrapped>
template<class wrapped>
wrapped & GetUnderlying ( PropagateConst< wrapped > & pt)
friend

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