[libcxx-commits] [libcxx] [libc++] Use pack subscripting for std::get (PR #156863)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 4 04:47:13 PDT 2025


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 origin/main HEAD --extensions ,h -- libcxx/include/__fwd/pair.h libcxx/include/__fwd/tuple.h libcxx/include/__utility/pair.h libcxx/include/tuple
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 7bc77f9cc..1e4635e65 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1119,23 +1119,24 @@ swap(const tuple<_Tp...>& __lhs,
 // get
 
 template <size_t _Ip, class... _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp...[_Ip]& get(tuple<_Tp...>& __t) _NOEXCEPT {
-  return static_cast<__tuple_leaf<_Ip, _Tp...[_Ip]>&>(__t.__base_).get();
-}
-
-template <size_t _Ip, class... _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp...[_Ip]& get(const tuple<_Tp...>& __t) _NOEXCEPT {
-  return static_cast<const __tuple_leaf<_Ip, _Tp...[_Ip]>&>(__t.__base_).get();
-}
-
-template <size_t _Ip, class... _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp...[_Ip]&& get(tuple<_Tp...>&& __t) _NOEXCEPT {
+        _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp... [_Ip] &
+        get(tuple<_Tp...>& __t) _NOEXCEPT { return static_cast<__tuple_leaf<_Ip, _Tp...[_Ip]>&>(__t.__base_).get(); }
+
+        template <size_t _Ip, class... _Tp>
+        _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp... [_Ip] &
+        get(const tuple<_Tp...>& __t) _NOEXCEPT {
+          return static_cast<const __tuple_leaf<_Ip, _Tp...[_Ip]>&>(__t.__base_).get();
+        }
+
+        template <size_t _Ip, class... _Tp>
+        _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp...[_Ip] &&
+    get(tuple<_Tp...>&& __t) _NOEXCEPT {
   using type _LIBCPP_NODEBUG = _Tp...[_Ip];
   return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
 }
 
 template <size_t _Ip, class... _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp...[_Ip]&& get(const tuple<_Tp...>&& __t) _NOEXCEPT {
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp...[_Ip] && get(const tuple<_Tp...>&& __t) _NOEXCEPT {
   using type _LIBCPP_NODEBUG = _Tp...[_Ip];
   return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
 }

``````````

</details>


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


More information about the libcxx-commits mailing list