aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/lib/include/newtype/derivation_clause.hpp3
-rw-r--r--source/lib/include/newtype/newtype.hpp15
2 files changed, 8 insertions, 10 deletions
diff --git a/source/lib/include/newtype/derivation_clause.hpp b/source/lib/include/newtype/derivation_clause.hpp
index 6de70e1..c4aa051 100644
--- a/source/lib/include/newtype/derivation_clause.hpp
+++ b/source/lib/include/newtype/derivation_clause.hpp
@@ -65,6 +65,9 @@ namespace nt
}
};
+ template<typename DerivationClause, auto Feature>
+ concept contains = requires(DerivationClause clause) { requires clause(Feature); };
+
} // namespace nt
#endif \ No newline at end of file
diff --git a/source/lib/include/newtype/newtype.hpp b/source/lib/include/newtype/newtype.hpp
index 126c439..33863ac 100644
--- a/source/lib/include/newtype/newtype.hpp
+++ b/source/lib/include/newtype/newtype.hpp
@@ -259,16 +259,14 @@ namespace nt
return lhs.decay() == rhs.decay();
}
- template<nt::concepts::equality_comparable BaseType, typename TagType, auto DerivationClause>
- requires(DerivationClause(nt::EqBase))
+ template<nt::concepts::equality_comparable BaseType, typename TagType, nt::contains<nt::EqBase> auto DerivationClause>
auto constexpr operator==(new_type<BaseType, TagType, DerivationClause> const & lhs,
BaseType const & rhs) noexcept(nt::concepts::nothrow_equality_comparable<BaseType>) -> bool
{
return lhs.decay() == rhs;
}
- template<nt::concepts::equality_comparable BaseType, typename TagType, auto DerivationClause>
- requires(DerivationClause(nt::EqBase))
+ template<nt::concepts::equality_comparable BaseType, typename TagType, nt::contains<nt::EqBase> auto DerivationClause>
auto constexpr
operator==(BaseType const & lhs,
new_type<BaseType, TagType, DerivationClause> const & rhs) noexcept(nt::concepts::nothrow_equality_comparable<BaseType>) -> bool
@@ -284,16 +282,14 @@ namespace nt
return lhs.decay() != rhs.decay();
}
- template<nt::concepts::inequality_comparable BaseType, typename TagType, auto DerivationClause>
- requires(DerivationClause(nt::EqBase))
+ template<nt::concepts::inequality_comparable BaseType, typename TagType, nt::contains<nt::EqBase> auto DerivationClause>
auto constexpr operator!=(new_type<BaseType, TagType, DerivationClause> const & lhs,
BaseType const & rhs) noexcept(nt::concepts::nothrow_inequality_comparable<BaseType>) -> bool
{
return lhs.decay() != rhs;
}
- template<nt::concepts::inequality_comparable BaseType, typename TagType, auto DerivationClause>
- requires(DerivationClause(nt::EqBase))
+ template<nt::concepts::inequality_comparable BaseType, typename TagType, nt::contains<nt::EqBase> auto DerivationClause>
auto constexpr
operator!=(BaseType const & lhs,
new_type<BaseType, TagType, DerivationClause> const & rhs) noexcept(nt::concepts::nothrow_inequality_comparable<BaseType>) -> bool
@@ -533,8 +529,7 @@ namespace nt
namespace std
{
- template<typename BaseType, typename TagType, auto DerivationClause>
- requires(nt::concepts::hashable<BaseType> && DerivationClause(nt::Hash))
+ template<nt::concepts::hashable BaseType, typename TagType, nt::contains<nt::Hash> auto DerivationClause>
struct hash<nt::new_type<BaseType, TagType, DerivationClause>>
{
auto constexpr operator()(nt::new_type<BaseType, TagType, DerivationClause> const & object) const