From e42a927fbb40bab04a1398695efffccf8f284cdc Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 9 Jun 2023 11:10:52 +0200 Subject: concepts: replace iterator traits --- source/lib/include/newtype/concepts.hpp | 232 +++++++++ source/lib/include/newtype/derivation_clause.hpp | 7 +- .../newtype/impl/type_traits_extensions.hpp | 360 ------------- source/lib/include/newtype/newtype.hpp | 226 ++++---- source/tests/CMakeLists.txt | 1 + source/tests/src/iterable.cpp | 576 ++++++++++----------- 6 files changed, 620 insertions(+), 782 deletions(-) diff --git a/source/lib/include/newtype/concepts.hpp b/source/lib/include/newtype/concepts.hpp index 42713f5..fc625ed 100644 --- a/source/lib/include/newtype/concepts.hpp +++ b/source/lib/include/newtype/concepts.hpp @@ -204,6 +204,238 @@ namespace nt::concepts } // namespace iostreamable + inline namespace iterable + { + + template + concept free_begin = requires(SubjectType & subject) { + typename SubjectType::iterator; + { + begin(subject) + } -> std::same_as; + }; + + template + concept const_free_begin = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + begin(subject) + } -> std::same_as; + }; + + template + concept member_begin = requires(SubjectType & subject) { + typename SubjectType::iterator; + { + subject.begin() + } -> std::same_as; + }; + + template + concept const_member_begin = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + subject.begin() + } -> std::same_as; + }; + + template + concept beginnable = free_begin || member_begin; + + template + concept const_beginnable = const_free_begin || const_member_begin; + + template + concept free_cbegin = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + cbegin(subject) + } -> std::same_as; + }; + + template + concept member_cbegin = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + subject.cbegin() + } -> std::same_as; + }; + + template + concept cbeginnable = free_cbegin || member_cbegin; + + template + concept free_rbegin = requires(SubjectType & subject) { + typename SubjectType::reverse_iterator; + { + rbegin(subject) + } -> std::same_as; + }; + + template + concept const_free_rbegin = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + rbegin(subject) + } -> std::same_as; + }; + + template + concept member_rbegin = requires(SubjectType & subject) { + typename SubjectType::reverse_iterator; + { + subject.rbegin() + } -> std::same_as; + }; + + template + concept const_member_rbegin = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + subject.rbegin() + } -> std::same_as; + }; + + template + concept rbeginnable = free_rbegin || member_rbegin; + + template + concept const_rbeginnable = const_free_rbegin || const_member_rbegin; + + template + concept free_crbegin = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + crbegin(subject) + } -> std::same_as; + }; + + template + concept member_crbegin = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + subject.crbegin() + } -> std::same_as; + }; + + template + concept crbeginnable = free_crbegin || member_crbegin; + + template + concept free_end = requires(SubjectType & subject) { + typename SubjectType::iterator; + { + end(subject) + } -> std::same_as; + }; + + template + concept const_free_end = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + end(subject) + } -> std::same_as; + }; + + template + concept member_end = requires(SubjectType & subject) { + typename SubjectType::iterator; + { + subject.end() + } -> std::same_as; + }; + + template + concept const_member_end = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + subject.end() + } -> std::same_as; + }; + + template + concept endable = free_end || member_end; + + template + concept const_endable = const_free_end || const_member_end; + + template + concept free_cend = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + cend(subject) + } -> std::same_as; + }; + + template + concept member_cend = requires(SubjectType const & subject) { + typename SubjectType::const_iterator; + { + subject.cend() + } -> std::same_as; + }; + + template + concept cendable = free_cend || member_cend; + + template + concept free_rend = requires(SubjectType & subject) { + typename SubjectType::reverse_iterator; + { + rend(subject) + } -> std::same_as; + }; + + template + concept const_free_rend = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + rend(subject) + } -> std::same_as; + }; + + template + concept member_rend = requires(SubjectType & subject) { + typename SubjectType::reverse_iterator; + { + subject.rend() + } -> std::same_as; + }; + + template + concept const_member_rend = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + subject.rend() + } -> std::same_as; + }; + + template + concept rendable = free_rend || member_rend; + + template + concept const_rendable = const_free_rend || const_member_rend; + + template + concept free_crend = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + crend(subject) + } -> std::same_as; + }; + + template + concept member_crend = requires(SubjectType const & subject) { + typename SubjectType::const_reverse_iterator; + { + subject.crend() + } -> std::same_as; + }; + + template + concept crendable = free_crend || member_crend; + } // namespace iterable + inline namespace standard_extensions { diff --git a/source/lib/include/newtype/derivation_clause.hpp b/source/lib/include/newtype/derivation_clause.hpp index c4aa051..eb3e8f1 100644 --- a/source/lib/include/newtype/derivation_clause.hpp +++ b/source/lib/include/newtype/derivation_clause.hpp @@ -12,6 +12,9 @@ namespace nt template struct derivation_clause { + template + using contains = std::disjunction...>; + constexpr derivation_clause(derivable...) noexcept { } @@ -65,8 +68,8 @@ namespace nt } }; - template - concept contains = requires(DerivationClause clause) { requires clause(Feature); }; + template + concept contains = requires(DerivationClause clause) { requires DerivationClause::template contains::value; }; } // namespace nt diff --git a/source/lib/include/newtype/impl/type_traits_extensions.hpp b/source/lib/include/newtype/impl/type_traits_extensions.hpp index 3bf2c8d..dd25905 100644 --- a/source/lib/include/newtype/impl/type_traits_extensions.hpp +++ b/source/lib/include/newtype/impl/type_traits_extensions.hpp @@ -124,366 +124,6 @@ namespace nt::impl } // namespace compound_arithmetic - inline namespace iterable_begin - { - template - struct has_free_begin : std::false_type - { - }; - - template - struct has_free_begin()))>> - : std::is_same()))>> - { - }; - - template - struct has_free_begin()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_begin_v = has_free_begin::value; - - template - struct has_member_begin : std::false_type - { - }; - - template - struct has_member_begin().begin())>> - : std::is_same().begin())>> - { - }; - - template - struct has_member_begin().begin())>> - : std::is_same().begin())>> - { - }; - - template - auto constexpr has_member_begin_v = has_member_begin::value; - - template - struct has_begin : std::disjunction, has_member_begin> - { - }; - - template - auto constexpr has_begin_v = has_begin::value; - } // namespace iterable_begin - - inline namespace iterable_cbegin - { - template - struct has_free_cbegin : std::false_type - { - }; - - template - struct has_free_cbegin()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_cbegin_v = has_free_cbegin::value; - - template - struct has_member_cbegin : std::false_type - { - }; - - template - struct has_member_cbegin().cbegin())>> - : std::is_same().cbegin())> - { - }; - - template - auto constexpr has_member_cbegin_v = has_member_cbegin::value; - - template - struct has_cbegin : std::disjunction, has_member_cbegin> - { - }; - - template - auto constexpr has_cbegin_v = has_cbegin::value; - } // namespace iterable_cbegin - - inline namespace iterable_rbegin - { - template - struct has_free_rbegin : std::false_type - { - }; - - template - struct has_free_rbegin()))>> - : std::is_same()))>> - { - }; - - template - struct has_free_rbegin()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_rbegin_v = has_free_rbegin::value; - - template - struct has_member_rbegin : std::false_type - { - }; - - template - struct has_member_rbegin().rbegin())>> - : std::is_same().rbegin())>> - { - }; - - template - struct has_member_rbegin().rbegin())>> - : std::is_same().rbegin())>> - { - }; - - template - auto constexpr has_member_rbegin_v = has_member_rbegin::value; - - template - struct has_rbegin : std::disjunction, has_member_rbegin> - { - }; - - template - auto constexpr has_rbegin_v = has_rbegin::value; - } // namespace iterable_rbegin - - inline namespace iterable_crbegin - { - template - struct has_free_crbegin : std::false_type - { - }; - - template - struct has_free_crbegin()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_crbegin_v = has_free_crbegin::value; - - template - struct has_member_crbegin : std::false_type - { - }; - - template - struct has_member_crbegin().crbegin())>> - : std::is_same().crbegin())>> - { - }; - - template - auto constexpr has_member_crbegin_v = has_member_crbegin::value; - - template - struct has_crbegin : std::disjunction, has_member_crbegin> - { - }; - - template - auto constexpr has_crbegin_v = has_crbegin::value; - } // namespace iterable_crbegin - - inline namespace iterable_end - { - template - struct has_free_end : std::false_type - { - }; - - template - struct has_free_end()))>> - : std::is_same()))>> - { - }; - - template - struct has_free_end()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_end_v = has_free_end::value; - - template - struct has_member_end : std::false_type - { - }; - - template - struct has_member_end().end())>> - : std::is_same().end())>> - { - }; - - template - struct has_member_end().end())>> - : std::is_same().end())>> - { - }; - - template - auto constexpr has_member_end_v = has_member_end::value; - - template - struct has_end : std::disjunction, has_member_end> - { - }; - - template - auto constexpr has_end_v = has_end::value; - } // namespace iterable_end - - inline namespace iterable_cend - { - template - struct has_free_cend : std::false_type - { - }; - - template - struct has_free_cend()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_cend_v = has_free_cend::value; - - template - struct has_member_cend : std::false_type - { - }; - - template - struct has_member_cend().cend())>> - : std::is_same().cend())> - { - }; - - template - auto constexpr has_member_cend_v = has_member_cend::value; - - template - struct has_cend : std::disjunction, has_member_cend> - { - }; - - template - auto constexpr has_cend_v = has_cend::value; - } // namespace iterable_cend - - inline namespace iterable_rend - { - template - struct has_free_rend : std::false_type - { - }; - - template - struct has_free_rend()))>> - : std::is_same()))>> - { - }; - - template - struct has_free_rend()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_rend_v = has_free_rend::value; - - template - struct has_member_rend : std::false_type - { - }; - - template - struct has_member_rend().rend())>> - : std::is_same().rend())>> - { - }; - - template - struct has_member_rend().rend())>> - : std::is_same().rend())>> - { - }; - - template - auto constexpr has_member_rend_v = has_member_rend::value; - - template - struct has_rend : std::disjunction, has_member_rend> - { - }; - - template - auto constexpr has_rend_v = has_rend::value; - } // namespace iterable_rend - - inline namespace iterable_crend - { - template - struct has_free_crend : std::false_type - { - }; - - template - struct has_free_crend()))>> - : std::is_same()))>> - { - }; - - template - auto constexpr has_free_crend_v = has_free_crend::value; - - template - struct has_member_crend : std::false_type - { - }; - - template - struct has_member_crend().crend())>> - : std::is_same().crend())>> - { - }; - - template - auto constexpr has_member_crend_v = has_member_crend::value; - - template - struct has_crend : std::disjunction, has_member_crend> - { - }; - - template - auto constexpr has_crend_v = has_crend::value; - } // namespace iterable_crend - } // namespace nt::impl #endif \ No newline at end of file diff --git a/source/lib/include/newtype/newtype.hpp b/source/lib/include/newtype/newtype.hpp index 4642122..b5eca97 100644 --- a/source/lib/include/newtype/newtype.hpp +++ b/source/lib/include/newtype/newtype.hpp @@ -61,65 +61,53 @@ namespace nt -> std::enable_if_t, new_type &>; - template - auto constexpr friend begin(new_type & obj) - -> std::enable_if_t, - typename new_type::iterator>; + template auto DerivationClauseV> + auto constexpr friend begin(new_type & obj) -> + typename new_type::iterator; - template - auto constexpr friend begin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator>; + template auto DerivationClauseV> + auto constexpr friend begin(new_type const & obj) -> + typename new_type::const_iterator; - template - auto constexpr friend cbegin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator>; + template auto DerivationClauseV> + auto constexpr friend cbegin(new_type const & obj) -> + typename new_type::const_iterator; - template - auto constexpr friend rbegin(new_type & obj) - -> std::enable_if_t, - typename new_type::reverse_iterator>; + template auto DerivationClauseV> + auto constexpr friend rbegin(new_type & obj) -> + typename new_type::reverse_iterator; - template - auto constexpr friend rbegin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator>; + template auto DerivationClauseV> + auto constexpr friend rbegin(new_type const & obj) -> + typename new_type::const_reverse_iterator; - template - auto constexpr friend crbegin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator>; + template auto DerivationClauseV> + auto constexpr friend crbegin(new_type const & obj) -> + typename new_type::const_reverse_iterator; - template - auto constexpr friend end(new_type & obj) - -> std::enable_if_t, - typename new_type::iterator>; + template auto DerivationClauseV> + auto constexpr friend end(new_type & obj) -> + typename new_type::iterator; - template - auto constexpr friend end(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator>; + template auto DerivationClauseV> + auto constexpr friend end(new_type const & obj) -> + typename new_type::const_iterator; - template - auto constexpr friend cend(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator>; + template auto DerivationClauseV> + auto constexpr friend cend(new_type const & obj) -> + typename new_type::const_iterator; - template - auto constexpr friend rend(new_type & obj) - -> std::enable_if_t, - typename new_type::reverse_iterator>; + template auto DerivationClauseV> + auto constexpr friend rend(new_type & obj) -> + typename new_type::reverse_iterator; - template - auto constexpr friend rend(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator>; + template auto DerivationClauseV> + auto constexpr friend rend(new_type const & obj) -> + typename new_type::const_reverse_iterator; - template - auto constexpr friend crend(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator>; + template auto DerivationClauseV> + auto constexpr friend crend(new_type const & obj) -> + typename new_type::const_reverse_iterator; using super = impl::new_type_move_assignment; @@ -168,86 +156,74 @@ namespace nt return std::addressof(this->m_value); } - template * = nullptr> - auto constexpr begin() - -> std::enable_if_t, typename NewType::iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr begin() -> typename new_type::iterator { return this->m_value.begin(); } - template - auto constexpr begin() const -> std::enable_if_t, - typename NewType::const_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr begin() const -> typename new_type::const_iterator { return this->m_value.begin(); } - template - auto constexpr cbegin() const -> std::enable_if_t, - typename NewType::const_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr cbegin() const -> typename new_type::const_iterator { return this->m_value.cbegin(); } - template * = nullptr> - auto constexpr rbegin() - -> std::enable_if_t, typename NewType::reverse_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr rbegin() -> typename new_type::reverse_iterator { return this->m_value.rbegin(); } - template - auto constexpr rbegin() const -> std::enable_if_t, - typename NewType::const_reverse_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr rbegin() const -> typename new_type::const_reverse_iterator { return this->m_value.rbegin(); } - template - auto constexpr crbegin() const -> std::enable_if_t, - typename NewType::const_reverse_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr crbegin() const -> typename new_type::const_reverse_iterator { return this->m_value.crbegin(); } - template * = nullptr> - auto constexpr end() - -> std::enable_if_t, typename NewType::iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr end() -> typename new_type::iterator { return this->m_value.end(); } - template - auto constexpr end() const -> std::enable_if_t, - typename NewType::const_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr end() const -> typename new_type::const_iterator { return this->m_value.end(); } - template - auto constexpr cend() const -> std::enable_if_t, - typename NewType::const_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr cend() const -> typename new_type::const_iterator { return this->m_value.cend(); } - template * = nullptr> - auto constexpr rend() - -> std::enable_if_t, typename NewType::reverse_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr rend() -> typename new_type::reverse_iterator { return this->m_value.rend(); } - template - auto constexpr rend() const -> std::enable_if_t, - typename NewType::const_reverse_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr rend() const -> typename new_type::const_reverse_iterator { return this->m_value.rend(); } - template - auto constexpr crend() const -> std::enable_if_t, - typename NewType::const_reverse_iterator> + template auto DerivationClauseV = DerivationClause> + auto constexpr crend() const -> typename new_type::const_reverse_iterator { return this->m_value.crend(); } @@ -431,98 +407,84 @@ namespace nt return lhs; } - template - auto constexpr begin(new_type & obj) - -> std::enable_if_t, - typename new_type::iterator> + template auto DerivationClause> + auto constexpr begin(new_type & obj) -> typename new_type::iterator { return begin(obj.m_value); } - template - auto constexpr begin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator> + template auto DerivationClause> + auto constexpr begin(new_type const & obj) -> + typename new_type::const_iterator { return begin(obj.m_value); } - template - auto constexpr cbegin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator> + template auto DerivationClause> + auto constexpr cbegin(new_type const & obj) -> + typename new_type::const_iterator { return cbegin(obj.m_value); } - template - auto constexpr rbegin(new_type & obj) - -> std::enable_if_t, - typename new_type::reverse_iterator> + template auto DerivationClause> + auto constexpr rbegin(new_type & obj) -> + typename new_type::reverse_iterator { return rbegin(obj.m_value); } - template - auto constexpr rbegin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator> + template auto DerivationClause> + auto constexpr rbegin(new_type const & obj) -> + typename new_type::const_reverse_iterator { return rbegin(obj.m_value); } - template - auto constexpr crbegin(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator> + template auto DerivationClause> + auto constexpr crbegin(new_type const & obj) -> + typename new_type::const_reverse_iterator { return crbegin(obj.m_value); } - template - auto constexpr end(new_type & obj) - -> std::enable_if_t, - typename new_type::iterator> + template auto DerivationClause> + auto constexpr end(new_type & obj) -> typename new_type::iterator { return end(obj.m_value); } - template - auto constexpr end(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator> + template auto DerivationClause> + auto constexpr end(new_type const & obj) -> + typename new_type::const_iterator { return end(obj.m_value); } - template - auto constexpr cend(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_iterator> + template auto DerivationClause> + auto constexpr cend(new_type const & obj) -> + typename new_type::const_iterator { return cend(obj.m_value); } - template - auto constexpr rend(new_type & obj) - -> std::enable_if_t, - typename new_type::reverse_iterator> + template auto DerivationClause> + auto constexpr rend(new_type & obj) -> + typename new_type::reverse_iterator { return rend(obj.m_value); } - template - auto constexpr rend(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator> + template auto DerivationClause> + auto constexpr rend(new_type const & obj) -> + typename new_type::const_reverse_iterator { return rend(obj.m_value); } - template - auto constexpr crend(new_type const & obj) - -> std::enable_if_t, - typename new_type::const_reverse_iterator> + template auto DerivationClause> + auto constexpr crend(new_type const & obj) -> + typename new_type::const_reverse_iterator { return crend(obj.m_value); } diff --git a/source/tests/CMakeLists.txt b/source/tests/CMakeLists.txt index 4fa1cdc..ce6b707 100644 --- a/source/tests/CMakeLists.txt +++ b/source/tests/CMakeLists.txt @@ -28,6 +28,7 @@ target_compile_options("${PROJECT_NAME}_tests" PRIVATE "$<$:-Wextra>" "$<$:-Werror>" "$<$:-pedantic-errors>" + "$<$:-fconcepts-diagnostics-depth=5>" ) catch_discover_tests("${PROJECT_NAME}_tests") diff --git a/source/tests/src/iterable.cpp b/source/tests/src/iterable.cpp index 265dc8c..ba91500 100644 --- a/source/tests/src/iterable.cpp +++ b/source/tests/src/iterable.cpp @@ -63,308 +63,308 @@ SCENARIO("Iterators", "[iterators]") GIVEN("A new_type over a non-iterable base type not deriving nt::Iterable") { using type_alias = nt::new_type; - static_assert(!nt::impl::has_begin_v); - static_assert(!nt::impl::has_begin_v); - static_assert(!nt::impl::has_cbegin_v); - static_assert(!nt::impl::has_rbegin_v); - static_assert(!nt::impl::has_rbegin_v); - static_assert(!nt::impl::has_crbegin_v); - static_assert(!nt::impl::has_end_v); - static_assert(!nt::impl::has_end_v); - static_assert(!nt::impl::has_cend_v); - static_assert(!nt::impl::has_rend_v); - static_assert(!nt::impl::has_rend_v); - static_assert(!nt::impl::has_crend_v); + static_assert(!nt::concepts::beginnable); + static_assert(!nt::concepts::beginnable); + static_assert(!nt::concepts::cbeginnable); + static_assert(!nt::concepts::rbeginnable); + static_assert(!nt::concepts::rbeginnable); + static_assert(!nt::concepts::crbeginnable); + static_assert(!nt::concepts::endable); + static_assert(!nt::concepts::endable); + static_assert(!nt::concepts::cendable); + static_assert(!nt::concepts::rendable); + static_assert(!nt::concepts::rendable); + static_assert(!nt::concepts::crendable); THEN("it has no begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::beginnable); } THEN("it has no constant begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::beginnable); } THEN("it has no cbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_cbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::cbeginnable); } THEN("it has no rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::rbeginnable); } THEN("it has no constant rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::rbeginnable); } THEN("it has no crbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_crbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::crbeginnable); } THEN("it has no end") { - STATIC_REQUIRE_FALSE(nt::impl::has_end_v); + STATIC_REQUIRE_FALSE(nt::concepts::endable); } THEN("it has no constant end") { - STATIC_REQUIRE_FALSE(nt::impl::has_end_v); + STATIC_REQUIRE_FALSE(nt::concepts::endable); } THEN("it has no cend") { - STATIC_REQUIRE_FALSE(nt::impl::has_cend_v); + STATIC_REQUIRE_FALSE(nt::concepts::cendable); } THEN("it has no rend") { - STATIC_REQUIRE_FALSE(nt::impl::has_rend_v); + STATIC_REQUIRE_FALSE(nt::concepts::rendable); } THEN("it has no constant rend") { - STATIC_REQUIRE_FALSE(nt::impl::has_rend_v); + STATIC_REQUIRE_FALSE(nt::concepts::rendable); } THEN("it has no crend") { - STATIC_REQUIRE_FALSE(nt::impl::has_crend_v); + STATIC_REQUIRE_FALSE(nt::concepts::crendable); } } GIVEN("A new_type over a non-iterable base type deriving nt::Iterable") { using type_alias = nt::new_type; - static_assert(!nt::impl::has_begin_v); - static_assert(!nt::impl::has_begin_v); - static_assert(!nt::impl::has_cbegin_v); - static_assert(!nt::impl::has_rbegin_v); - static_assert(!nt::impl::has_rbegin_v); - static_assert(!nt::impl::has_crbegin_v); - static_assert(!nt::impl::has_end_v); - static_assert(!nt::impl::has_end_v); - static_assert(!nt::impl::has_cend_v); - static_assert(!nt::impl::has_rend_v); - static_assert(!nt::impl::has_rend_v); - static_assert(!nt::impl::has_crend_v); + static_assert(!nt::concepts::beginnable); + static_assert(!nt::concepts::beginnable); + static_assert(!nt::concepts::cbeginnable); + static_assert(!nt::concepts::rbeginnable); + static_assert(!nt::concepts::rbeginnable); + static_assert(!nt::concepts::crbeginnable); + static_assert(!nt::concepts::endable); + static_assert(!nt::concepts::endable); + static_assert(!nt::concepts::cendable); + static_assert(!nt::concepts::rendable); + static_assert(!nt::concepts::rendable); + static_assert(!nt::concepts::crendable); THEN("it has no begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::beginnable); } THEN("it has no constant begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::beginnable); } THEN("it has no cbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_cbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::cbeginnable); } THEN("it has no rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::rbeginnable); } THEN("it has no constant rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::rbeginnable); } THEN("it has no crbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_crbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::crbeginnable); } THEN("it has no end") { - STATIC_REQUIRE_FALSE(nt::impl::has_end_v); + STATIC_REQUIRE_FALSE(nt::concepts::endable); } THEN("it has no constant end") { - STATIC_REQUIRE_FALSE(nt::impl::has_end_v); + STATIC_REQUIRE_FALSE(nt::concepts::endable); } THEN("it has no cend") { - STATIC_REQUIRE_FALSE(nt::impl::has_cend_v); + STATIC_REQUIRE_FALSE(nt::concepts::cendable); } THEN("it has no rend") { - STATIC_REQUIRE_FALSE(nt::impl::has_rend_v); + STATIC_REQUIRE_FALSE(nt::concepts::rendable); } THEN("it has no constant rend") { - STATIC_REQUIRE_FALSE(nt::impl::has_rend_v); + STATIC_REQUIRE_FALSE(nt::concepts::rendable); } THEN("it has no crend") { - STATIC_REQUIRE_FALSE(nt::impl::has_crend_v); + STATIC_REQUIRE_FALSE(nt::concepts::crendable); } } GIVEN("A new_type over an iterable base type not deriving nt::Iterable") { using type_alias = nt::new_type, struct tag>; - static_assert(nt::impl::has_begin_v); - static_assert(nt::impl::has_begin_v); - static_assert(nt::impl::has_cbegin_v); - static_assert(nt::impl::has_rbegin_v); - static_assert(nt::impl::has_rbegin_v); - static_assert(nt::impl::has_crbegin_v); - static_assert(nt::impl::has_end_v); - static_assert(nt::impl::has_end_v); - static_assert(nt::impl::has_cend_v); - static_assert(nt::impl::has_rend_v); - static_assert(nt::impl::has_rend_v); - static_assert(nt::impl::has_crend_v); + static_assert(nt::concepts::beginnable); + static_assert(nt::concepts::const_beginnable); + static_assert(nt::concepts::cbeginnable); + static_assert(nt::concepts::rbeginnable); + static_assert(nt::concepts::const_rbeginnable); + static_assert(nt::concepts::crbeginnable); + static_assert(nt::concepts::endable); + static_assert(nt::concepts::const_endable); + static_assert(nt::concepts::cendable); + static_assert(nt::concepts::rendable); + static_assert(nt::concepts::const_rendable); + static_assert(nt::concepts::crendable); THEN("it has no begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::beginnable); } THEN("it has no constant begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::beginnable); } THEN("it has no cbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_cbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::cbeginnable); } THEN("it has no rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::rbeginnable); } THEN("it has no constant rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::rbeginnable); } THEN("it has no crbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_crbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::crbeginnable); } THEN("it has no end") { - STATIC_REQUIRE_FALSE(nt::impl::has_end_v); + STATIC_REQUIRE_FALSE(nt::concepts::endable); } THEN("it has no constant end") { - STATIC_REQUIRE_FALSE(nt::impl::has_end_v); + STATIC_REQUIRE_FALSE(nt::concepts::endable); } THEN("it has no cend") { - STATIC_REQUIRE_FALSE(nt::impl::has_cend_v); + STATIC_REQUIRE_FALSE(nt::concepts::cendable); } THEN("it has no rend") { - STATIC_REQUIRE_FALSE(nt::impl::has_rend_v); + STATIC_REQUIRE_FALSE(nt::concepts::rendable); } THEN("it has no constant rend") { - STATIC_REQUIRE_FALSE(nt::impl::has_rend_v); + STATIC_REQUIRE_FALSE(nt::concepts::rendable); } THEN("it has no crend") { - STATIC_REQUIRE_FALSE(nt::impl::has_crend_v); + STATIC_REQUIRE_FALSE(nt::concepts::crendable); } } GIVEN("A new_type over an iterable base type deriving nt::Iterable") { using type_alias = nt::new_type, struct tag, deriving(nt::Iterable)>; - static_assert(nt::impl::has_begin_v); - static_assert(nt::impl::has_begin_v); - static_assert(nt::impl::has_cbegin_v); - static_assert(nt::impl::has_rbegin_v); - static_assert(nt::impl::has_rbegin_v); - static_assert(nt::impl::has_crbegin_v); - static_assert(nt::impl::has_end_v); - static_assert(nt::impl::has_end_v); - static_assert(nt::impl::has_cend_v); - static_assert(nt::impl::has_rend_v); - static_assert(nt::impl::has_rend_v); - static_assert(nt::impl::has_crend_v); + static_assert(nt::concepts::beginnable); + static_assert(nt::concepts::const_beginnable); + static_assert(nt::concepts::cbeginnable); + static_assert(nt::concepts::rbeginnable); + static_assert(nt::concepts::const_rbeginnable); + static_assert(nt::concepts::crbeginnable); + static_assert(nt::concepts::endable); + static_assert(nt::concepts::const_endable); + static_assert(nt::concepts::cendable); + static_assert(nt::concepts::rendable); + static_assert(nt::concepts::const_rendable); + static_assert(nt::concepts::crendable); THEN("it has begin") { - STATIC_REQUIRE(nt::impl::has_begin_v); + STATIC_REQUIRE(nt::concepts::beginnable); } THEN("it has constant begin") { - STATIC_REQUIRE(nt::impl::has_begin_v); + STATIC_REQUIRE(nt::concepts::const_beginnable); } THEN("it has cbegin") { - STATIC_REQUIRE(nt::impl::has_cbegin_v); + STATIC_REQUIRE(nt::concepts::cbeginnable); } THEN("it has rbegin") { - STATIC_REQUIRE(nt::impl::has_rbegin_v); + STATIC_REQUIRE(nt::concepts::rbeginnable); } THEN("it has constant rbegin") { - STATIC_REQUIRE(nt::impl::has_rbegin_v); + STATIC_REQUIRE(nt::concepts::const_rbeginnable); } THEN("it has crbegin") { - STATIC_REQUIRE(nt::impl::has_crbegin_v); + STATIC_REQUIRE(nt::concepts::crbeginnable); } THEN("it has end") { - STATIC_REQUIRE(nt::impl::has_end_v); + STATIC_REQUIRE(nt::concepts::endable); } THEN("it has constant end") { - STATIC_REQUIRE(nt::impl::has_end_v); + STATIC_REQUIRE(nt::concepts::const_endable); } THEN("it has cend") { - STATIC_REQUIRE(nt::impl::has_cend_v); + STATIC_REQUIRE(nt::concepts::cendable); } THEN("it has rend") { - STATIC_REQUIRE(nt::impl::has_rend_v); + STATIC_REQUIRE(nt::concepts::rendable); } THEN("it has constant rend") { - STATIC_REQUIRE(nt::impl::has_rend_v); + STATIC_REQUIRE(nt::concepts::const_rendable); } THEN("it has crend") { - STATIC_REQUIRE(nt::impl::has_crend_v); + STATIC_REQUIRE(nt::concepts::crendable); } } } @@ -374,308 +374,308 @@ SCENARIO("Iterators (member)", "[iterators]") GIVEN("A new_type over a non-iterable base type not deriving nt::Iterable") { using type_alias = nt::new_type; - static_assert(!nt::impl::has_member_begin_v); - static_assert(!nt::impl::has_member_begin_v); - static_assert(!nt::impl::has_member_cbegin_v); - static_assert(!nt::impl::has_member_rbegin_v); - static_assert(!nt::impl::has_member_rbegin_v); - static_assert(!nt::impl::has_member_crbegin_v); - static_assert(!nt::impl::has_member_end_v); - static_assert(!nt::impl::has_member_end_v); - static_assert(!nt::impl::has_member_cend_v); - static_assert(!nt::impl::has_member_rend_v); - static_assert(!nt::impl::has_member_rend_v); - static_assert(!nt::impl::has_member_crend_v); + static_assert(!nt::concepts::member_begin); + static_assert(!nt::concepts::const_member_begin); + static_assert(!nt::concepts::member_cbegin); + static_assert(!nt::concepts::member_rbegin); + static_assert(!nt::concepts::const_member_rbegin); + static_assert(!nt::concepts::member_crbegin); + static_assert(!nt::concepts::member_end); + static_assert(!nt::concepts::const_member_end); + static_assert(!nt::concepts::member_cend); + static_assert(!nt::concepts::member_rend); + static_assert(!nt::concepts::const_member_rend); + static_assert(!nt::concepts::member_crend); THEN("it has no member begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_member_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::member_begin); } THEN("it has no member constant begin") { - STATIC_REQUIRE_FALSE(nt::impl::has_member_begin_v); + STATIC_REQUIRE_FALSE(nt::concepts::member_begin); } THEN("it has no member cbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_member_cbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::member_cbegin); } THEN("it has no member rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_member_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::member_rbegin); } THEN("it has no member constant rbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_member_rbegin_v); + STATIC_REQUIRE_FALSE(nt::concepts::member_rbegin); } THEN("it has no member crbegin") { - STATIC_REQUIRE_FALSE(nt::impl::has_member_crbegi