Utils: add has_value to optional

Change-Id: I73af682c98d3fd9e97c169ffb3930950e2b0addb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2018-05-16 10:23:49 +02:00
parent a0c02b50da
commit d79c0ed575

View File

@@ -498,6 +498,7 @@ public:
// 20.5.4.5, Observers
explicit constexpr operator bool() const noexcept { return initialized(); }
constexpr bool has_value() const noexcept { return initialized(); }
constexpr T const* operator ->() const {
return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), dataptr());
@@ -693,7 +694,8 @@ public:
explicit constexpr operator bool() const noexcept {
return ref != nullptr;
}
constexpr bool has_value() const noexcept { return ref != nullptr; }
template <class V>
constexpr typename decay<T>::type value_or(V&& v) const
{