From 0bb0d1d2880d562298eeec8eee4ab4e8ba943260 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 2 Sep 2025 22:30:46 +0100 Subject: libstdc++: Make CTAD ignore pair(const T1&, const T2&) constructor [PR110853] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the pair(T1, T2) explicit deduction type to decay its arguments as intended, we need the pair(const T1&, const T2&) constructor to not be used for CTAD. Otherwise we try to instantiate pair without decaying, which is ill-formed for function lvalues. Use std::type_identity_t to make the constructor unusable for an implicit deduction guide. libstdc++-v3/ChangeLog: PR libstdc++/110853 * include/bits/stl_pair.h [C++20] (pair(const T1&, const T2&)): Use std::type_identity_t for first parameter. * testsuite/20_util/pair/cons/110853.cc: New test. Reviewed-by: Patrick Palka Reviewed-by: Tomasz KamiƄski --- libstdc++-v3/include/bits/stl_pair.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libstdc++-v3/include') diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 393f6a0..2de7439 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -445,7 +445,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Constructor accepting lvalues of `first_type` and `second_type` constexpr explicit(!_S_convertible()) - pair(const _T1& __x, const _T2& __y) + pair(const type_identity_t<_T1>& __x, const _T2& __y) noexcept(_S_nothrow_constructible()) requires (_S_constructible()) : first(__x), second(__y) -- cgit v1.1