diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2019-12-28 17:22:06 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2019-12-28 17:22:06 +0100 |
| commit | 65f0b622e390edb39a6cfd8d614374314472a5a9 (patch) | |
| tree | 54df59e27b4f1441d5146c13601765f1a4f54bb9 /include | |
| parent | 2006e67303f31da2e5a359993e08d25c02751c5a (diff) | |
| download | newtype-65f0b622e390edb39a6cfd8d614374314472a5a9.tar.xz newtype-65f0b622e390edb39a6cfd8d614374314472a5a9.zip | |
new_type: add equality comparison tests
Diffstat (limited to 'include')
| -rw-r--r-- | include/newtype/new_type.hpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/newtype/new_type.hpp b/include/newtype/new_type.hpp index 67e29c3..c0fb8d3 100644 --- a/include/newtype/new_type.hpp +++ b/include/newtype/new_type.hpp @@ -134,7 +134,9 @@ namespace nt */ template<typename BaseType, typename TagType, auto DerivationClause> auto constexpr operator==(new_type<BaseType, TagType, DerivationClause> const & lhs, - new_type<BaseType, TagType, DerivationClause> const & rhs) noexcept(noexcept(lhs.decay() == rhs.decay())) -> bool + new_type<BaseType, TagType, DerivationClause> const & rhs) noexcept(noexcept(std::declval<BaseType const &>() == + std::declval<BaseType const &>())) + -> bool { return lhs.decay() == rhs.decay(); } @@ -144,9 +146,11 @@ namespace nt */ template<typename BaseType, typename TagType, auto DerivationClause> auto constexpr operator!=(new_type<BaseType, TagType, DerivationClause> const & lhs, - new_type<BaseType, TagType, DerivationClause> const & rhs) noexcept(noexcept(!(lhs == rhs))) -> bool + new_type<BaseType, TagType, DerivationClause> const & rhs) noexcept(noexcept(std::declval<BaseType const &>() != + std::declval<BaseType const &>())) + -> bool { - return !(lhs == rhs); + return lhs.decay() != rhs.decay(); } } // namespace nt |
