introduce gsl::not_null<T>::element_type (#1196)

* introduce gsl::not_null<T>::element_type

* use std::is_same instead of is_same_v

* fix: cannot put a non-pointer in a gsl::not_null
This commit is contained in:
Carson Radtke
2025-02-12 09:16:05 -06:00
committed by GitHub
parent 7f4fc9388b
commit ec729d63a7
4 changed files with 23 additions and 0 deletions
+2
View File
@@ -98,6 +98,8 @@ class not_null
public:
static_assert(details::is_comparable_to_nullptr<T>::value, "T cannot be compared to nullptr.");
using element_type = T;
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
constexpr not_null(U&& u) noexcept(std::is_nothrow_move_constructible<T>::value) : ptr_(std::forward<U>(u))
{