template <typename T>
class optional_ref
Defined at line 78 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
Public Methods
void optional_ref<T> ()
Defined at line 86 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
void optional_ref<T> (std::nullopt_t )
Defined at line 87 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
void optional_ref<T> (T & input)
Constructor given a concrete value.
Defined at line 92 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
template <typename U, typename = EnableIfConvertibleFrom<const U>>
void optional_ref<T> (const std::optional<U> & input)
Constructors given an existing std::optional value.
Templated on the input optional's type to avoid creating a temporary.
Defined at line 99 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
template <typename U, typename = EnableIfConvertibleFrom<U>>
void optional_ref<T> (std::optional<U> & input)
Defined at line 103 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
void optional_ref<T> (T * input)
Constructor given a T*, where nullptr indicates empty/absent.
Defined at line 108 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
void optional_ref<T> (std::nullptr_t )
Don't allow naked nullptr as input, as this creates confusion in the case
of optional_ref
<T
*>. Use std::nullopt instead to create an empty
optional_ref.
Defined at line 115 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
void optional_ref<T> (const optional_ref<T> & )
Copying is allowed.
Defined at line 119 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
optional_ref<T> & operator= (const optional_ref<T> & )
Assignment is not allowed.
Defined at line 121 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
template <typename U, typename = EnableIfConvertibleFrom<U>>
void optional_ref<T> (optional_ref<U> input)
Conversion from optional_ref
<U
> is allowed iff U* is convertible to T*.
(Note this also allows non-const to const conversions.)
Defined at line 126 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
bool has_value ()
Determines whether the `optional_ref` contains a value. Returns `false` if
and only if `*this` is empty.
Defined at line 132 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
T & value ()
Returns a reference to an `optional_ref`s underlying value. The constness
and lvalue/rvalue-ness of the `optional_ref` is preserved to the view of
the `T` sub-object. Throws the same error as `std::optional`'s `value()`
when the `optional_ref` is empty.
Defined at line 138 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
template <typename U>
T value_or (U && default_value)
Returns the value iff *this has a value, otherwise returns `default_value`.
Defined at line 151 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
T & operator* ()
Accesses the underlying `T` value of an `optional_ref`. If the
`optional_ref` is empty, behavior is undefined.
Defined at line 165 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
T * operator-> ()
Defined at line 169 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
T * as_pointer ()
Convenience function to represent the `optional_ref` as a `T*` pointer.
Defined at line 175 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h
template <typename U = std::decay_t<T>>
std::optional<U> as_optional ()
Convenience function to represent the `optional_ref` as an `optional`,
which incurs a copy when the `optional_ref` is non-empty. The template type
allows for implicit type conversion; example:
optional_ref
<std
::string> a = ...;
std::optional
<std
::string_view> b = a.as_optional
<std
::string_view>();
Defined at line 182 of file ../../third_party/abseil-cpp/src/absl/types/optional_ref.h