forked from OSchip/llvm-project
220 lines
6.0 KiB
C++
220 lines
6.0 KiB
C++
// -*- C++ -*-
|
|
//===--------------------------- ranges -----------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef _LIBCPP_RANGES
|
|
#define _LIBCPP_RANGES
|
|
|
|
/*
|
|
|
|
#include <compare> // see [compare.syn]
|
|
#include <initializer_list> // see [initializer.list.syn]
|
|
#include <iterator> // see [iterator.synopsis]
|
|
|
|
namespace std::ranges {
|
|
inline namespace unspecified {
|
|
// [range.access], range access
|
|
inline constexpr unspecified begin = unspecified;
|
|
inline constexpr unspecified end = unspecified;
|
|
inline constexpr unspecified cbegin = unspecified;
|
|
inline constexpr unspecified cend = unspecified;
|
|
|
|
inline constexpr unspecified size = unspecified;
|
|
inline constexpr unspecified ssize = unspecified;
|
|
}
|
|
|
|
// [range.range], ranges
|
|
template<class T>
|
|
concept range = see below;
|
|
|
|
template<class T>
|
|
inline constexpr bool enable_borrowed_range = false;
|
|
|
|
template<class T>
|
|
using iterator_t = decltype(ranges::begin(declval<R&>()));
|
|
template<range R>
|
|
using sentinel_t = decltype(ranges::end(declval<R&>()));
|
|
template<range R>
|
|
using range_difference_t = iter_difference_t<iterator_t<R>>;
|
|
template<sized_range R>
|
|
using range_size_t = decltype(ranges::size(declval<R&>()));
|
|
template<range R>
|
|
using range_value_t = iter_value_t<iterator_t<R>>;
|
|
template<range R>
|
|
using range_reference_t = iter_reference_t<iterator_t<R>>;
|
|
template<range R>
|
|
using range_rvalue_reference_t = iter_rvalue_reference_t<iterator_t<R>>;
|
|
|
|
// [range.sized], sized ranges
|
|
template<class>
|
|
inline constexpr bool disable_sized_range = false;
|
|
|
|
template<class T>
|
|
concept sized_range = ...;
|
|
|
|
// [range.view], views
|
|
template<class T>
|
|
inline constexpr bool enable_view = ...;
|
|
|
|
struct view_base { };
|
|
|
|
template<class T>
|
|
concept view = ...;
|
|
|
|
// [range.refinements], other range refinements
|
|
template<class R, class T>
|
|
concept output_range = see below;
|
|
|
|
template<class T>
|
|
concept input_range = see below;
|
|
|
|
template<class T>
|
|
concept forward_range = see below;
|
|
|
|
template<class T>
|
|
concept bidirectional_range = see below;
|
|
|
|
template<class T>
|
|
concept random_access_range = see below;
|
|
|
|
template<class T>
|
|
concept contiguous_range = see below;
|
|
|
|
template <class _Tp>
|
|
concept common_range = see below;
|
|
|
|
template<class T>
|
|
concept viewable_range = see below;
|
|
|
|
// [view.interface], class template view_interface
|
|
template<class D>
|
|
requires is_class_v<D> && same_as<D, remove_cv_t<D>>
|
|
class view_interface;
|
|
|
|
// [range.subrange], sub-ranges
|
|
enum class subrange_kind : bool { unsized, sized };
|
|
|
|
template<input_or_output_iterator I, sentinel_for<I> S = I, subrange_kind K = see below>
|
|
requires (K == subrange_kind::sized || !sized_sentinel_for<S, I>)
|
|
class subrange;
|
|
|
|
template<class I, class S, subrange_kind K>
|
|
inline constexpr bool enable_borrowed_range<subrange<I, S, K>> = true;
|
|
|
|
// [range.dangling], dangling iterator handling
|
|
struct dangling;
|
|
|
|
template<range R>
|
|
using borrowed_iterator_t = see below;
|
|
|
|
template<range R>
|
|
using borrowed_subrange_t = see below;
|
|
|
|
// [range.empty], empty view
|
|
template<class T>
|
|
requires is_object_v<T>
|
|
class empty_view;
|
|
|
|
// [range.all], all view
|
|
namespace views {
|
|
inline constexpr unspecified all = unspecified;
|
|
|
|
template<viewable_range R>
|
|
using all_t = decltype(all(declval<R>()));
|
|
}
|
|
|
|
template<range R>
|
|
requires is_object_v<R>
|
|
class ref_view;
|
|
|
|
template<class T>
|
|
inline constexpr bool enable_borrowed_range<ref_view<T>> = true;
|
|
|
|
// [range.drop], drop view
|
|
template<view V>
|
|
class drop_view;
|
|
|
|
template<class T>
|
|
inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>;
|
|
|
|
// [range.transform], transform view
|
|
template<input_range V, copy_constructible F>
|
|
requires view<V> && is_object_v<F> &&
|
|
regular_invocable<F&, range_reference_t<V>> &&
|
|
can-reference<invoke_result_t<F&, range_reference_t<V>>>
|
|
class transform_view;
|
|
|
|
// [range.common], common view
|
|
template<view V>
|
|
requires (!common_range<V> && copyable<iterator_t<V>>)
|
|
class common_view;
|
|
|
|
template<class T>
|
|
inline constexpr bool enable_borrowed_range<common_view<T>> = enable_borrowed_range<T>;
|
|
|
|
// [range.take], take view
|
|
template<view> class take_view;
|
|
|
|
template<class T>
|
|
inline constexpr bool enable_borrowed_range<take_view<T>> = enable_borrowed_range<T>;
|
|
|
|
template<copy_constructible T>
|
|
requires is_object_v<T>
|
|
class single_view;
|
|
}
|
|
|
|
*/
|
|
|
|
#include <__config>
|
|
#include <__ranges/access.h>
|
|
#include <__ranges/all.h>
|
|
#include <__ranges/common_view.h>
|
|
#include <__ranges/concepts.h>
|
|
#include <__ranges/dangling.h>
|
|
#include <__ranges/data.h>
|
|
#include <__ranges/drop_view.h>
|
|
#include <__ranges/empty.h>
|
|
#include <__ranges/empty_view.h>
|
|
#include <__ranges/enable_borrowed_range.h>
|
|
#include <__ranges/enable_view.h>
|
|
#include <__ranges/ref_view.h>
|
|
#include <__ranges/single_view.h>
|
|
#include <__ranges/size.h>
|
|
#include <__ranges/subrange.h>
|
|
#include <__ranges/take_view.h>
|
|
#include <__ranges/transform_view.h>
|
|
#include <__ranges/view_interface.h>
|
|
#include <compare> // Required by the standard.
|
|
#include <initializer_list> // Required by the standard.
|
|
#include <iterator> // Required by the standard.
|
|
#include <type_traits>
|
|
#include <version>
|
|
|
|
#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
|
|
# error "The Ranges library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
|
|
#endif
|
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
#pragma GCC system_header
|
|
#endif
|
|
|
|
_LIBCPP_PUSH_MACROS
|
|
#include <__undef_macros>
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
|
|
|
|
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
_LIBCPP_POP_MACROS
|
|
|
|
#endif // _LIBCPP_RANGES
|