diff --git a/stl/inc/utility b/stl/inc/utility index 180db6b712..97f74f75f0 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -651,92 +651,92 @@ struct _MSVC_KNOWN_SEMANTICS tuple_element<_Idx, pair<_Ty1, _Ty2>> { using type = conditional_t<_Idx == 0, _Ty1, _Ty2>; }; -template -constexpr _Ret _Pair_get(_Pair& _Pr, integral_constant) noexcept { - // get reference to element 0 in pair _Pr - return _Pr.first; -} - -template -constexpr _Ret _Pair_get(_Pair& _Pr, integral_constant) noexcept { - // get reference to element 1 in pair _Pr - return _Pr.second; -} - template _NODISCARD constexpr tuple_element_t<_Idx, pair<_Ty1, _Ty2>>& get(pair<_Ty1, _Ty2>& _Pr) noexcept { // get reference to element at _Idx in pair _Pr - using _Rtype = tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&; - return _Pair_get<_Rtype>(_Pr, integral_constant{}); + if constexpr (_Idx == 0) { + return _Pr.first; + } else { + return _Pr.second; + } } template _NODISCARD constexpr _Ty1& get(pair<_Ty1, _Ty2>& _Pr) noexcept { // get reference to element _Ty1 in pair _Pr - return _STD get<0>(_Pr); + return _Pr.first; } template _NODISCARD constexpr _Ty2& get(pair<_Ty1, _Ty2>& _Pr) noexcept { // get reference to element _Ty2 in pair _Pr - return _STD get<1>(_Pr); + return _Pr.second; } template _NODISCARD constexpr const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>& get(const pair<_Ty1, _Ty2>& _Pr) noexcept { // get const reference to element at _Idx in pair _Pr - using _Ctype = const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&; - return _Pair_get<_Ctype>(_Pr, integral_constant{}); + if constexpr (_Idx == 0) { + return _Pr.first; + } else { + return _Pr.second; + } } template _NODISCARD constexpr const _Ty1& get(const pair<_Ty1, _Ty2>& _Pr) noexcept { // get const reference to element _Ty1 in pair _Pr - return _STD get<0>(_Pr); + return _Pr.first; } template _NODISCARD constexpr const _Ty2& get(const pair<_Ty1, _Ty2>& _Pr) noexcept { // get const reference to element _Ty2 in pair _Pr - return _STD get<1>(_Pr); + return _Pr.second; } template _NODISCARD constexpr tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept { // get rvalue reference to element at _Idx in pair _Pr - using _RRtype = tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&&; - return _STD forward<_RRtype>(_STD get<_Idx>(_Pr)); + if constexpr (_Idx == 0) { + return _STD forward<_Ty1>(_Pr.first); + } else { + return _STD forward<_Ty2>(_Pr.second); + } } template _NODISCARD constexpr _Ty1&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept { // get rvalue reference to element _Ty1 in pair _Pr - return _STD get<0>(_STD move(_Pr)); + return _STD forward<_Ty1>(_Pr.first); } template _NODISCARD constexpr _Ty2&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept { // get rvalue reference to element _Ty2 in pair _Pr - return _STD get<1>(_STD move(_Pr)); + return _STD forward<_Ty2>(_Pr.second); } template _NODISCARD constexpr const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept { // get const rvalue reference to element at _Idx in pair _Pr - using _RRtype = const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&&; - return _STD forward<_RRtype>(_STD get<_Idx>(_Pr)); + if constexpr (_Idx == 0) { + return _STD forward(_Pr.first); + } else { + return _STD forward(_Pr.second); + } } template _NODISCARD constexpr const _Ty1&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept { // get const rvalue reference to element _Ty1 in pair _Pr - return _STD get<0>(_STD move(_Pr)); + return _STD forward(_Pr.first); } template _NODISCARD constexpr const _Ty2&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept { // get const rvalue reference to element _Ty2 in pair _Pr - return _STD get<1>(_STD move(_Pr)); + return _STD forward(_Pr.second); } template