#include <userver/utils/required.hpp>
A wrapper that holds a value of type T and has no default constructor, forcing explicit initialization.
Unlike std::optional, Required is always engaged after construction. It is useful for struct fields that must be explicitly set.
Definition at line 29 of file required.hpp.
Public Member Functions | |
| template<typename U = T> requires (!std::same_as<std::decay_t<U>, Required> && std::constructible_from<T, U &&>) | |
| constexpr | explicit (!std::convertible_to< U &&, T >) Required(U &&value) |
Construct T from a value (conditionally explicit). | |
| template<typename... Args> requires (sizeof...(Args) >= 2 && std::constructible_from<T, Args && ...>) | |
| constexpr | Required (Args &&... args) |
Emplace-construct T from args. | |
| Required (const Required &)=default | |
| Required & | operator= (const Required &)=default |
| Required (Required &&)=default | |
| Required & | operator= (Required &&)=default |
| constexpr T & | operator* () &noexcept USERVER_IMPL_LIFETIME_BOUND |
| Access the contained value. | |
| constexpr const T & | operator* () const &noexcept USERVER_IMPL_LIFETIME_BOUND |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| constexpr T && | operator* () &&noexcept |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| constexpr T * | operator-> () noexcept USERVER_IMPL_LIFETIME_BOUND |
| Access members of the contained value. | |
| constexpr const T * | operator-> () const noexcept USERVER_IMPL_LIFETIME_BOUND |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| constexpr | operator T& () &noexcept USERVER_IMPL_LIFETIME_BOUND |
Implicit conversion to T&. | |
| constexpr | operator const T & () const &noexcept USERVER_IMPL_LIFETIME_BOUND |
Implicit conversion to const T&. | |
| template<typename U> requires (!std::same_as<U, T> && !std::is_reference_v<U> && std::convertible_to<const T&, U>) | |
| constexpr | operator U () const |
Implicit conversion to any type that T is implicitly convertible to (by value). | |
|
inlineexplicitconstexpr |
Emplace-construct T from args.
Definition at line 43 of file required.hpp.
|
inlineconstexpr |
Construct T from a value (conditionally explicit).
Definition at line 36 of file required.hpp.
|
inlineconstexprnoexcept |
Implicit conversion to const T&.
Definition at line 71 of file required.hpp.
|
inlineconstexprnoexcept |
Implicit conversion to T&.
Definition at line 68 of file required.hpp.
|
inlineconstexpr |
Implicit conversion to any type that T is implicitly convertible to (by value).
Definition at line 76 of file required.hpp.
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 59 of file required.hpp.
|
inlineconstexprnoexcept |
Access the contained value.
Definition at line 53 of file required.hpp.
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 56 of file required.hpp.
|
inlineconstexprnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 65 of file required.hpp.
|
inlineconstexprnoexcept |
Access members of the contained value.
Definition at line 62 of file required.hpp.