Define the feature test macro now that ranges support is complete.
This also changes the preprocessor checks for the __cpp_concepts macro
so that library components depending on concepts are only enabled when
C++20 concepts are supported, and not just for the Concepts TS (which
uses different syntax in places).
* include/bits/range_cmp.h (__cpp_lib_ranges): Define.
* include/bits/stl_iterator.h: Check value of __cpp_concepts so that
C++20 concepts are required.
* include/bits/stl_iterator_base_types.h: Likewise.
* include/std/concepts: Likewise.
* include/std/version: Likewise.
* testsuite/std/ranges/headers/ranges/synopsis.cc: Check feature test
macro.
2020-03-27 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/range_cmp.h (__cpp_lib_ranges): Define.
+ * include/bits/stl_iterator.h: Check value of __cpp_concepts so that
+ C++20 concepts are required.
+ * include/bits/stl_iterator_base_types.h: Likewise.
+ * include/std/concepts: Likewise.
+ * include/std/version: Likewise.
+ * testsuite/std/ranges/headers/ranges/synopsis.cc: Check feature test
+ macro.
+
* include/bits/stl_iterator.h (reverse_iterator::iterator_concept)
(reverse_iterator::iterator_category): Define for C++20.
(reverse_iterator): Define comparison operators correctly for C++20.
};
#ifdef __cpp_lib_concepts
+// Define this here, included by all the headers that need to define it.
+#define __cpp_lib_ranges 201911L
+
namespace ranges
{
namespace __detail
*/
_GLIBCXX17_CONSTEXPR pointer
operator->() const
-#if __cplusplus > 201703L && defined __cpp_concepts
+#if __cplusplus > 201703L && __cpp_concepts >= 201907L
requires is_pointer_v<_Iterator>
|| requires(const _Iterator __i) { __i.operator->(); }
#endif
# include <type_traits> // For __void_t, is_convertible
#endif
-#if __cplusplus > 201703L && __cpp_concepts
+#if __cplusplus > 201703L && __cpp_concepts >= 201907L
# include <bits/iterator_concepts.h>
#endif
#if __cplusplus > 201703L
/// Partial specialization for object pointer types.
template<typename _Tp>
-#if __cpp_concepts
+#if __cpp_concepts >= 201907L
requires is_object_v<_Tp>
#endif
struct iterator_traits<_Tp*>
#ifndef _GLIBCXX_CONCEPTS
#define _GLIBCXX_CONCEPTS 1
-#if __cplusplus > 201703L && __cpp_concepts
+#if __cplusplus > 201703L && __cpp_concepts >= 201907L
#pragma GCC system_header
#define __cpp_lib_nonmember_container_access 201411
#define __cpp_lib_not_fn 201603
#define __cpp_lib_optional 201606L
+#define __cpp_lib_parallel_algorithm 201603L
#define __cpp_lib_raw_memory_algorithms 201606L
#define __cpp_lib_sample 201603
#ifdef _GLIBCXX_HAS_GTHREADS
#define __cpp_lib_unordered_map_insertion 201411
#define __cpp_lib_unordered_map_try_emplace 201411
#define __cpp_lib_variant 201606L
-#define __cpp_lib_parallel_algorithm 201603L
#endif
#if __cplusplus > 201703L
#define __cpp_lib_atomic_value_initialization 201911L
#define __cpp_lib_bitops 201907L
#define __cpp_lib_bounded_array_traits 201902L
-#if __cpp_concepts
+#if __cpp_concepts >= 201907L
# define __cpp_lib_concepts 201806L
#endif
#if __cpp_impl_destroying_delete
#endif
#define __cpp_lib_list_remove_return_type 201806L
#define __cpp_lib_math_constants 201907L
+#if __cpp_lib_concepts
+# define __cpp_lib_ranges 201911L
+#endif
#define __cpp_lib_span 202002L
#if __cpp_impl_three_way_comparison >= 201907L && __cpp_lib_concepts
# define __cpp_lib_three_way_comparison 201711L
template<typename T>
concept has_member_base = requires (T t) { std::forward<T>(t).base(); };
-static_assert( ! has_member_base<std::move_iterator<move_iterator>&> );
-static_assert( ! has_member_base<const std::move_iterator<move_iterator>&> );
-static_assert( has_member_base<std::move_iterator<move_iterator>> );
-static_assert( ! has_member_base<const std::move_iterator<move_iterator>> );
+using move_only_move_iterator = std::move_iterator<move_only_iterator>;
+
+static_assert( ! has_member_base<move_only_move_iterator&> );
+static_assert( ! has_member_base<const move_only_move_iterator&> );
+static_assert( has_member_base<move_only_move_iterator> );
+static_assert( ! has_member_base<const move_only_move_iterator> );
void
test01()
{
- std::move_iterator<move_only_iterator> m1, m2;
- m1 = std::make_move_iterator(move_only_iterator{});
+ move_only_move_iterator m1 = std::make_move_iterator(move_only_iterator{});
+ move_only_move_iterator m2;
m2 = std::move(m1);
- m1.swap(m2);
}
template<int N> friend Iter operator-(Iter<N>, difference_type);
template<int N> friend difference_type operator-(Iter<N>, Iter<N>);
- // Define the full set of operators for same-type comparisons
- template<int N> friend bool operator==(Iter<N>, Iter<N>); // synthesizes !=
- template<int N> friend bool operator<(Iter<N>, Iter<N>);
- template<int N> friend bool operator>(Iter<N>, Iter<N>);
- template<int N> friend bool operator<=(Iter<N>, Iter<N>);
- template<int N> friend bool operator>=(Iter<N>, Iter<N>);
+ template<int N> friend bool operator==(Iter<N>, Iter<N>);
+ template<int N> friend std::weak_ordering operator<=>(Iter<N>, Iter<N>);
};
-
static_assert( std::random_access_iterator<Iter<0>> );
int operator==(Iter<0>, long*);
#include <ranges>
+#ifndef __cpp_lib_ranges
+# error "Feature test macro for ranges is missing in <ranges>"
+#elif __cpp_lib_ranges < 201911L
+# error "Feature test macro for ranges has wrong value in <ranges>"
+#endif
+
struct R { };
template<> constexpr bool std::ranges::disable_sized_range<R> = true;