diff --git a/include/sparrow/nullable.hpp b/include/sparrow/nullable.hpp index c3993e4a..86cc571b 100644 --- a/include/sparrow/nullable.hpp +++ b/include/sparrow/nullable.hpp @@ -23,9 +23,7 @@ namespace sparrow { - using mpl::boolean_like; - - template + template class nullable; /* * Default traits for the nullable class. These traits should be specialized @@ -229,7 +227,7 @@ namespace sparrow * @tparam T the type of the value * @tparam B the type of the flag. This type must be convertible to and assignable from bool */ - template + template class nullable { public: @@ -276,7 +274,7 @@ namespace sparrow constexpr nullable(const self_type&) = default; - template + template requires ( impl::both_constructible_from_cref and not impl::initializable_from_refs> @@ -290,7 +288,7 @@ namespace sparrow constexpr nullable(self_type&&) noexcept = default; - template + template requires ( impl::both_constructible_from_cond_ref and not impl::initializable_from_refs> @@ -351,7 +349,7 @@ namespace sparrow return *this; } - template + template requires( impl::both_assignable_from_cref and not impl::initializable_from_refs> and @@ -371,7 +369,7 @@ namespace sparrow return *this; } - template + template requires( impl::both_assignable_from_cond_ref and not impl::initializable_from_refs> and @@ -418,7 +416,7 @@ namespace sparrow T m_value; B m_null_flag; - template + template friend class nullable; }; @@ -428,7 +426,7 @@ namespace sparrow template constexpr bool operator==(const nullable& lhs, nullval_t) noexcept; - template + template constexpr std::strong_ordering operator<=>(const nullable& lhs, nullval_t) noexcept; template @@ -448,38 +446,38 @@ namespace sparrow // Even if we have CTAD in C++20, some constructors add lvalue reference // to their argument, making the deduction impossible. - template + template constexpr nullable make_nullable(T&& value, B&& flag = true); /*************************** * nullable implementation * ***************************/ - template + template constexpr nullable::operator bool() const noexcept { return m_null_flag; } - template + template constexpr bool nullable::has_value() const noexcept { return m_null_flag; } - template + template constexpr auto nullable::null_flag() & noexcept -> flag_reference { return m_null_flag; } - template + template constexpr auto nullable::null_flag() const & noexcept -> flag_const_reference { return m_null_flag; } - template + template constexpr auto nullable::null_flag() && noexcept -> flag_rvalue_reference { if constexpr (std::is_reference_v) @@ -492,7 +490,7 @@ namespace sparrow } } - template + template constexpr auto nullable::null_flag() const && noexcept -> flag_const_rvalue_reference { if constexpr (std::is_reference_v) @@ -505,19 +503,19 @@ namespace sparrow } } - template + template constexpr auto nullable::get() & noexcept -> reference { return m_value; } - template + template constexpr auto nullable::get() const & noexcept -> const_reference { return m_value; } - template + template constexpr auto nullable::get() && noexcept -> rvalue_reference { if constexpr (std::is_reference_v) @@ -530,7 +528,7 @@ namespace sparrow } } - template + template constexpr auto nullable::get() const && noexcept -> const_rvalue_reference { if constexpr (std::is_reference_v) @@ -543,49 +541,49 @@ namespace sparrow } } - template + template constexpr auto nullable::value() & -> reference { throw_if_null(); return get(); } - template + template constexpr auto nullable::value() const & -> const_reference { throw_if_null(); return get(); } - template + template constexpr auto nullable::value() && -> rvalue_reference { throw_if_null(); return std::move(*this).get(); } - template + template constexpr auto nullable::value() const && -> const_rvalue_reference { throw_if_null(); return std::move(*this).get(); } - template + template template constexpr auto nullable::value_or(U&& default_value) const & -> value_type { return *this ? get() : value_type(std::forward(default_value)); } - template + template template constexpr auto nullable::value_or(U&& default_value) && -> value_type { return *this ? get() : value_type(std::forward(default_value)); } - template + template void nullable::swap(self_type& other) noexcept { using std::swap; @@ -593,13 +591,13 @@ namespace sparrow swap(m_null_flag, other.m_null_flag); } - template + template void nullable::reset() noexcept { m_null_flag = false; } - template + template void nullable::throw_if_null() const { if (!m_null_flag) @@ -653,7 +651,7 @@ namespace sparrow return (lhs && rhs) ? lhs.get() <=> rhs.get() : bool(lhs) <=> bool(rhs); } - template + template constexpr nullable make_nullable(T&& value, B&& flag) { return nullable(std::forward(value), std::forward(flag));