Gromacs
2025-dev-20241003-bd59e46
|
#include <gromacs/compat/pointers.h>
Restricts a pointer or smart pointer to only hold non-null values.
Has zero size overhead over T.
If T is a pointer (i.e. T == U*) then
Public Member Functions | |
template<typename U , typename = std::enable_if_t<std::is_convertible<U, T>::value>> | |
constexpr | not_null (U &&u) |
Move constructor. Asserts in debug mode if is nullptr. | |
template<typename = std::enable_if_t<!std::is_same<std::nullptr_t, T>::value>> | |
constexpr | not_null (T u) |
Simple constructor. Asserts in debug mode if u is nullptr. | |
template<typename U , typename = std::enable_if_t<std::is_convertible<U, T>::value>> | |
constexpr | not_null (const not_null< U > &other) |
Copy constructor. | |
not_null (not_null &&other) noexcept=default | |
Default constructors and assignment. | |
not_null (const not_null &other)=default | |
not_null & | operator= (const not_null &other)=default |
constexpr T | get () const |
Getters. | |
constexpr | operator T () const |
constexpr T | operator-> () const |
not_null (std::nullptr_t)=delete | |
Deleted to prevent compilation when someone attempts to assign a null pointer constant. | |
not_null & | operator= (std::nullptr_t)=delete |
not_null & | operator++ ()=delete |
Deleted unwanted operators because pointers only point to single objects. | |
not_null & | operator-- ()=delete |
not_null | operator++ (int)=delete |
not_null | operator-- (int)=delete |
not_null & | operator+= (std::ptrdiff_t)=delete |
not_null & | operator-= (std::ptrdiff_t)=delete |
void | operator[] (std::ptrdiff_t) const =delete |