135 explicit operator bool()
const;
140 const T&
value()
const &;
142 const T&&
value()
const &&;
143 T
value_or(
const T& default_value)
const;
200 *m_dataPtr = std::move(
value);
207 if (m_dataPtr !=
nullptr){
251 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
260 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
268 if (m_dataPtr !=
nullptr){
284 if (m_dataPtr !=
nullptr){
311 if (m_dataPtr !=
nullptr){
328 if (m_dataPtr !=
nullptr){
333 *m_dataPtr = std::move(value);
345 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
354 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
363 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
372 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
381 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
383 return std::move(*m_dataPtr);
390 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
392 return std::move(*m_dataPtr);
410 if (m_dataPtr !=
nullptr){
414 if (other.m_dataPtr !=
nullptr){
416 *m_dataPtr = *other.m_dataPtr;
419 m_hasValue = other.m_hasValue;
420 m_isNull = other.m_isNull;
421 m_isValid = other.m_isValid;
444 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
453 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
462 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
464 return std::move(*m_dataPtr);
471 Q_ASSERT_X(!m_isNull && m_hasValue, __func__,
"Access to uninitialized data");
473 return std::move(*m_dataPtr);
480 if (m_hasValue && !m_isNull){
484 return default_value;
491 std::swap(m_dataPtr, other.m_dataPtr);
492 std::swap(m_hasValue, other.m_hasValue);
493 std::swap(m_isNull, other.m_isNull);
494 std::swap(m_isValid, other.m_isValid);
515 m_dataPtr = std::move(value);
527 bool retVal = m_hasValue == other.m_hasValue && m_isNull == other.m_isNull && m_isValid == other.m_isValid;
529 if (retVal && (m_dataPtr !=
nullptr && other.m_dataPtr !=
nullptr)){
530 retVal = *m_dataPtr == *other.m_dataPtr;
540 return (!
operator==(other));
547 return m_dataPtr ==
nullptr;
554 return m_dataPtr !=
nullptr;
561 if (!m_hasValue || m_isNull){
562 Q_ASSERT_X(
false, __func__,
"Comnpare with uninitialized data");
567 return *m_dataPtr == value;
574 if (!m_hasValue || m_isNull){
575 Q_ASSERT_X(
false, __func__,
"Comnpare with uninitialized data");
580 return *m_dataPtr != value;
TNullable & operator=(const T &value)
void SetNull()
Destroys a containing value (if was set), and sets state of a container to NULL.
void Reset()
Resets a container and destroys a value.
const T * GetPtr() const
access the pointer of value
bool IsValid() const
Checks whether the container has been initialized with a value, even if it is a NULL value.
const T & operator*() const &
void swap(TNullable &other)
T & Emplace()
Initializes a container with a default value.
T & GetValue()
access the value
T value_or(const T &default_value) const
bool operator!=(const TNullable &other) const
bool operator==(const TNullable &other) const
bool HasValue() const
Checks whether the container has been initialized with a specific value.
const T * operator->() const
bool IsNull() const
Checks whether the container has been explicitly initialized with a NULL value.