[libcxx-commits] [libcxx] [libc++] Simplify the implementation of std::get for pairs (PR #102740)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Aug 10 04:17:53 PDT 2024
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/102740
There doesn't seem to be any benefit by calling `__get_pair`, so we can just remove the additional indirection.
>From cf0b2e2ec7aaa8ab81c05a063f25b84c7bc8084e Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sat, 10 Aug 2024 13:09:25 +0200
Subject: [PATCH] [libc++] Simplify the implementation of std::get for pairs
---
libcxx/include/__utility/pair.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h
index 0afbebcdc9f2ae..39944b3e9047f6 100644
--- a/libcxx/include/__utility/pair.h
+++ b/libcxx/include/__utility/pair.h
@@ -635,42 +635,42 @@ get(const pair<_T1, _T2>&& __p) _NOEXCEPT {
#if _LIBCPP_STD_VER >= 14
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {
- return __get_pair<0>::get(__p);
+ return __p.first;
}
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {
- return __get_pair<0>::get(__p);
+ return __p.first;
}
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
- return __get_pair<0>::get(std::move(__p));
+ return std::move(__p.first);
}
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {
- return __get_pair<0>::get(std::move(__p));
+ return std::move(__p.first);
}
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T2, _T1>& __p) _NOEXCEPT {
- return __get_pair<1>::get(__p);
+ return __p.second;
}
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T2, _T1> const& __p) _NOEXCEPT {
- return __get_pair<1>::get(__p);
+ return __p.second;
}
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T2, _T1>&& __p) _NOEXCEPT {
- return __get_pair<1>::get(std::move(__p));
+ return std::move(__p.second);
}
template <class _T1, class _T2>
inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T2, _T1> const&& __p) _NOEXCEPT {
- return __get_pair<1>::get(std::move(__p));
+ return std::move(__p.second);
}
#endif // _LIBCPP_STD_VER >= 14
More information about the libcxx-commits
mailing list