[libcxx-commits] [clang] [clang-tools-extra] [libcxx] [llvm] [libc++] implement views::concat (PR #120920)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 30 03:37:01 PST 2024


================
@@ -0,0 +1,626 @@
+// -*- 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_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/common_reference_with.h>
+#include <__concepts/constructible.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include <tuple>
+#include <variant>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26
+
+namespace ranges {
+
+template <class _T, class... _Tp>
+struct __extract_last : __extract_last<_Tp...> {};
+
+template <class _T>
+struct __extract_last<_T> {
+  using type = _T;
+};
+
+template <class _T, class... _Tp>
+struct __derived_from_pack {
+  constexpr static bool value =
+      __derived_from_pack<_T, typename __extract_last<_Tp...>::type>::value && __derived_from_pack<_Tp...>::value;
+};
+
+template <class _T, class _IterCategory>
+struct __derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};
+
+template <class _View, class... _Views>
+struct __last_view : __last_view<_Views...> {};
+
+template <class _View>
+struct __last_view<_View> {
+  using type = _View;
+};
+
+template <class _Ref, class _RRef, class _It>
+concept __concat_indirectly_readable_impl = requires(const _It it) {
+  { *it } -> convertible_to<_Ref>;
+  { ranges::iter_move(it) } -> convertible_to<_RRef>;
+};
----------------
frederick-vs-ja wrote:

Missed __uglification (ditto below)
```suggestion
template <class _Ref, class _RRef, class _It>
concept __concat_indirectly_readable_impl = requires(const _It __it) {
  { *__it } -> convertible_to<_Ref>;
  { ranges::iter_move(__it) } -> convertible_to<_RRef>;
};
```

https://github.com/llvm/llvm-project/pull/120920


More information about the libcxx-commits mailing list