* @{
*/
-#if __glibcxx_concepts
+#ifdef __glibcxx_concepts
+ /// @cond undocumented
namespace __detail
{
// Weaken iterator_category _Cat to _Limit if it is derived from that,
using __clamp_iter_cat
= __conditional_t<derived_from<_Cat, _Limit>, _Limit, _Otherwise>;
}
+ /// @endcond
#endif
// Ignore warnings about std::iterator.
template<typename _Iter>
friend class reverse_iterator;
-#if __glibcxx_concepts
+#ifdef __glibcxx_concepts
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 3435. three_way_comparable_with<reverse_iterator<int*>, [...]>
template<typename _Iter>
public:
typedef _Iterator iterator_type;
typedef typename __traits_type::pointer pointer;
-#if ! __glibcxx_concepts
+#ifndef __glibcxx_concepts
typedef typename __traits_type::difference_type difference_type;
typedef typename __traits_type::reference reference;
#else
* underlying %iterator can be converted to the type of @c current.
*/
template<typename _Iter>
-#if __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires __convertible<_Iter>
#endif
_GLIBCXX17_CONSTEXPR
#if __cplusplus >= 201103L
template<typename _Iter>
-#if __glibcxx_concepts
+# ifdef __glibcxx_concepts
requires __convertible<_Iter>
&& assignable_from<_Iterator&, const _Iter&>
-#endif
+# endif
_GLIBCXX17_CONSTEXPR
reverse_iterator&
operator=(const reverse_iterator<_Iter>& __x)
current = __x.current;
return *this;
}
-#endif
+#endif // C++11
/**
* @return @c current, the %iterator used for underlying work.
_GLIBCXX_NODISCARD
_GLIBCXX17_CONSTEXPR pointer
operator->() const
-#if __cplusplus > 201703L && __cpp_concepts >= 201907L
+#ifdef __glibcxx_concepts
requires is_pointer_v<_Iterator>
|| requires(const _Iterator __i) { __i.operator->(); }
#endif
operator[](difference_type __n) const
{ return *(*this + __n); }
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
[[nodiscard]]
friend constexpr iter_rvalue_reference_t<_Iterator>
iter_move(const reverse_iterator& __i)
auto __ytmp = __y.base();
ranges::iter_swap(--__xtmp, --__ytmp);
}
-#endif
+#endif // ranges
private:
template<typename _Tp>
* iterators.
*
*/
-#if __cplusplus <= 201703L || ! defined __glibcxx_concepts
+#ifndef __glibcxx_concepts
template<typename _Iterator>
_GLIBCXX_NODISCARD
inline _GLIBCXX17_CONSTEXPR bool
make_reverse_iterator(_Iterator __i)
{ return reverse_iterator<_Iterator>(__i); }
-# if __cplusplus > 201703L && defined __glibcxx_concepts
+# ifdef __glibcxx_ranges
template<typename _Iterator1, typename _Iterator2>
requires (!sized_sentinel_for<_Iterator1, _Iterator2>)
inline constexpr bool
public:
/// A nested typedef for the type of whatever container you used.
typedef _Container container_type;
-#if __cplusplus > 201703L
+#ifdef __glibcxx_ranges
using difference_type = ptrdiff_t;
#endif
public:
/// A nested typedef for the type of whatever container you used.
typedef _Container container_type;
-#if __cplusplus > 201703L
+#ifdef __glibcxx_ranges
using difference_type = ptrdiff_t;
#endif
class insert_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
-#if __cplusplus > 201703L && defined __glibcxx_concepts
+#ifdef __glibcxx_ranges
using _Iter = std::__detail::__range_iter_t<_Container>;
#else
typedef typename _Container::iterator _Iter;
/// A nested typedef for the type of whatever container you used.
typedef _Container container_type;
-#if __cplusplus > 201703L && defined __glibcxx_concepts
+#ifdef __glibcxx_ranges
using difference_type = ptrdiff_t;
#endif
* template parameter deduction, making the compiler match the correct
* types for you.
*/
-#if __cplusplus > 201703L && defined __glibcxx_concepts
+#ifdef __glibcxx_ranges
template<typename _Container>
[[nodiscard]]
constexpr insert_iterator<_Container>
typedef typename __traits_type::reference reference;
typedef typename __traits_type::pointer pointer;
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
using iterator_concept = std::__detail::__iter_concept<_Iterator>;
#endif
// provide overloads whose operands are of the same type. Can someone
// remind me what generic programming is about? -- Gaby
-#if __cpp_lib_three_way_comparison
+#ifdef __cpp_lib_three_way_comparison
template<typename _IteratorL, typename _IteratorR, typename _Container>
[[nodiscard, __gnu__::__always_inline__]]
constexpr bool
* @{
*/
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
+ /// A sentinel adaptor for use with std::move_iterator.
template<semiregular _Sent>
class move_sentinel
{
private:
_Sent _M_last;
};
-#endif // C++20
+ /// @cond undocumented
namespace __detail
{
-#if __cplusplus > 201703L && __glibcxx_concepts
template<typename _Iterator>
struct __move_iter_cat
{ };
= __clamp_iter_cat<__iter_category_t<_Iterator>,
random_access_iterator_tag>;
};
-#endif
}
+ /// @endcond
+#endif // ranges
// 24.4.3 Move iterators
- /**
+ /** @brief An iterator adaptor that yields an rvalue reference.
+ *
* Class template move_iterator is an iterator adapter with the same
* behavior as the underlying iterator except that its dereference
* operator implicitly converts the value returned by the underlying
*/
template<typename _Iterator>
class move_iterator
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
: public __detail::__move_iter_cat<_Iterator>
#endif
{
_Iterator _M_current;
using __traits_type = iterator_traits<_Iterator>;
-#if ! (__cplusplus > 201703L && __glibcxx_concepts)
+#ifndef __glibcxx_ranges
using __base_ref = typename __traits_type::reference;
#endif
template<typename _Iter2>
friend class move_iterator;
-#if __glibcxx_concepts // C++20 && concepts
+#ifdef __glibcxx_concepts // C++20 && concepts
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 3435. three_way_comparable_with<reverse_iterator<int*>, [...]>
template<typename _Iter2>
&& convertible_to<const _Iter2&, _Iterator>;
#endif
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
static auto
_S_iter_concept()
{
: _M_current(std::move(__i)) { }
template<typename _Iter>
-#if __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires __convertible<_Iter>
#endif
_GLIBCXX17_CONSTEXPR
: _M_current(__i._M_current) { }
template<typename _Iter>
-#if __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires __convertible<_Iter>
&& assignable_from<_Iterator&, const _Iter&>
#endif
[[__nodiscard__]]
_GLIBCXX17_CONSTEXPR reference
operator*() const
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
{ return ranges::iter_move(_M_current); }
#else
{ return static_cast<reference>(*_M_current); }
return __tmp;
}
-#if __glibcxx_concepts
+#ifdef __glibcxx_concepts
constexpr void
operator++(int) requires (!forward_iterator<_Iterator>)
{ ++_M_current; }
[[__nodiscard__]]
_GLIBCXX17_CONSTEXPR reference
operator[](difference_type __n) const
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
{ return ranges::iter_move(_M_current + __n); }
#else
{ return std::move(_M_current[__n]); }
#endif
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
template<sentinel_for<_Iterator> _Sent>
[[nodiscard]]
friend constexpr bool
inline _GLIBCXX17_CONSTEXPR bool
operator==(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires requires { { __x.base() == __y.base() } -> convertible_to<bool>; }
#endif
{ return __x.base() == __y.base(); }
-#if __cpp_lib_three_way_comparison
+#ifdef __cpp_lib_three_way_comparison
template<typename _IteratorL,
three_way_comparable_with<_IteratorL> _IteratorR>
[[__nodiscard__]]
inline _GLIBCXX17_CONSTEXPR bool
operator<(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
#endif
{ return __x.base() < __y.base(); }
inline _GLIBCXX17_CONSTEXPR bool
operator<=(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires requires { { __y.base() < __x.base() } -> convertible_to<bool>; }
#endif
{ return !(__y < __x); }
inline _GLIBCXX17_CONSTEXPR bool
operator>(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires requires { { __y.base() < __x.base() } -> convertible_to<bool>; }
#endif
{ return __y < __x; }
inline _GLIBCXX17_CONSTEXPR bool
operator>=(const move_iterator<_IteratorL>& __x,
const move_iterator<_IteratorR>& __y)
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_concepts
requires requires { { __x.base() < __y.base() } -> convertible_to<bool>; }
#endif
{ return !(__x < __y); }
const move_iterator<_Iterator>& __y)
{ return __x.base() == __y.base(); }
-#if __cpp_lib_three_way_comparison
+#ifdef __cpp_lib_three_way_comparison
template<three_way_comparable _Iterator>
[[__nodiscard__]]
constexpr compare_three_way_result_t<_Iterator>
#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
#endif // C++11
-#if __cplusplus > 201703L && __glibcxx_concepts
+#ifdef __glibcxx_ranges
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 3736. move_iterator missing disable_sized_sentinel_for specialization
template<typename _Iterator1, typename _Iterator2>
// [iterators.common] Common iterators
+ /// @cond undocumented
namespace __detail
{
template<typename _It>
&& constructible_from<iter_value_t<_It>, iter_reference_t<_It>>
&& move_constructible<iter_value_t<_It>>;
} // namespace __detail
+ /// @endcond
/// An iterator/sentinel adaptor for representing a non-common range.
template<input_or_output_iterator _It, sentinel_for<_It> _Sent>
// [iterators.counted] Counted iterators
+ /// @cond undocumented
namespace __detail
{
template<typename _It>
struct __counted_iter_cat<_It>
{ using iterator_category = typename _It::iterator_category; };
}
+ /// @endcond
/// An iterator adaptor that keeps track of the distance to the end.
template<input_or_output_iterator _It>
void>;
};
-#if __glibcxx_ranges_as_const // >= C++23
+#ifdef __glibcxx_ranges_as_const // >= C++23
template<indirectly_readable _It>
using iter_const_reference_t
= common_reference_t<const iter_value_t<_It>&&, iter_reference_t<_It>>;
make_const_sentinel(_Sent __s)
noexcept(is_nothrow_convertible_v<_Sent, const_sentinel<_Sent>>)
{ return __s; }
-#endif // C++23
-#endif // C++20
+#endif // C++23 ranges_as_const
+#endif // C++20 ranges
/// @} group iterators
// of associative containers.
template<typename _InputIterator>
using __iter_key_t = remove_const_t<
-#if __glibcxx_tuple_like // >= C++23
+#ifdef __glibcxx_tuple_like // >= C++23
tuple_element_t<0, typename iterator_traits<_InputIterator>::value_type>>;
#else
typename iterator_traits<_InputIterator>::value_type::first_type>;
template<typename _InputIterator>
using __iter_val_t
-#if __glibcxx_tuple_like // >= C++23
+#ifdef __glibcxx_tuple_like // >= C++23
= tuple_element_t<1, typename iterator_traits<_InputIterator>::value_type>;
#else
= typename iterator_traits<_InputIterator>::value_type::second_type;