]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Simplify std::error_code and std::error_condition
authorJonathan Wakely <jwakely@redhat.com>
Fri, 26 Aug 2022 11:55:02 +0000 (12:55 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 26 Aug 2022 14:29:03 +0000 (15:29 +0100)
commit1c0288065b8184e0051d846b0940027b97ea0eb4
treea58df9efcff99cc36775375840ce35fc4eb9be9a
parent1b0b969df794d0401ccb9279d44302d1e4729f15
libstdc++: Simplify std::error_code and std::error_condition

This removes the redundant operator=(E) from std::error_code and
std::error_condition. Without that overload, assignment from a custom
type will use the templated constructor to create a temporary and then
use the trivial copy assignment operator. With the overloaded
assignment, we have to check the constraints twice as often, because
that overload and its constraints are checked for simple copy
assignments (including the one in the overloaded assignment operator
itself!)

Also add tests that ADL is used as per LWG 3629.

libstdc++-v3/ChangeLog:

* include/std/system_error (error_code::_Check): New alias
template for constructor SFINAE constraint.
(error_code::error_code(ErrorCodeEnum)): Use it.
(error_code::operator=(ErrorCodeEnum)): Remove.
(error_condition::_Check): New alias template for constraint.
(error_condition::error_condition(ErrorConditionEnum)): Use it.
(error_condition::operator=(ErrorConditionEnum)): Remove.
* testsuite/19_diagnostics/error_code/cons/1.cc: Check
constructor taking user-defined error enum.
* testsuite/19_diagnostics/error_condition/cons/1.cc: Likewise.
libstdc++-v3/include/std/system_error
libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc
libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc
This page took 0.056791 seconds and 5 git commands to generate.