From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id B308D3858036; Fri, 8 Apr 2022 17:31:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B308D3858036 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-8063] libstdc++: Fix constraints on std::expected constructor [PR105153] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 0dfaf562521ba97c18398d027bf44a15f802f303 X-Git-Newrev: 7b4495d3c4040d8f56c05dd254d76269d4471623 Message-Id: <20220408173105.B308D3858036@sourceware.org> Date: Fri, 8 Apr 2022 17:31:05 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2022 17:31:05 -0000 https://gcc.gnu.org/g:7b4495d3c4040d8f56c05dd254d76269d4471623 commit r12-8063-g7b4495d3c4040d8f56c05dd254d76269d4471623 Author: Jonathan Wakely Date: Fri Apr 8 18:26:23 2022 +0100 libstdc++: Fix constraints on std::expected constructor [PR105153] libstdc++-v3/ChangeLog: PR libstdc++/105153 * include/std/expected (expected::expected(expected&&)): Fix constraints. * testsuite/20_util/expected/cons.cc: Check constructor. Diff: --- libstdc++-v3/include/std/expected | 4 ++-- libstdc++-v3/testsuite/20_util/expected/cons.cc | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/expected b/libstdc++-v3/include/std/expected index 1864e866ed0..3446d6dbaed 100644 --- a/libstdc++-v3/include/std/expected +++ b/libstdc++-v3/include/std/expected @@ -966,8 +966,8 @@ namespace __expected } template - requires is_void_v<_Tp> - && is_constructible_v<_Er, const _Gr&> + requires is_void_v<_Up> + && is_constructible_v<_Er, _Gr> && (!__cons_from_expected<_Up, _Gr>) constexpr explicit(!is_convertible_v<_Gr, _Er>) expected(expected<_Up, _Gr>&& __x) diff --git a/libstdc++-v3/testsuite/20_util/expected/cons.cc b/libstdc++-v3/testsuite/20_util/expected/cons.cc index 1fe5b7bf4d1..6946858198c 100644 --- a/libstdc++-v3/testsuite/20_util/expected/cons.cc +++ b/libstdc++-v3/testsuite/20_util/expected/cons.cc @@ -162,6 +162,22 @@ test_copy() return true; } +constexpr bool +test_pr105153() +{ + struct E { + E(int&&) = delete; + E(const int&); + }; + + std::expected e(std::expected{}); + + static_assert( ! std::is_constructible_v, + std::expected> ); + + return true; +} + int main() { test_default(); @@ -172,4 +188,6 @@ int main() static_assert( test_err() ); test_copy(); static_assert( test_copy() ); + test_pr105153(); + static_assert( test_pr105153() ); }