|
|
@@ -12,71 +12,78 @@
|
|
|
#include "detail/get_ptr.hpp"
|
|
|
#include "pointer_fwd.hpp"
|
|
|
|
|
|
-template <typename P>
|
|
|
-class const_propogating_ptr
|
|
|
- : private detail::get_ptr<P>,
|
|
|
- public detail::pointer_compare<const_propogating_ptr<P>> {
|
|
|
-public:
|
|
|
- using element_type = typename std::pointer_traits<P>::element_type;
|
|
|
- using pointer = element_type *;
|
|
|
- using reference = element_type &;
|
|
|
- using const_pointer = element_type const *;
|
|
|
- using const_reference = element_type const &;
|
|
|
+namespace pointers {
|
|
|
|
|
|
- const_propogating_ptr() noexcept : _ptr() {}
|
|
|
- const_propogating_ptr(P const & p) noexcept(
|
|
|
- std::is_nothrow_copy_constructible<P>::value)
|
|
|
- : _ptr(p) {}
|
|
|
- const_propogating_ptr(P && p) noexcept(
|
|
|
- std::is_nothrow_move_constructible<P>::value)
|
|
|
- : _ptr(std::move(p)) {}
|
|
|
- template <typename Y, typename = typename std::enable_if<
|
|
|
- std::is_constructible<P, Y>::value>::type>
|
|
|
- const_propogating_ptr(Y const & p) : _ptr(p) {}
|
|
|
- template <typename Y, typename = typename std::enable_if<
|
|
|
- std::is_constructible<P, Y>::value>::type>
|
|
|
- const_propogating_ptr(Y && p) : _ptr(std::forward<Y>(p)) {}
|
|
|
+ template <typename P>
|
|
|
+ class const_propogating_ptr
|
|
|
+ : private detail::get_ptr<P>,
|
|
|
+ public detail::pointer_compare<const_propogating_ptr<P>> {
|
|
|
+ public:
|
|
|
+ using element_type = typename std::pointer_traits<P>::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(const_propogating_ptr &) noexcept(
|
|
|
- std::is_nothrow_copy_constructible<P>::value) = default;
|
|
|
- const_propogating_ptr(const_propogating_ptr &&) noexcept(
|
|
|
- std::is_nothrow_move_constructible<P>::value) = default;
|
|
|
- const_propogating_ptr(const_propogating_ptr const &) = delete;
|
|
|
- const_propogating_ptr & operator=(const_propogating_ptr &) noexcept(
|
|
|
- std::is_nothrow_copy_assignable<P>::value) = default;
|
|
|
- const_propogating_ptr & operator=(const_propogating_ptr &&) noexcept(
|
|
|
- std::is_nothrow_move_assignable<P>::value) = default;
|
|
|
- const_propogating_ptr & operator=(const_propogating_ptr const &) = delete;
|
|
|
+ const_propogating_ptr() noexcept : _ptr() {}
|
|
|
+ const_propogating_ptr(P const & p) noexcept(
|
|
|
+ std::is_nothrow_copy_constructible<P>::value)
|
|
|
+ : _ptr(p) {}
|
|
|
+ const_propogating_ptr(P && p) noexcept(
|
|
|
+ std::is_nothrow_move_constructible<P>::value)
|
|
|
+ : _ptr(std::move(p)) {}
|
|
|
+ template <typename Y, typename = typename std::enable_if<
|
|
|
+ std::is_constructible<P, Y>::value>::type>
|
|
|
+ const_propogating_ptr(Y const & p) : _ptr(p) {}
|
|
|
+ template <typename Y, typename = typename std::enable_if<
|
|
|
+ std::is_constructible<P, Y>::value>::type>
|
|
|
+ const_propogating_ptr(Y && p) : _ptr(std::forward<Y>(p)) {}
|
|
|
|
|
|
- template <typename Y>
|
|
|
- explicit operator const_propogating_ptr<Y>() &
|
|
|
- noexcept(std::is_nothrow_constructible<P, Y>::value) {
|
|
|
- return _ptr;
|
|
|
- }
|
|
|
+ const_propogating_ptr(const_propogating_ptr &) noexcept(
|
|
|
+ std::is_nothrow_copy_constructible<P>::value) = default;
|
|
|
+ const_propogating_ptr(const_propogating_ptr &&) noexcept(
|
|
|
+ std::is_nothrow_move_constructible<P>::value) = default;
|
|
|
+ const_propogating_ptr(const_propogating_ptr const &) = delete;
|
|
|
+ const_propogating_ptr & operator=(const_propogating_ptr &) noexcept(
|
|
|
+ std::is_nothrow_copy_assignable<P>::value) = default;
|
|
|
+ const_propogating_ptr & operator=(const_propogating_ptr &&) noexcept(
|
|
|
+ std::is_nothrow_move_assignable<P>::value) = default;
|
|
|
+ const_propogating_ptr & operator=(const_propogating_ptr const &) = delete;
|
|
|
|
|
|
- template <typename Y>
|
|
|
- explicit operator const_ptr<Y>() const
|
|
|
- noexcept(std::is_nothrow_constructible<P, Y>::value) {
|
|
|
- return _ptr;
|
|
|
- }
|
|
|
+ template <typename Y>
|
|
|
+ explicit operator const_propogating_ptr<Y>() &
|
|
|
+ noexcept(std::is_nothrow_constructible<P, Y>::value) {
|
|
|
+ return _ptr;
|
|
|
+ }
|
|
|
|
|
|
- template <typename Y>
|
|
|
- explicit operator const_propogating_ptr<Y>() const & = delete;
|
|
|
+ template <typename Y>
|
|
|
+ explicit operator const_ptr<Y>() const
|
|
|
+ noexcept(std::is_nothrow_constructible<P, Y>::value) {
|
|
|
+ return _ptr;
|
|
|
+ }
|
|
|
|
|
|
- operator bool() const noexcept { return static_cast<bool>(_ptr); }
|
|
|
+ template <typename Y>
|
|
|
+ explicit operator const_propogating_ptr<Y>() const & = delete;
|
|
|
|
|
|
- reference operator*() noexcept(noexcept(*_ptr)) { return *_ptr; }
|
|
|
- pointer get() noexcept(noexcept(detail::get_ptr<P>::get(_ptr))) {
|
|
|
- return detail::get_ptr<P>::get(_ptr);
|
|
|
- }
|
|
|
- pointer operator->() noexcept(noexcept(get())) { return get(); }
|
|
|
+ operator bool() const noexcept { return static_cast<bool>(_ptr); }
|
|
|
|
|
|
- const_reference operator*() const noexcept(noexcept(*_ptr)) { return *_ptr; }
|
|
|
- const_pointer get() const noexcept(noexcept(detail::get_ptr<P>::get(_ptr))) {
|
|
|
- return detail::get_ptr<P>::get(_ptr);
|
|
|
- }
|
|
|
- const_pointer operator->() const noexcept(noexcept(get())) { return get(); }
|
|
|
+ reference operator*() noexcept(noexcept(*_ptr)) { return *_ptr; }
|
|
|
+ pointer get() noexcept(noexcept(detail::get_ptr<P>::get(_ptr))) {
|
|
|
+ return detail::get_ptr<P>::get(_ptr);
|
|
|
+ }
|
|
|
+ pointer operator->() noexcept(noexcept(get())) { return get(); }
|
|
|
|
|
|
-private:
|
|
|
- P _ptr;
|
|
|
-};
|
|
|
+ const_reference operator*() const noexcept(noexcept(*_ptr)) {
|
|
|
+ return *_ptr;
|
|
|
+ }
|
|
|
+ const_pointer get() const
|
|
|
+ noexcept(noexcept(detail::get_ptr<P>::get(_ptr))) {
|
|
|
+ return detail::get_ptr<P>::get(_ptr);
|
|
|
+ }
|
|
|
+ const_pointer operator->() const noexcept(noexcept(get())) { return get(); }
|
|
|
+
|
|
|
+ private:
|
|
|
+ P _ptr;
|
|
|
+ };
|
|
|
+
|
|
|
+}
|