Commit 6c32a9f1 by Maarten L. Hekkelman

Add operator != for optional type

parent cefeebbf
...@@ -1285,6 +1285,19 @@ condition operator==(const key &key, const std::optional<T> &v) ...@@ -1285,6 +1285,19 @@ condition operator==(const key &key, const std::optional<T> &v)
} }
/** /**
* @brief Create a condition to search any item for a value @a v if @a v contains a value
* compare to null if not.
*/
template <typename T>
condition operator!=(const key &key, const std::optional<T> &v)
{
if (v.has_value())
return condition(new detail::not_condition_impl({new detail::key_equals_condition_impl({ key.m_item_name, *v })}));
else
return condition(new detail::not_condition_impl({new detail::key_is_empty_condition_impl(key.m_item_name)}));
}
/**
* @brief Operator to create a boolean opposite of the condition in @a rhs * @brief Operator to create a boolean opposite of the condition in @a rhs
*/ */
inline condition operator not(condition &&rhs) inline condition operator not(condition &&rhs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment