From 0ca730591a6ddfdb55a2511884ded65ab44aa5d8 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Sat, 10 Feb 2018 16:03:49 -0800 Subject: [PATCH] Implement iterator_category per TS Drive-by: remove unused is_lvalue_reference_v --- include/stl2/detail/iterator/concepts.hpp | 16 +++++++++------- include/stl2/detail/range/access.hpp | 16 +++++----------- include/stl2/type_traits.hpp | 3 --- test/concepts/iterator.cpp | 2 ++ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/include/stl2/detail/iterator/concepts.hpp b/include/stl2/detail/iterator/concepts.hpp index 43f420d91..7285fa0d4 100644 --- a/include/stl2/detail/iterator/concepts.hpp +++ b/include/stl2/detail/iterator/concepts.hpp @@ -458,10 +458,13 @@ STL2_OPEN_NAMESPACE { template struct iterator_category {}; - template <_IsNot T> - struct iterator_category { - using type = ext::contiguous_iterator_tag; - }; + template + struct iterator_category + : std::enable_if::value, ext::contiguous_iterator_tag> {}; + + template + struct iterator_category + : iterator_category {}; template struct iterator_category { @@ -481,8 +484,7 @@ STL2_OPEN_NAMESPACE { struct iterator_category {}; template - using iterator_category_t = - meta::_t>>; + using iterator_category_t = meta::_t>; /////////////////////////////////////////////////////////////////////////// // Iterator [iterators.iterator] @@ -681,7 +683,7 @@ STL2_OPEN_NAMESPACE { concept bool ContiguousIterator = RandomAccessIterator && DerivedFrom, contiguous_iterator_tag> && - _Is, is_lvalue_reference> && + std::is_lvalue_reference>::value && Same, __uncvref>>; } diff --git a/include/stl2/detail/range/access.hpp b/include/stl2/detail/range/access.hpp index 685c66ef3..1194b22b6 100644 --- a/include/stl2/detail/range/access.hpp +++ b/include/stl2/detail/range/access.hpp @@ -501,8 +501,7 @@ STL2_OPEN_NAMESPACE { struct fn { // Prefer member template - requires - has_member + requires has_member constexpr auto operator()(R& r) const STL2_NOEXCEPT_RETURN( r.data() @@ -510,8 +509,7 @@ STL2_OPEN_NAMESPACE { // Return begin(r) if it's a pointer template - requires - !has_member && has_pointer_iterator + requires !has_member && has_pointer_iterator constexpr auto operator()(R& r) const STL2_NOEXCEPT_RETURN( __stl2::begin(r) @@ -520,9 +518,7 @@ STL2_OPEN_NAMESPACE { // Extension: Support contiguous ranges with non-pointer // iterators. template - requires - !has_member && - !has_pointer_iterator && + requires !has_member && !has_pointer_iterator && has_contiguous_iterator constexpr auto operator()(R& r) const noexcept(noexcept(__stl2::begin(r) == __stl2::end(r) @@ -542,10 +538,8 @@ STL2_OPEN_NAMESPACE { template [[deprecated]] constexpr auto operator()(const R&& r) const - noexcept(noexcept(declval()(r))) - requires - has_member || - has_pointer_iterator || + noexcept(noexcept(std::declval()(r))) + requires has_member || has_pointer_iterator || has_contiguous_iterator { return (*this)(r); diff --git a/include/stl2/type_traits.hpp b/include/stl2/type_traits.hpp index 76018342f..f5ce8aeb5 100644 --- a/include/stl2/type_traits.hpp +++ b/include/stl2/type_traits.hpp @@ -223,9 +223,6 @@ STL2_OPEN_NAMESPACE { __stl2::Common{T, U} constexpr bool Common = true; } - - template - constexpr auto is_lvalue_reference_v = is_lvalue_reference::value; } STL2_CLOSE_NAMESPACE #endif diff --git a/test/concepts/iterator.cpp b/test/concepts/iterator.cpp index 9654f2652..92e78e4c9 100644 --- a/test/concepts/iterator.cpp +++ b/test/concepts/iterator.cpp @@ -158,6 +158,8 @@ namespace associated_type_test { template using test = std::is_same>, U>; + CONCEPT_ASSERT(!meta::is_trait>()); + CONCEPT_ASSERT(!meta::is_trait>()); CONCEPT_ASSERT(!meta::is_trait>>()); CONCEPT_ASSERT(!meta::is_trait>>());