1 #ifndef LIBFILEZILLA_OPTIONAL_HEADER
2 #define LIBFILEZILLA_OPTIONAL_HEADER
34 explicit operator bool()
const {
return v_ !=
nullptr; };
36 T& operator*() {
return *v_; }
37 T
const& operator*()
const {
return *v_; }
39 T* operator->() {
return v_; }
40 T
const* operator->()
const {
return v_; }
43 inline bool operator!=(
sparse_optional<T> const& cmp)
const {
return !(*
this == cmp); }
76 sparse_optional<T>::sparse_optional(sparse_optional<T> && v) noexcept
83 sparse_optional<T>::~sparse_optional()
89 void sparse_optional<T>::clear()
96 sparse_optional<T>& sparse_optional<T>::operator=(sparse_optional<T>
const& v)
101 value =
new T(*v.v_);
111 sparse_optional<T>& sparse_optional<T>::operator=(sparse_optional<T> && v) noexcept
123 bool sparse_optional<T>::operator==(sparse_optional<T>
const& cmp)
const
125 if (!v_ && !cmp.v_) {
129 if (!v_ || !cmp.v_) {
133 return *v_ == *cmp.v_;
137 bool sparse_optional<T>::operator<(sparse_optional<T>
const& cmp)
const
139 if (!v_ || !cmp.v_) {
140 return cmp.v_ !=
nullptr;
143 return *v_ < *cmp.v_;
Similar to C++17's std::optional, but stores the data in dynamic memory.
Definition: optional.hpp:20
The namespace used by libfilezilla.
Definition: apply.hpp:17