// // const_propogating_ptr.hpp // pointers // // Created by Sam Jaffe on 12/3/16. // #pragma once #include #include "pointer_fwd.hpp" #include "ptr_compare.hpp" template class const_propogating_ptr { public: using element_type = typename std::pointer_traits

::element_type; using pointer = element_type *; using reference = element_type &; using const_pointer = element_type const *; using const_reference = element_type const &; const_propogating_ptr() noexcept : _ptr(nullptr) {} const_propogating_ptr(P const & p) noexcept(std::is_nothrow_copy_constructible

::value) : _ptr(p) {} const_propogating_ptr(P && p) noexcept(std::is_nothrow_move_constructible

::value) : _ptr(std::move(p)) {} const_propogating_ptr(const_propogating_ptr &) noexcept(std::is_nothrow_copy_constructible

::value) = default; const_propogating_ptr(const_propogating_ptr &&) noexcept(std::is_nothrow_move_constructible

::value) = default; const_propogating_ptr(const_propogating_ptr const &) = delete; const_propogating_ptr& operator=(const_propogating_ptr &) noexcept(std::is_nothrow_copy_constructible

::value) = default; const_propogating_ptr& operator=(const_propogating_ptr &&) noexcept(std::is_nothrow_move_constructible

::value) = default; const_propogating_ptr& operator=(const_propogating_ptr const &) = delete; template explicit operator const_propogating_ptr() & noexcept(std::is_nothrow_copy_constructible::value) { return _ptr; } template explicit operator const_ptr() const noexcept(std::is_nothrow_copy_constructible::value) { return _ptr; } template explicit operator const_propogating_ptr() const & = delete; operator bool() const noexcept { return static_cast(_ptr); } reference operator*() noexcept { return *_ptr; } pointer get() noexcept { return std::addressof(operator*()); } pointer operator->() noexcept { return get(); } const_reference operator*() const noexcept { return *_ptr; } const_pointer get() const noexcept { return std::addressof(operator*()); } const_pointer operator->() const noexcept { return get(); } private: P _ptr; }; POINTER_TEMPLATE_COMPARE( const_propogating_ptr )