On Sun, 3 Oct 2021 at 10:07, Jonathan Wakely wrote: > > > > On Sat, 2 Oct 2021, 13:50 Daniel Krügler via Libstdc++, > <libstd...@gcc.gnu.org> wrote: >> >> Am Fr., 1. Okt. 2021 um 21:57 Uhr schrieb Jonathan Wakely via >> Libstdc++ <libstd...@gcc.gnu.org>: >> > >> > Implement the changes from P2162R2 (as a DR for C++17). >> > >> > Signed-off-by: Jonathan Wakely <jwak...@redhat.com> >> > >> > libstdc++-v3/ChangeLog: >> > >> > PR libstdc++/90943 >> > * include/std/variant (__cpp_lib_variant): Update value. >> > (__detail::__variant::__as): New helpers implementing the >> > as-variant exposition-only function templates. >> > (visit, visit<R>): Use __as to upcast the variant parameters. >> > * include/std/version (__cpp_lib_variant): Update value. >> > * testsuite/20_util/variant/visit_inherited.cc: New test. >> > >> > Tested powerpc64le-linux. Committed to trunk. >> > >> >> I'm wondering why the first __as overload is not noexcept as well (or >> asking it the other way around: Why different exception-specifications >> are used for the different overloads): >> >> + // The __as function templates implement the exposition-only "as-variant" >> + >> + template<typename... _Types> >> + constexpr std::variant<_Types...>& >> + __as(std::variant<_Types...>& __v) >> + { return __v; } > > > Probably just an oversight, I'll check again and fix it. Thanks!
Fixed by the attached patch, thanks again. Tested powerpc64le-linux, pushed to trunk.
commit 728e639d82099035fdfe69b716a54717ae7050e0 Author: Jonathan Wakely <jwak...@redhat.com> Date: Mon Oct 4 10:21:58 2021 libstdc++: Add missing noexcept to std::variant helper libstdc++-v3/ChangeLog: * include/std/variant (__detail::__variant::__as): Add missing noexcept to first overload. diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index d50c6b7de1d..6377b6731ea 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -206,7 +206,7 @@ namespace __variant template<typename... _Types> constexpr std::variant<_Types...>& - __as(std::variant<_Types...>& __v) + __as(std::variant<_Types...>& __v) noexcept { return __v; } template<typename... _Types>