5 #include <libcopp/utils/config/libcopp_build_features.h>
14 #include <system_error>
15 #include <type_traits>
21 LIBCOPP_COPP_NAMESPACE_BEGIN
26 template <
typename T,
typename =
void>
31 T, typename std::enable_if<std::is_convertible<decltype(std::declval<T>() != nullptr), bool>::value>::type>
48 template <class T, class = typename std::enable_if<std::is_pointer<T>::value>::type>
68 using value_type =
typename std::conditional<std::is_copy_constructible<T>::value, T,
const T&>::type;
73 template <class U, class = typename std::enable_if<std::is_convertible<U, T>::value>::type>
76 template <class = typename std::enable_if<!std::is_same<std::nullptr_t, T>::value>::type>
79 template <class U, class = typename std::enable_if<std::is_convertible<U, T>::value>::type>
85 assert(
ptr_ !=
nullptr);
89 constexpr
operator T()
const {
return get(); }
91 constexpr
typename std::remove_pointer<value_type>::type
operator*()
const {
return *
get(); }
115 template <
class T,
class U>
117 -> decltype(lhs.get() == rhs.get()) {
118 return lhs.get() == rhs.get();
121 template <
class T,
class U>
123 -> decltype(lhs.get() != rhs.get()) {
124 return lhs.get() != rhs.get();
127 template <
class T,
class U>
129 -> decltype(lhs.get() < rhs.get()) {
130 return lhs.get() < rhs.get();
133 template <
class T,
class U>
135 -> decltype(lhs.get() <= rhs.get()) {
136 return lhs.get() <= rhs.get();
139 template <
class T,
class U>
141 -> decltype(lhs.get() > rhs.get()) {
142 return lhs.get() > rhs.get();
145 template <
class T,
class U>
147 -> decltype(lhs.get() >= rhs.get()) {
148 return lhs.get() >= rhs.get();
152 template <
class T,
class U>
185 template <class U, class = typename std::enable_if<std::is_convertible<U, T>::value>::type>
188 template <class = typename std::enable_if<!std::is_same<std::nullptr_t, T>::value>::type>
191 template <class U, class = typename std::enable_if<std::is_convertible<U, T>::value>::type>
194 template <class U, class = typename std::enable_if<std::is_convertible<U, T>::value>::type>
220 template <
class T,
class U>
234 #if (defined(__cpp_deduction_guides) && (__cpp_deduction_guides >= 201611L))
238 not_null(T) -> not_null<T>;
240 strict_not_null(T) -> strict_not_null<T>;
246 LIBCOPP_COPP_NAMESPACE_END
252 std::size_t
operator()(
const LIBCOPP_COPP_NAMESPACE_ID::gsl::not_null<T>& value)
const {
253 return hash<T>{}(value.get());
258 ostream&
operator<<(ostream& os,
const LIBCOPP_COPP_NAMESPACE_ID::gsl::not_null<T>& val) {
265 std::size_t
operator()(
const LIBCOPP_COPP_NAMESPACE_ID::gsl::strict_not_null<T>& value)
const {
266 return hash<T>{}(value.get());
void operator[](std::ptrdiff_t) const =delete
constexpr value_type get() const
not_null & operator++()=delete
not_null(std::nullptr_t)=delete
constexpr not_null(U &&u)
typename std::conditional< std::is_copy_constructible< T >::value, T, const T & >::type value_type
not_null & operator--()=delete
not_null & operator=(const not_null &other)=default
constexpr not_null(const not_null< U > &other)
not_null & operator+=(std::ptrdiff_t)=delete
not_null(const not_null &other)=default
not_null & operator=(std::nullptr_t)=delete
not_null operator--(int)=delete
not_null operator++(int)=delete
not_null & operator-=(std::ptrdiff_t)=delete
constexpr std::remove_pointer< value_type >::type operator*() const
constexpr value_type operator->() const
strict_not_null & operator=(const not_null< T > &other)
strict_not_null & operator--()=delete
strict_not_null operator--(int)=delete
strict_not_null & operator+=(std::ptrdiff_t)=delete
strict_not_null(const strict_not_null &other)=default
strict_not_null operator++(int)=delete
strict_not_null(std::nullptr_t)=delete
constexpr strict_not_null(T u)
strict_not_null & operator=(std::nullptr_t)=delete
strict_not_null & operator-=(std::ptrdiff_t)=delete
strict_not_null & operator++()=delete
void operator[](std::ptrdiff_t) const =delete
constexpr strict_not_null(U &&u)
strict_not_null & operator=(const strict_not_null &other)=default
constexpr strict_not_null(const not_null< U > &other)
constexpr strict_not_null(const strict_not_null< U > &other)
strict_not_null(strict_not_null &&other)=default
auto operator<=(const not_null< T > &lhs, const not_null< U > &rhs) noexcept(noexcept(lhs.get()<=rhs.get())) -> decltype(lhs.get()<=rhs.get())
auto make_strict_not_null(T &&t) noexcept
auto make_not_null(T &&t) noexcept
auto operator==(const not_null< T > &lhs, const not_null< U > &rhs) noexcept(noexcept(lhs.get()==rhs.get())) -> decltype(lhs.get()==rhs.get())
auto operator<(const not_null< T > &lhs, const not_null< U > &rhs) noexcept(noexcept(lhs.get()< rhs.get())) -> decltype(lhs.get()< rhs.get())
auto operator!=(const not_null< T > &lhs, const not_null< U > &rhs) noexcept(noexcept(lhs.get() !=rhs.get())) -> decltype(lhs.get() !=rhs.get())
auto operator>=(const not_null< T > &lhs, const not_null< U > &rhs) noexcept(noexcept(lhs.get() >=rhs.get())) -> decltype(lhs.get() >=rhs.get())
std::ptrdiff_t operator-(const not_null< T > &, const not_null< U > &)=delete
not_null< T > operator+(const not_null< T > &, std::ptrdiff_t)=delete
auto operator>(const not_null< T > &lhs, const not_null< U > &rhs) noexcept(noexcept(lhs.get() > rhs.get())) -> decltype(lhs.get() > rhs.get())
ostream & operator<<(ostream &os, const LIBCOPP_COPP_NAMESPACE_ID::gsl::not_null< T > &val)
std::size_t operator()(const LIBCOPP_COPP_NAMESPACE_ID::gsl::not_null< T > &value) const
std::size_t operator()(const LIBCOPP_COPP_NAMESPACE_ID::gsl::strict_not_null< T > &value) const