This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [v3 PATCH] Constrain optional's __constexpr_addressof in its return type, Use a constexpr addressof for optional, if available.
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 6 Dec 2016 12:37:41 +0000
- Subject: Re: [v3 PATCH] Constrain optional's __constexpr_addressof in its return type, Use a constexpr addressof for optional, if available.
- Authentication-results: sourceware.org; auth=none
- References: <CAFk2RUaqjYiJPBVfU-jpHNUm=b9+xnYNeLwMp3Yn=32=TYYjrg@mail.gmail.com>
On 06/12/16 10:52 +0200, Ville Voutilainen wrote:
The background for these is at
https://stackoverflow.com/questions/40983822/cannot-use-a-constant-reference-of-experimentaloptional-when-using-clang-lib
We use excessive trickery to constrain __constexpr_addressof in
experimental::optional.
That trickery is not agreed on by compilers, and we can cope with a much simpler
approach.
The first patch just simplifies that trickery by moving the
constraints from a template
parameter to the return type.
The second patch uses a constexpr std::__addressof if it's available.
I split these
out in case we want just the first patch but not the second. The second patch
allows C++17 users to benefit from a completely constexpr addressof even
for experimental::optional (std::optional already gives that).
Tested on Linux-x64. Ok for trunk, the gcc-6 branch and the gcc-5 branch?
Yes, both patches are OK for all branches (they only affect
experimental TS material and/or C++17 mode, so OK for stage 3).
Thanks.