[libcxx-commits] [libcxx] [libc++] The rest of P2278R4 (cdata, as_const_view, span changes) (PR #102301)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 7 06:17:44 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 388b63243c6846d3bb2e9f4d8cec228756ad1d1b dc15ecdd3b06c0bf67ca37750cfa082efb85577e --extensions cpp,,inc,h -- libcxx/include/__iterator/const_iterator.h libcxx/include/__ranges/as_const_view.h libcxx/include/__ranges/const_access.h libcxx/test/std/iterators/const.iterators/alias.pass.cpp libcxx/test/std/iterators/const.iterators/iterator.pass.cpp libcxx/test/std/ranges/range.access/cbegin.pass.cpp libcxx/test/std/ranges/range.access/cbegin.verify.cpp libcxx/test/std/ranges/range.access/cend.pass.cpp libcxx/test/std/ranges/range.access/cend.verify.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/adaptor.pass.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/base.pass.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/begin.pass.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/ctad.compile.pass.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/ctor.pass.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/enable_borrowed_range.compile.pass.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/end.pass.cpp libcxx/test/std/ranges/range.adaptors/range.as.const/size.pass.cpp libcxx/include/__algorithm/ranges_reverse_copy.h libcxx/include/__format/range_default_formatter.h libcxx/include/__format/range_formatter.h libcxx/include/__iterator/reverse_iterator.h libcxx/include/__ranges/access.h libcxx/include/__ranges/concepts.h libcxx/include/__ranges/owning_view.h libcxx/include/__ranges/rbegin.h libcxx/include/__ranges/ref_view.h libcxx/include/__ranges/rend.h libcxx/include/__ranges/view_interface.h libcxx/include/iterator libcxx/include/ranges libcxx/include/span libcxx/include/string_view libcxx/include/version libcxx/modules/std/iterator.inc libcxx/modules/std/ranges.inc libcxx/test/std/containers/views/views.span/range_concept_conformance.compile.pass.cpp libcxx/test/std/containers/views/views.span/span.iterators/begin.pass.cpp libcxx/test/std/containers/views/views.span/span.iterators/end.pass.cpp libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp libcxx/test/std/containers/views/views.span/span.iterators/iterator_concept_conformance.compile.pass.cpp libcxx/test/std/containers/views/views.span/span.iterators/rbegin.pass.cpp libcxx/test/std/containers/views/views.span/span.iterators/rend.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/test/std/ranges/range.access/begin.pass.cpp libcxx/test/std/ranges/range.access/data.pass.cpp libcxx/test/std/ranges/range.access/end.pass.cpp libcxx/test/std/ranges/range.access/rbegin.pass.cpp libcxx/test/std/ranges/range.access/rend.pass.cpp libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp libcxx/test/support/test_iterators.h libcxx/test/support/test_macros.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__ranges/as_const_view.h b/libcxx/include/__ranges/as_const_view.h
index aef1c98f52..4e168577a5 100644
--- a/libcxx/include/__ranges/as_const_view.h
+++ b/libcxx/include/__ranges/as_const_view.h
@@ -111,9 +111,8 @@ struct __already_constant_case {};
 template <class _Range>
   requires constant_range<all_t<_Range>>
 struct __already_constant_case<_Range> {
-  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range)
-    noexcept(noexcept(views::all(std::forward<_Range>(__range))))
-    -> decltype(views::all(std::forward<_Range>(__range))) {
+  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range) noexcept(
+      noexcept(views::all(std::forward<_Range>(__range)))) -> decltype(views::all(std::forward<_Range>(__range))) {
     return views::all(std::forward<_Range>(__range));
   }
 };
@@ -121,11 +120,10 @@ struct __already_constant_case<_Range> {
 template <class _Range, class _UType = std::remove_cvref_t<_Range>>
 struct __empty_view_case {};
 template <class _Range, class _XType>
-  requires (!__case<__already_constant_case<_Range>>)
+  requires(!__case<__already_constant_case<_Range>>)
 struct __empty_view_case<_Range, empty_view<_XType>> {
-  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range&)
-    noexcept(noexcept(auto(views::empty<const _XType>)))
-      -> decltype(auto(views::empty<const _XType>)) {
+  _LIBCPP_HIDE_FROM_ABI static constexpr auto
+  __impl(_Range&) noexcept(noexcept(auto(views::empty<const _XType>))) -> decltype(auto(views::empty<const _XType>)) {
     return auto(views::empty<const _XType>);
   }
 };
@@ -133,11 +131,10 @@ struct __empty_view_case<_Range, empty_view<_XType>> {
 template <class _Range, class _UType = std::remove_cvref_t<_Range>>
 struct __span_case {};
 template <class _Range, class _XType, size_t _Extent>
-  requires (!__case<__already_constant_case<_Range>>)
+  requires(!__case<__already_constant_case<_Range>>)
 struct __span_case<_Range, span<_XType, _Extent>> {
-  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range)
-    noexcept(noexcept(span<const _XType, _Extent>(std::forward<_Range>(__range))))
-      -> decltype(span<const _XType, _Extent>(std::forward<_Range>(__range))) {
+  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range) noexcept(noexcept(span<const _XType, _Extent>(
+      std::forward<_Range>(__range)))) -> decltype(span<const _XType, _Extent>(std::forward<_Range>(__range))) {
     return span<const _XType, _Extent>(std::forward<_Range>(__range));
   }
 };
@@ -145,28 +142,25 @@ struct __span_case<_Range, span<_XType, _Extent>> {
 template <class _Range, class _UType = std::remove_cvref_t<_Range>>
 struct __ref_view_case {};
 template <class _Range, class _XType>
-  requires (!__case<__already_constant_case<_Range>>) && constant_range<const _XType>
+  requires(!__case<__already_constant_case<_Range>>) && constant_range<const _XType>
 struct __ref_view_case<_Range, ref_view<_XType>> {
-  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range)
-    noexcept(noexcept(ref_view(static_cast<const _XType&>(std::forward<_Range>(__range).base()))))
-    -> decltype(ref_view(static_cast<const _XType&>(std::forward<_Range>(__range).base()))) {
-      return ref_view(static_cast<const _XType&>(std::forward<_Range>(__range).base()));
+  _LIBCPP_HIDE_FROM_ABI static constexpr auto
+  __impl(_Range& __range) noexcept(noexcept(ref_view(static_cast<const _XType&>(std::forward<_Range>(__range).base()))))
+      -> decltype(ref_view(static_cast<const _XType&>(std::forward<_Range>(__range).base()))) {
+    return ref_view(static_cast<const _XType&>(std::forward<_Range>(__range).base()));
   }
 };
 
 template <class _Range, class _UType = std::remove_cvref_t<_Range>>
 struct __constant_range_case {};
 template <class _Range, class _UType>
-  requires(!__case<__already_constant_case<_Range>>)
-    && (!__case<__empty_view_case<_Range>>)
-    && (!__case<__span_case<_Range>>)
-    && (!__case<__ref_view_case<_Range>>)
-    && is_lvalue_reference_v<_Range>
-    && constant_range<const _UType>
-    && (!view<_UType>)
+  requires(!__case<__already_constant_case<_Range>>) && (!__case<__empty_view_case<_Range>>) &&
+          (!__case<__span_case<_Range>>) &&
+          (!__case<__ref_view_case<_Range>>) && is_lvalue_reference_v<_Range> && constant_range<const _UType> &&
+          (!view<_UType>)
 struct __constant_range_case<_Range, _UType> {
-  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range)
-    noexcept(noexcept(ref_view(static_cast<const _UType&>(std::forward<_Range>(__range)))))
+  _LIBCPP_HIDE_FROM_ABI static constexpr auto
+  __impl(_Range& __range) noexcept(noexcept(ref_view(static_cast<const _UType&>(std::forward<_Range>(__range)))))
       -> decltype(ref_view(static_cast<const _UType&>(std::forward<_Range>(__range)))) {
     return ref_view(static_cast<const _UType&>(std::forward<_Range>(__range)));
   }
@@ -175,15 +169,12 @@ struct __constant_range_case<_Range, _UType> {
 template <class _Range>
 struct __otherwise_case {};
 template <class _Range>
-  requires (!__case<__already_constant_case<_Range>>)
-    && (!__case<__empty_view_case<_Range>>)
-    && (!__case<__span_case<_Range>>)
-    && (!__case<__ref_view_case<_Range>>)
-    && (!__case<__constant_range_case<_Range>>)
+  requires(!__case<__already_constant_case<_Range>>) && (!__case<__empty_view_case<_Range>>) &&
+          (!__case<__span_case<_Range>>) && (!__case<__ref_view_case<_Range>>) &&
+          (!__case<__constant_range_case<_Range>>)
 struct __otherwise_case<_Range> {
-  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range)
-    noexcept(noexcept(as_const_view(std::forward<_Range>(__range))))
-      -> decltype(as_const_view(std::forward<_Range>(__range))) {
+  _LIBCPP_HIDE_FROM_ABI static constexpr auto __impl(_Range& __range) noexcept(noexcept(
+      as_const_view(std::forward<_Range>(__range)))) -> decltype(as_const_view(std::forward<_Range>(__range))) {
     return as_const_view(std::forward<_Range>(__range));
   }
 };
@@ -191,49 +182,43 @@ struct __otherwise_case<_Range> {
 struct __fn : __range_adaptor_closure<__fn> {
   // [range.as.const.overview]: the basic `constant_range` case
   template <class _Range>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
-  operator()(_Range&& __range) noexcept(noexcept(__already_constant_case<_Range>::__impl(__range)))
-      -> decltype(__already_constant_case<_Range>::__impl(__range)) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range) noexcept(noexcept(
+      __already_constant_case<_Range>::__impl(__range))) -> decltype(__already_constant_case<_Range>::__impl(__range)) {
     return __already_constant_case<_Range>::__impl(__range);
   }
 
   // [range.as.const.overview]: the `empty_view` case
   template <class _Range>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
-  operator()(_Range&& __range) noexcept(noexcept(__empty_view_case<_Range>::__impl(__range)))
-      -> decltype(__empty_view_case<_Range>::__impl(__range)) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range) noexcept(
+      noexcept(__empty_view_case<_Range>::__impl(__range))) -> decltype(__empty_view_case<_Range>::__impl(__range)) {
     return __empty_view_case<_Range>::__impl(__range);
   }
 
   // [range.as.const.overview]: the `span` case
   template <class _Range>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
-  operator()(_Range&& __range) noexcept(noexcept(__span_case<_Range>::__impl(__range)))
-      -> decltype(__span_case<_Range>::__impl(__range)) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range) noexcept(
+      noexcept(__span_case<_Range>::__impl(__range))) -> decltype(__span_case<_Range>::__impl(__range)) {
     return __span_case<_Range>::__impl(__range);
   }
 
   // [range.as.const.overview]: the `ref_view` case
   template <class _Range>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range) noexcept(
-      noexcept(__ref_view_case<_Range>::__impl(__range)))
-      -> decltype(__ref_view_case<_Range>::__impl(__range)) {
+      noexcept(__ref_view_case<_Range>::__impl(__range))) -> decltype(__ref_view_case<_Range>::__impl(__range)) {
     return __ref_view_case<_Range>::__impl(__range);
   }
 
   // [range.as.const.overview]: the second `constant_range` case
   template <class _Range>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range) noexcept(
-      noexcept(__constant_range_case<_Range>::__impl(__range)))
-      -> decltype(__constant_range_case<_Range>::__impl(__range)) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range) noexcept(noexcept(
+      __constant_range_case<_Range>::__impl(__range))) -> decltype(__constant_range_case<_Range>::__impl(__range)) {
     return __constant_range_case<_Range>::__impl(__range);
   }
 
   // [range.as.const.overview]: otherwise
   template <class _Range>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range)
-    noexcept(noexcept(__otherwise_case<_Range>::__impl(__range)))
-      -> decltype(__otherwise_case<_Range>::__impl(__range)) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range) noexcept(
+      noexcept(__otherwise_case<_Range>::__impl(__range))) -> decltype(__otherwise_case<_Range>::__impl(__range)) {
     return __otherwise_case<_Range>::__impl(__range);
   }
 };

``````````

</details>


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


More information about the libcxx-commits mailing list