aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-06-01 11:16:49 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-06-01 16:06:15 +0100
commitfe94f8b7e022b7e154f6c47cc292d4463bddac5e (patch)
treee210a16c2df0d7b5b88f092daced5531c75a20b7 /gcc
parentb7b255e77a271974479c34d1db3daafc04b920bc (diff)
downloadgcc-fe94f8b7e022b7e154f6c47cc292d4463bddac5e.zip
gcc-fe94f8b7e022b7e154f6c47cc292d4463bddac5e.tar.gz
gcc-fe94f8b7e022b7e154f6c47cc292d4463bddac5e.tar.bz2
libstdc++: Do not use std::expected::value() in monadic ops (LWG 3938)
The monadic operations in std::expected always check has_value() so we can avoid the execptional path in value() and the assertions in error() by accessing _M_val and _M_unex directly. This means that the monadic operations no longer require _M_unex to be copyable so that it can be thrown from value(), as modified by LWG 3938. This also fixes two incorrect uses of std::move in transform(F&&)& and transform(F&&) const& which I found while making these changes. Now that move-only error types are supported, it's possible to properly test the constraints that LWG 3877 added to and_then and transform. The lwg3877.cc test now does that. libstdc++-v3/ChangeLog: * include/std/expected (expected::and_then, expected::or_else) (expected::transform_error): Use _M_val and _M_unex instead of calling value() and error(), as per LWG 3938. (expected::transform): Likewise. Remove incorrect std::move calls from lvalue overloads. (expected<void, E>::and_then, expected<void, E>::or_else) (expected<void, E>::transform): Use _M_unex instead of calling error(). * testsuite/20_util/expected/lwg3877.cc: Add checks for and_then and transform, and for std::expected<void, E>. * testsuite/20_util/expected/lwg3938.cc: New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions