|
@@ -9,19 +9,20 @@
|
|
|
#include <memory>
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "pointer_fwd.hpp"
|
|
#include "pointer_fwd.hpp"
|
|
|
|
|
+#include "ptr_compare.hpp"
|
|
|
|
|
|
|
|
-template <typename T>
|
|
|
|
|
|
|
+template <typename P>
|
|
|
class const_propogating_ptr {
|
|
class const_propogating_ptr {
|
|
|
public:
|
|
public:
|
|
|
- using element_type = typename std::pointer_traits<T>::element_type;
|
|
|
|
|
|
|
+ using element_type = typename std::pointer_traits<P>::element_type;
|
|
|
using pointer = element_type *;
|
|
using pointer = element_type *;
|
|
|
using reference = element_type &;
|
|
using reference = element_type &;
|
|
|
using const_pointer = element_type const *;
|
|
using const_pointer = element_type const *;
|
|
|
using const_reference = element_type const &;
|
|
using const_reference = element_type const &;
|
|
|
|
|
|
|
|
const_propogating_ptr() : _ptr(nullptr) {}
|
|
const_propogating_ptr() : _ptr(nullptr) {}
|
|
|
- const_propogating_ptr(T const & p) : _ptr(p) {}
|
|
|
|
|
- const_propogating_ptr(T && p) : _ptr(std::move(p)) {}
|
|
|
|
|
|
|
+ const_propogating_ptr(P const & p) : _ptr(p) {}
|
|
|
|
|
+ const_propogating_ptr(P && p) : _ptr(std::move(p)) {}
|
|
|
|
|
|
|
|
const_propogating_ptr(const_propogating_ptr & other) : _ptr(other._ptr) {}
|
|
const_propogating_ptr(const_propogating_ptr & other) : _ptr(other._ptr) {}
|
|
|
const_propogating_ptr(const_propogating_ptr &&) = default;
|
|
const_propogating_ptr(const_propogating_ptr &&) = default;
|
|
@@ -56,100 +57,7 @@ public:
|
|
|
const_pointer operator->() const { return get(); }
|
|
const_pointer operator->() const { return get(); }
|
|
|
|
|
|
|
|
private:
|
|
private:
|
|
|
- T _ptr;
|
|
|
|
|
|
|
+ P _ptr;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-template <typename T, typename U>
|
|
|
|
|
-bool operator==(const_propogating_ptr<T> const&lhs, const_propogating_ptr<U> const&rhs) {
|
|
|
|
|
- return lhs.get() == rhs.get();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T, typename U>
|
|
|
|
|
-bool operator!=(const_propogating_ptr<T> const&lhs, const_propogating_ptr<U> const&rhs) {
|
|
|
|
|
- return !(lhs == rhs);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T, typename U>
|
|
|
|
|
-bool operator< (const_propogating_ptr<T> const&lhs, const_propogating_ptr<U> const&rhs) {
|
|
|
|
|
- typedef typename std::common_type<
|
|
|
|
|
- typename const_propogating_ptr<T>::pointer,
|
|
|
|
|
- typename const_propogating_ptr<U>::pointer>::type V;
|
|
|
|
|
- return std::less<V>(lhs.get(), rhs.get());
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T, typename U>
|
|
|
|
|
-bool operator> (const_propogating_ptr<T> const&lhs, const_propogating_ptr<U> const&rhs) {
|
|
|
|
|
- return rhs < lhs;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T, typename U>
|
|
|
|
|
-bool operator<=(const_propogating_ptr<T> const&lhs, const_propogating_ptr<U> const&rhs) {
|
|
|
|
|
- return !(rhs < lhs);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T, typename U>
|
|
|
|
|
-bool operator>=(const_propogating_ptr<T> const&lhs, const_propogating_ptr<U> const&rhs) {
|
|
|
|
|
- return !(lhs < rhs);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator==(const_propogating_ptr<T> const&lhs, std::nullptr_t) {
|
|
|
|
|
- return !lhs;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator==(std::nullptr_t, const_propogating_ptr<T> const&rhs) {
|
|
|
|
|
- return !rhs;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator!=(const_propogating_ptr<T> const&lhs, std::nullptr_t) {
|
|
|
|
|
- return static_cast<bool>(lhs);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator!=(std::nullptr_t, const_propogating_ptr<T> const&rhs) {
|
|
|
|
|
- return static_cast<bool>(rhs);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator< (const_propogating_ptr<T> const&lhs, std::nullptr_t) {
|
|
|
|
|
- typedef typename const_propogating_ptr<T>::pointer V;
|
|
|
|
|
- return std::less<V>(lhs.get(), nullptr);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator< (std::nullptr_t, const_propogating_ptr<T> const&rhs) {
|
|
|
|
|
- typedef typename const_propogating_ptr<T>::pointer V;
|
|
|
|
|
- return std::less<V>(nullptr, rhs.get());
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator> (const_propogating_ptr<T> const&lhs, std::nullptr_t) {
|
|
|
|
|
- return nullptr < lhs;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator> (std::nullptr_t, const_propogating_ptr<T> const&rhs) {
|
|
|
|
|
- return rhs < nullptr;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator<=(const_propogating_ptr<T> const&lhs, std::nullptr_t) {
|
|
|
|
|
- return !(nullptr < lhs);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator<=(std::nullptr_t, const_propogating_ptr<T> const&rhs) {
|
|
|
|
|
- return !(rhs < nullptr);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator>=(const_propogating_ptr<T> const&lhs, std::nullptr_t) {
|
|
|
|
|
- return !(lhs < nullptr);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-bool operator>=(std::nullptr_t, const_propogating_ptr<T> const&rhs) {
|
|
|
|
|
- return !(nullptr < rhs);
|
|
|
|
|
-}
|
|
|
|
|
|
|
+POINTER_TEMPLATE_COMPARE( const_propogating_ptr )
|