Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Untag dispatch get for pair #2756

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions stl/inc/utility
Original file line number Diff line number Diff line change
Expand Up @@ -651,92 +651,92 @@ struct _MSVC_KNOWN_SEMANTICS tuple_element<_Idx, pair<_Ty1, _Ty2>> {
using type = conditional_t<_Idx == 0, _Ty1, _Ty2>;
};

template <class _Ret, class _Pair>
constexpr _Ret _Pair_get(_Pair& _Pr, integral_constant<size_t, 0>) noexcept {
// get reference to element 0 in pair _Pr
return _Pr.first;
}

template <class _Ret, class _Pair>
constexpr _Ret _Pair_get(_Pair& _Pr, integral_constant<size_t, 1>) noexcept {
// get reference to element 1 in pair _Pr
return _Pr.second;
}

template <size_t _Idx, class _Ty1, class _Ty2>
_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<size_t, _Idx>{});
if constexpr (_Idx == 0) {
return _Pr.first;
} else {
return _Pr.second;
}
}

template <class _Ty1, class _Ty2>
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
_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 <class _Ty2, class _Ty1>
_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 <size_t _Idx, class _Ty1, class _Ty2>
_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<size_t, _Idx>{});
if constexpr (_Idx == 0) {
return _Pr.first;
} else {
return _Pr.second;
}
}

template <class _Ty1, class _Ty2>
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
_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 <class _Ty2, class _Ty1>
_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 <size_t _Idx, class _Ty1, class _Ty2>
_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 <class _Ty1, class _Ty2>
_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 <class _Ty2, class _Ty1>
_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 <size_t _Idx, class _Ty1, class _Ty2>
_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<const _Ty1>(_Pr.first);
} else {
return _STD forward<const _Ty2>(_Pr.second);
}
}

template <class _Ty1, class _Ty2>
_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<const _Ty1>(_Pr.first);
}

template <class _Ty2, class _Ty1>
_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<const _Ty2>(_Pr.second);
}

template <class _Ty, class _Other = _Ty>
Expand Down