userver: utils::NotNull< T > Class Template Reference
Loading...
Searching...
No Matches
utils::NotNull< T > Class Template Reference

#include <userver/utils/not_null.hpp>

Detailed Description

template<typename T>
class utils::NotNull< T >

Restricts a pointer or smart pointer to only hold non-null values.

Definition at line 21 of file not_null.hpp.

Public Member Functions

constexpr NotNull (const T &u)
 
constexpr NotNull (T &&u)
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr NotNull (U &&u)
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T>>>
constexpr NotNull (U &u)
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr NotNull (const NotNull< U > &other)
 
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr NotNull (NotNull< U > &&other)
 
constexpr NotNull (std::nullptr_t)=delete
 
 NotNull (const NotNull &other) noexcept=default
 
 NotNull (NotNull &&other) noexcept=default
 
NotNulloperator= (const NotNull &other) noexcept=default
 
NotNulloperator= (NotNull &&other) noexcept=default
 
constexpr NotNulloperator= (std::nullptr_t)=delete
 
constexpr const T & GetBase () const &
 
constexpr T && GetBase () &&
 
constexpr operator const T & () const &
 
constexpr operator bool ()=delete
 
constexpr decltype(autooperator-> () const &
 
constexpr decltype(autooperator* () const &
 
template<typename U >
constexpr bool operator== (const NotNull< U > &other) const &
 
template<typename U >
constexpr bool operator!= (const NotNull< U > &other) const &
 

Constructor & Destructor Documentation

◆ NotNull() [1/6]

template<typename T >
constexpr utils::NotNull< T >::NotNull ( const T & u)
inlineexplicitconstexpr

Definition at line 29 of file not_null.hpp.

◆ NotNull() [2/6]

template<typename T >
constexpr utils::NotNull< T >::NotNull ( T && u)
inlineexplicitconstexpr

Definition at line 33 of file not_null.hpp.

◆ NotNull() [3/6]

template<typename T >
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr utils::NotNull< T >::NotNull ( U && u)
inlineexplicitconstexpr

Definition at line 39 of file not_null.hpp.

◆ NotNull() [4/6]

template<typename T >
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U*, T>>>
constexpr utils::NotNull< T >::NotNull ( U & u)
inlineconstexpr

Definition at line 45 of file not_null.hpp.

◆ NotNull() [5/6]

template<typename T >
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr utils::NotNull< T >::NotNull ( const NotNull< U > & other)
inlineconstexpr

Definition at line 49 of file not_null.hpp.

◆ NotNull() [6/6]

template<typename T >
template<typename U , typename = std::enable_if_t<std::is_convertible_v<U, T>>>
constexpr utils::NotNull< T >::NotNull ( NotNull< U > && other)
inlineconstexpr

Definition at line 56 of file not_null.hpp.

Member Function Documentation

◆ GetBase() [1/2]

template<typename T >
constexpr T && utils::NotNull< T >::GetBase ( ) &&
inlineconstexpr

Definition at line 76 of file not_null.hpp.

◆ GetBase() [2/2]

template<typename T >
constexpr const T & utils::NotNull< T >::GetBase ( ) const &
inlineconstexpr

Definition at line 71 of file not_null.hpp.

◆ operator const T &()

template<typename T >
constexpr utils::NotNull< T >::operator const T & ( ) const &
inlineconstexpr

Definition at line 81 of file not_null.hpp.

◆ operator!=()

template<typename T >
template<typename U >
constexpr bool utils::NotNull< T >::operator!= ( const NotNull< U > & other) const &
inlineconstexpr

Definition at line 95 of file not_null.hpp.

◆ operator*()

template<typename T >
constexpr decltype(auto) utils::NotNull< T >::operator* ( ) const &
inlineconstexpr

Definition at line 87 of file not_null.hpp.

◆ operator->()

template<typename T >
constexpr decltype(auto) utils::NotNull< T >::operator-> ( ) const &
inlineconstexpr

Definition at line 85 of file not_null.hpp.

◆ operator==()

template<typename T >
template<typename U >
constexpr bool utils::NotNull< T >::operator== ( const NotNull< U > & other) const &
inlineconstexpr

Definition at line 90 of file not_null.hpp.


The documentation for this class was generated from the following file: