Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/GSL.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Maples <jomaples@microsoft.com>2020-08-27 02:51:58 +0300
committerJordan Maples <jomaples@microsoft.com>2020-08-27 02:51:58 +0300
commit4a4bb3c13a6c782b9207bba9ece72b123ff76431 (patch)
treeb0ef0e8b884adc71b22d240fcb435bd91412fe8a /include
parentb6451c5db078e0c6445471e3d34c47404f3c6b5a (diff)
adding changes suggested by Jonathan Wakely
Diffstat (limited to 'include')
-rw-r--r--include/gsl/pointers7
1 files changed, 3 insertions, 4 deletions
diff --git a/include/gsl/pointers b/include/gsl/pointers
index 2418ec7..874583d 100644
--- a/include/gsl/pointers
+++ b/include/gsl/pointers
@@ -72,7 +72,7 @@ public:
}
template <typename = std::enable_if_t<!std::is_same<std::nullptr_t, T>::value>>
- constexpr not_null(T u) : ptr_(u)
+ constexpr not_null(T u) : ptr_(std::move(u))
{
Expects(ptr_ != nullptr);
}
@@ -84,15 +84,14 @@ public:
not_null(const not_null& other) = default;
not_null& operator=(const not_null& other) = default;
-
- constexpr T get() const
+ constexpr std::conditional_t<std::is_copy_constructible<T>::value, T, const T&> get() const
{
Ensures(ptr_ != nullptr);
return ptr_;
}
constexpr operator T() const { return get(); }
- constexpr T operator->() const { return get(); }
+ constexpr decltype(auto) operator->() const { return get(); }
constexpr decltype(auto) operator*() const { return *get(); }
// prevents compilation when someone attempts to assign a null pointer constant