31template <
typename View,
typename Value>
34 using view_type = View;
35 using value_type = Value;
40 static_assert(std::is_constructible<View, Value>::value,
41 "View type must be constructible from a Value");
46 static_assert(std::is_default_constructible<View>::value,
47 "View type must be default constructible");
81 : _value(other._value), _view(_value ? *_value : other._view) {}
87 _value = other._value;
88 _view = _value ? *_value : other._view;
98 : _value{std::move(other._value)}, _view(_value ? *_value : std::move(other._view)) {
100 other._value = stdx::nullopt;
108 _value = std::move(other._value);
109 _view = _value ? *_value : std::move(other._view);
110 other._view = View();
111 other._value = stdx::nullopt;
121 return static_cast<bool>(_value);
129 operator View()
const {
153template <
typename View,
typename Value>
159template <
typename View,
typename Value>
161 return !(lhs == rhs);
173template <
typename View,
typename Value>
175 return lhs.
view() == rhs;
179template <
typename View,
typename Value>
185template <
typename View,
typename Value>
187 return !(lhs == rhs);
191template <
typename View,
typename Value>
193 return !(rhs == lhs);
197template <
typename View,
typename Value>
199 return lhs.
view() == View(rhs);
203template <
typename View,
typename Value>
209template <
typename View,
typename Value>
211 return !(lhs == rhs);
215template <
typename View,
typename Value>
217 return !(rhs == lhs);
228using ::bsoncxx::v_noabi::operator==;
229using ::bsoncxx::v_noabi::operator!=;
240#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
245template <
typename View,
typename Value>
250template <
typename View,
typename Value>
255template <
typename View,
typename Value>
259template <
typename View,
typename Value>
263template <
typename View,
typename Value>
267template <
typename View,
typename Value>
271template <
typename View,
typename Value>
275template <
typename View,
typename Value>
279template <
typename View,
typename Value>
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A polyfill for std::optional<T>.
Definition optional.hpp:874
Class representing a view-or-value variant type.
Definition view_or_value.hpp:32
bool operator!=(const Value &lhs, const view_or_value< View, Value > &rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:216
bool operator!=(View lhs, const view_or_value< View, Value > &rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:192
view_or_value(View view)
Construct a view_or_value from a View. When constructed with a View, this object is non-owning....
Definition view_or_value.hpp:67
view_or_value()=default
Default-constructs a view_or_value. This is equivalent to constructing a view_or_value with a default...
view_or_value(const view_or_value &other)
Construct a view_or_value from a copied view_or_value.
Definition view_or_value.hpp:80
bool operator!=(const view_or_value< View, Value > &lhs, const view_or_value< View, Value > &rhs)
Compare view_or_value objects for (in)equality.
Definition view_or_value.hpp:160
bool is_owning() const noexcept
Return whether or not this view_or_value owns an underlying Value.
Definition view_or_value.hpp:120
view_or_value(Value &&value)
Constructs a view_or_value from a Value type. This object owns the passed-in Value.
Definition view_or_value.hpp:75
view_or_value & operator=(view_or_value &&other) noexcept
Assign to this view_or_value from a moved-in view_or_value.
Definition view_or_value.hpp:107
bool operator!=(const view_or_value< View, Value > &lhs, const Value &rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:210
bool operator==(const view_or_value< View, Value > &lhs, View rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:174
bool operator!=(const view_or_value< View, Value > &lhs, View rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:186
bool operator==(const view_or_value< View, Value > &lhs, const Value &rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:198
bool operator==(View lhs, const view_or_value< View, Value > &rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:180
view_or_value(view_or_value &&other) noexcept
Construct a view_or_value from a moved-in view_or_value.
Definition view_or_value.hpp:97
const View & view() const
Get a View for the type.
Definition view_or_value.hpp:138
~view_or_value()=default
Class View must be constructible from an instance of class Value.
bool operator==(const Value &lhs, const view_or_value< View, Value > &rhs)
Mixed (in)equality operators for view_or_value against View and Value types.
Definition view_or_value.hpp:204
view_or_value & operator=(const view_or_value &other)
Assign to this view_or_value from a copied view_or_value.
Definition view_or_value.hpp:86
bool operator==(const view_or_value< View, Value > &lhs, const view_or_value< View, Value > &rhs)
Compare view_or_value objects for (in)equality.
Definition view_or_value.hpp:154
The top-level namespace within which all bsoncxx library entities are declared.
bool operator==(const v_noabi::view_or_value< View, Value > &lhs, const v_noabi::view_or_value< View, Value > &rhs)
bsoncxx::v_noabi::operator==(const v_noabi::view_or_value<View, Value>& lhs, const v_noabi::view_or_v...
bool operator!=(const v_noabi::view_or_value< View, Value > &lhs, const v_noabi::view_or_value< View, Value > &rhs)
bsoncxx::v_noabi::operator!=(const v_noabi::view_or_value<View, Value>& lhs, const v_noabi::view_or_v...
The top-level namespace reserved for the C++ standard library.
Provides std::optional-related polyfills for library API usage.
Declares bsoncxx::v_noabi::view_or_value.