diff --git a/include/gsl/pointers b/include/gsl/pointers index 9c65a96..0759c53 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -215,14 +215,28 @@ not_null operator+(const not_null&, std::ptrdiff_t) = delete; template not_null operator+(std::ptrdiff_t, const not_null&) = delete; + +template ().get()), bool = std::is_default_constructible>::value> +struct not_null_hash +{ + std::size_t operator()(const T& value) const { return std::hash{}(value.get()); } +}; + +template +struct not_null_hash +{ + not_null_hash() = delete; + not_null_hash(const not_null_hash&) = delete; + not_null_hash& operator=(const not_null_hash&) = delete; +}; + } // namespace gsl namespace std { template -struct hash> +struct hash> : gsl::not_null_hash> { - std::size_t operator()(const gsl::not_null& value) const { return hash{}(value.get()); } }; } // namespace std @@ -323,12 +337,8 @@ strict_not_null(T) -> strict_not_null; namespace std { template -struct hash> +struct hash> : gsl::not_null_hash> { - std::size_t operator()(const gsl::strict_not_null& value) const - { - return hash{}(value.get()); - } }; } // namespace std