std::experimental::propagate_const is a const-propagating wrapper for pointers and pointer-like objects. It treats the wrapped pointer as a pointer to const when accessed through a const access path, hence the name.

T must be an object pointer type or a pointer-like class type, as specified below. The program is ill-formed if T is an array type, reference type, pointer to function type, pointer to (possibly cv-qualified) void, or if decltype(*std::declval<T&>()) is not an lvalue reference type.

Requirements on pointer-like class types

If T is a class type, it must satisfy the requirements in this subsection.

The following expressions must be valid and have their specified effects:

Expression

Return type

Pre-conditions

Operational semantics

t.get()

element_type*

ct.get()

element_type* or const element_type*

t.get()== ct.get()

*t

element_type&

t.get()!= nullptr

*t refers to the same object as *(t.get())

*ct

element_type& or const element_type&

ct.get()!= nullptr

*ct refers to the same object as *(ct.get())

t.operator->()

element_type*

t.get()!= nullptr

t.operator->()== t.get()

ct.operator->()

element_type* or const element_type*

ct.get()!= nullptr

ct.operator->()== ct.get()

(bool)t

bool

(bool)t is equivalent to t.get()!= nullptr

(bool)ct

bool

(bool)ct is equivalent to ct.get()!= nullptr

Further, T and const T shall be contextually convertible to bool.

In addition, if T is implicitly convertible to element_type*, then (element_type*)t shall be equal to t.get(). Similarly, if const T is implicitly convertible to const element_type*, then (const element_type*)ct shall be equal to ct.get().