[libcxx-commits] [libcxx] [libcxx] P2278R4: cbegin and friends (PR #99915)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 22 11:53:34 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 2bc38dc30bc9baad610925d7e90e724a9d09ee7d 57bb74c215a2a9c7274e5813c649934ea70c280b --extensions ,h -- libcxx/include/__iterator/const_iterator.h libcxx/include/__ranges/const_access.h libcxx/include/__ranges/access.h libcxx/include/__ranges/concepts.h libcxx/include/__ranges/rbegin.h libcxx/include/__ranges/rend.h libcxx/include/iterator libcxx/include/ranges libcxx/include/span
``````````

</details>

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

``````````diff
diff --git a/libcxx/include/__ranges/concepts.h b/libcxx/include/__ranges/concepts.h
index 7a638817ac..19264d4ac7 100644
--- a/libcxx/include/__ranges/concepts.h
+++ b/libcxx/include/__ranges/concepts.h
@@ -62,10 +62,10 @@ concept borrowed_range =
 template <range _Rp>
 using sentinel_t = decltype(ranges::end(std::declval<_Rp&>()));
 
-#if _LIBCPP_STD_VER >= 23
+#  if _LIBCPP_STD_VER >= 23
 template <range _Rp>
 using const_iterator_t = const_iterator<iterator_t<_Rp>>;
-#endif // _LIBCPP_STD_VER >= 23
+#  endif // _LIBCPP_STD_VER >= 23
 
 template <range _Rp>
 using range_difference_t = iter_difference_t<iterator_t<_Rp>>;
@@ -76,7 +76,7 @@ using range_value_t = iter_value_t<iterator_t<_Rp>>;
 template <range _Rp>
 using range_reference_t = iter_reference_t<iterator_t<_Rp>>;
 
-template<range _Rp>
+template <range _Rp>
 using range_const_reference_t = iter_const_reference_t<iterator_t<_Rp>>;
 
 template <range _Rp>
@@ -142,10 +142,10 @@ concept viewable_range =
       (is_lvalue_reference_v<_Tp> ||
        (movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>))));
 
-#if _LIBCPP_STD_VER >= 23
+#  if _LIBCPP_STD_VER >= 23
 template <class _Tp>
 concept constant_range = input_range<_Tp> && __constant_iterator<iterator_t<_Tp>>;
-#endif // _LIBCPP_STD_VER >= 23
+#  endif // _LIBCPP_STD_VER >= 23
 
 } // namespace ranges
 
diff --git a/libcxx/include/span b/libcxx/include/span
index 72ac447b17..6d018c3e71 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -397,26 +397,18 @@ public:
 #  endif
   }
 
-#if _LIBCPP_STD_VER >= 23
-  _LIBCPP_HIDE_FROM_ABI constexpr const_iterator cbegin() const noexcept {
-    return begin();
-  }
-  _LIBCPP_HIDE_FROM_ABI constexpr const_iterator cend() const noexcept {
-    return end();
-  }
-#endif // _LIBCPP_STD_VER >= 23
+#  if _LIBCPP_STD_VER >= 23
+  _LIBCPP_HIDE_FROM_ABI constexpr const_iterator cbegin() const noexcept { return begin(); }
+  _LIBCPP_HIDE_FROM_ABI constexpr const_iterator cend() const noexcept { return end(); }
+#  endif // _LIBCPP_STD_VER >= 23
 
   _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
   _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
 
-#if _LIBCPP_STD_VER >= 23
-  _LIBCPP_HIDE_FROM_ABI constexpr const_reverse_iterator crbegin() const noexcept {
-    return rbegin();
-  }
-  _LIBCPP_HIDE_FROM_ABI constexpr const_reverse_iterator crend() const noexcept {
-    return rend();
-  }
-#endif // _LIBCPP_STD_VER >= 23
+#  if _LIBCPP_STD_VER >= 23
+  _LIBCPP_HIDE_FROM_ABI constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); }
+  _LIBCPP_HIDE_FROM_ABI constexpr const_reverse_iterator crend() const noexcept { return rend(); }
+#  endif // _LIBCPP_STD_VER >= 23
 
   _LIBCPP_HIDE_FROM_ABI span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noexcept {
     return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte*>(data()), size_bytes()};

``````````

</details>


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


More information about the libcxx-commits mailing list