From 3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sat, 11 Jul 2026 22:48:30 +0800 Subject: lib: establish Zircon libc++ and KTL foundation --- third_party/libcxx/include/c++/v1/ranges | 517 +++++++++++++++++++++++++++++++ 1 file changed, 517 insertions(+) create mode 100644 third_party/libcxx/include/c++/v1/ranges (limited to 'third_party/libcxx/include/c++/v1/ranges') diff --git a/third_party/libcxx/include/c++/v1/ranges b/third_party/libcxx/include/c++/v1/ranges new file mode 100644 index 0000000..9f725b1 --- /dev/null +++ b/third_party/libcxx/include/c++/v1/ranges @@ -0,0 +1,517 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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 // see [compare.syn] +#include // see [initializer.list.syn] +#include // 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 + concept range = see below; + + template + inline constexpr bool enable_borrowed_range = false; + + template + using iterator_t = decltype(ranges::begin(declval())); + template + using sentinel_t = decltype(ranges::end(declval())); + template + using range_difference_t = iter_difference_t>; + template + using range_size_t = decltype(ranges::size(declval())); + template + using range_value_t = iter_value_t>; + template + using range_reference_t = iter_reference_t>; + template + using range_rvalue_reference_t = iter_rvalue_reference_t>; + template + using range_common_reference_t = iter_common_reference_t>; + + // [range.sized], sized ranges + template + inline constexpr bool disable_sized_range = false; + + template + concept sized_range = ...; + + // [range.view], views + template + inline constexpr bool enable_view = ...; + + struct view_base { }; + + template + concept view = ...; + + // [range.refinements], other range refinements + template + concept output_range = see below; + + template + concept input_range = see below; + + template + concept forward_range = see below; + + template + concept bidirectional_range = see below; + + template + concept random_access_range = see below; + + template + concept contiguous_range = see below; + + template + concept common_range = see below; + + template + concept viewable_range = see below; + + // [range.adaptor.object], range adaptor objects + template + requires is_class_v && same_as> + class range_adaptor_closure { }; // Since c++23 + + // [view.interface], class template view_interface + template + requires is_class_v && same_as> + class view_interface; + + // [range.subrange], sub-ranges + enum class subrange_kind : bool { unsized, sized }; + + template S = I, subrange_kind K = see below> + requires (K == subrange_kind::sized || !sized_sentinel_for) + class subrange; + + template + inline constexpr bool enable_borrowed_range> = true; + + // [range.dangling], dangling iterator handling + struct dangling; + + // [range.elementsof], class template elements_of + template> + struct elements_of; + + template + using borrowed_iterator_t = see below; + + template + using borrowed_subrange_t = see below; + + // [range.elements], elements view + template + requires see below + class elements_view; + + template + inline constexpr bool enable_borrowed_range> = + enable_borrowed_range; + + template + using keys_view = elements_view; + template + using values_view = elements_view; + + namespace views { + template + inline constexpr unspecified elements = unspecified; + inline constexpr auto keys = elements<0>; + inline constexpr auto values = elements<1>; + } + + // [range.utility.conv], range conversions + template requires (!view) + constexpr C to(R&& r, Args&&... args); // Since C++23 + template class C, input_range R, class... Args> + constexpr auto to(R&& r, Args&&... args); // Since C++23 + template requires (!view) + constexpr auto to(Args&&... args); // Since C++23 + template class C, class... Args> + constexpr auto to(Args&&... args); // Since C++23 + + // [range.empty], empty view + template + requires is_object_v + class empty_view; + + template + inline constexpr bool enable_borrowed_range> = true; + + namespace views { + template + inline constexpr empty_view empty{}; + } + + // [range.all], all view + namespace views { + inline constexpr unspecified all = unspecified; + + template + using all_t = decltype(all(declval())); + } + + template + requires is_object_v + class ref_view; + + template + inline constexpr bool enable_borrowed_range> = true; + + template + requires see below + class owning_view; + + template + inline constexpr bool enable_borrowed_range> = enable_borrowed_range; + + // [range.filter], filter view + template> Pred> + requires view && is_object_v + class filter_view; + + namespace views { + inline constexpr unspecified filter = unspecified; + } + + // [range.drop], drop view + template + class drop_view; + + template + inline constexpr bool enable_borrowed_range> = enable_borrowed_range; + + // [range.drop.while], drop while view + template + requires input_range && is_object_v && + indirect_unary_predicate> + class drop_while_view; + + template + inline constexpr bool enable_borrowed_range> = + enable_borrowed_range; + + namespace views { inline constexpr unspecified drop_while = unspecified; } + + // [range.transform], transform view + template + requires view && is_object_v && + regular_invocable> && + can-reference>> + class transform_view; + + // [range.counted], counted view + namespace views { inline constexpr unspecified counted = unspecified; } + + // [range.common], common view + template + requires (!common_range && copyable>) + class common_view; + + // [range.reverse], reverse view + template + requires bidirectional_range + class reverse_view; + + template + inline constexpr bool enable_borrowed_range> = enable_borrowed_range; + + template + inline constexpr bool enable_borrowed_range> = enable_borrowed_range; + + // [range.take], take view + template class take_view; + + template + inline constexpr bool enable_borrowed_range> = enable_borrowed_range; + + // [range.take.while], take while view + template + requires input_range && is_object_v && + indirect_unary_predicate> + class take_while_view; + + namespace views { inline constexpr unspecified take_while = unspecified; } + + template + requires is_object_v + class single_view; + + template + requires weakly-equality-comparable-with && copyable + class iota_view; + + template + inline constexpr bool enable_borrowed_range> = true; + + namespace views { + inline constexpr unspecified iota = unspecified; + inline constexpr unspecified indices = unspecified; // Since C++26 + } + + // [range.repeat], repeat view + template + concept integer-like-with-usable-difference-type = // exposition only + is-signed-integer-like || (is-integer-like && weakly_incrementable); + + template + requires (is_object_v && same_as> && + (integer-like-with-usable-difference-type || + same_as)) + class repeat_view; + + namespace views { inline constexpr unspecified repeat = unspecified; } + + // [range.join], join view + template + requires view && input_range> + class join_view; + + // [range.join.with], join with view + template + requires view && input_range> + && view + && concatable, Pattern> + class join_with_view; // since C++23 + + namespace views { inline constexpr unspecified join_with = unspecified; } // since C++23 + + // [range.lazy.split], lazy split view + template + concept tiny-range = see below; // exposition only + + template + requires view && view && + indirectly_comparable, iterator_t, ranges::equal_to> && + (forward_range || tiny-range) + class lazy_split_view; + + // [range.split], split view + template + requires view && view && + indirectly_comparable, iterator_t, ranges::equal_to> + class split_view; + + namespace views { + inline constexpr unspecified lazy_split = unspecified; + inline constexpr unspecified split = unspecified; + } + + // [range.istream], istream view + template> + requires see below + class basic_istream_view; + + template + using istream_view = basic_istream_view; + + template + using wistream_view = basic_istream_view; + + namespace views { template inline constexpr unspecified istream = unspecified; } + + // [range.zip], zip view + template + requires (view && ...) && (sizeof...(Views) > 0) + class zip_view; // C++23 + + template + inline constexpr bool enable_borrowed_range> = // C++23 + (enable_borrowed_range && ...); + + namespace views { inline constexpr unspecified zip = unspecified; } // C++23 + + // [range.zip.transform], zip transform view + template + requires (view && ...) && (sizeof...(Views) > 0) && is_object_v && + regular_invocable...> && + can-reference...>> + class zip_transform_view; // C++23 + + namespace views { inline constexpr unspecified zip_transform = unspecified; } // C++23 + + // [range.adjacent], adjacent view + template + requires view && (N > 0) + class adjacent_view; + + template + constexpr bool enable_borrowed_range> = + enable_borrowed_range; + + namespace views { + template + constexpr unspecified adjacent = unspecified; + inline constexpr auto pairwise = adjacent<2>; + } + + // [range.adjacent.transform], adjacent transform view + template + requires see below + class adjacent_transform_view; + + namespace views { + template + constexpr unspecified adjacent_transform = unspecified; + inline constexpr auto pairwise_transform = adjacent_transform<2>; + } + + // [range.as.rvalue] + template + requires input_range + class as_rvalue_view; // C++23 + + namespace views { inline constexpr unspecified as_rvalue ) unspecified; } // C++23 + + [range.chunk.by] + template, iterator_t> Pred> + requires view && is_object_v + class chunk_by_view; // C++23 + + namespace views { inline constexpr unspecified chunk_by = unspecified; } // C++23 +} + +namespace std { + namespace views = ranges::views; + + template struct tuple_size; + template struct tuple_element; + + template + struct tuple_size> + : integral_constant {}; + + template + struct tuple_element<0, ranges::subrange> { + using type = I; + }; + + template + struct tuple_element<1, ranges::subrange> { + using type = S; + }; + + template + struct tuple_element<0, const ranges::subrange> { + using type = I; + }; + + template + struct tuple_element<1, const ranges::subrange> { + using type = S; + }; + + struct from_range_t { explicit from_range_t() = default; }; // Since C++23 + inline constexpr from_range_t from_range{}; // Since C++23 +} +*/ + +#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) +# include <__cxx03/__config> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 20 +# include <__ranges/access.h> +# include <__ranges/all.h> +# include <__ranges/common_view.h> +# include <__ranges/concepts.h> +# include <__ranges/counted.h> +# include <__ranges/dangling.h> +# include <__ranges/data.h> +# include <__ranges/drop_view.h> +# include <__ranges/drop_while_view.h> +# include <__ranges/elements_of.h> +# include <__ranges/elements_view.h> +# include <__ranges/empty.h> +# include <__ranges/empty_view.h> +# include <__ranges/enable_borrowed_range.h> +# include <__ranges/enable_view.h> +# include <__ranges/filter_view.h> +# include <__ranges/iota_view.h> +# include <__ranges/join_view.h> +# include <__ranges/lazy_split_view.h> +# include <__ranges/rbegin.h> +# include <__ranges/ref_view.h> +# include <__ranges/rend.h> +# include <__ranges/reverse_view.h> +# include <__ranges/single_view.h> +# include <__ranges/size.h> +# include <__ranges/split_view.h> +# include <__ranges/subrange.h> +# include <__ranges/take_view.h> +# include <__ranges/take_while_view.h> +# include <__ranges/transform_view.h> +# include <__ranges/view_interface.h> +# include <__ranges/views.h> + +# if _LIBCPP_HAS_LOCALIZATION +# include <__ranges/istream_view.h> +# endif +# endif + +# if _LIBCPP_STD_VER >= 23 +# include <__ranges/adjacent_transform_view.h> +# include <__ranges/adjacent_view.h> +# include <__ranges/as_rvalue_view.h> +# include <__ranges/chunk_by_view.h> +# include <__ranges/from_range.h> +# include <__ranges/join_with_view.h> +# include <__ranges/repeat_view.h> +# include <__ranges/to.h> +# include <__ranges/zip_transform_view.h> +# include <__ranges/zip_view.h> +# endif + +# include + +// standard-mandated includes + +// [ranges.syn] +# include +# include +# include + +// [tuple.helper] +# include <__tuple/tuple_element.h> +# include <__tuple/tuple_size.h> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# endif +#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) + +#endif // _LIBCPP_RANGES -- cgit v1.2.3