public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>,
	gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [committed] libstdc++: Simplify constraints for std::any construction [PR104242]
Date: Fri, 18 Mar 2022 15:48:53 +0000	[thread overview]
Message-ID: <CACb0b4m9_F9ek9hDEn9Q2JohapO7jxAC0_q6kvT5ApCbYSZKHw@mail.gmail.com> (raw)
In-Reply-To: <20220318154303.532138-1-jwakely@redhat.com>

Oops, I meant to change the commit summary line to Un-simplify, since
it was reverting the "Simplify constaints ..." commit.


On Fri, 18 Mar 2022 at 15:43, Jonathan Wakely via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Tested powerpc64le-linux, pushed to trunk,
>
> -- >8 --
>
> Partially revert r12-4190-g6da36b7d0e43b6f9281c65c19a025d4888a25b2d
> because using __and_<..., is_copy_constructible<T>> when T is incomplete
> results in an error about deriving from is_copy_constructible<T> when
> that is incomplete. I don't know how to fix that, so this simply
> restores the previous constraint which worked in this case (even though
> I think it's technically undefined to use is_copy_constructible<T> with
> incomplete T). This doesn't restore exactly what we had before, but uses
> the is_copy_constructible_v and __is_in_place_type_v variable templates
> instead of the ::value member.
>
> libstdc++-v3/ChangeLog:
>
>         PR libstdc++/104242
>         * include/std/any (any(T&&)): Revert change to constraints.
>         * testsuite/20_util/any/cons/104242.cc: New test.
> ---
>  libstdc++-v3/include/std/any                      |  4 ++--
>  libstdc++-v3/testsuite/20_util/any/cons/104242.cc | 12 ++++++++++++
>  2 files changed, 14 insertions(+), 2 deletions(-)
>  create mode 100644 libstdc++-v3/testsuite/20_util/any/cons/104242.cc
>
> diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
> index bdad76239b4..a6770e8f235 100644
> --- a/libstdc++-v3/include/std/any
> +++ b/libstdc++-v3/include/std/any
> @@ -185,8 +185,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      /// Construct with a copy of @p __value as the contained object.
>      template <typename _Tp, typename _VTp = _Decay_if_not_any<_Tp>,
>               typename _Mgr = _Manager<_VTp>,
> -             typename = _Require<__not_<__is_in_place_type<_VTp>>,
> -                                 is_copy_constructible<_VTp>>>
> +             enable_if_t<is_copy_constructible_v<_VTp>
> +                         && !__is_in_place_type_v<_VTp>, bool> = true>
>        any(_Tp&& __value)
>        : _M_manager(&_Mgr::_S_manage)
>        {
> diff --git a/libstdc++-v3/testsuite/20_util/any/cons/104242.cc b/libstdc++-v3/testsuite/20_util/any/cons/104242.cc
> new file mode 100644
> index 00000000000..8d5868b7ff9
> --- /dev/null
> +++ b/libstdc++-v3/testsuite/20_util/any/cons/104242.cc
> @@ -0,0 +1,12 @@
> +// { dg-do compile { target c++17 } }
> +
> +// PR libstdc++/104242 - Class with constructor from std::any is not copyable
> +
> +#include <any>
> +#include <type_traits>
> +
> +struct A {
> +    A(const A&) = default;
> +    explicit A(std::any value);
> +};
> +static_assert(std::is_copy_constructible_v<A>);
> --
> 2.34.1
>


      reply	other threads:[~2022-03-18 15:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18 15:43 Jonathan Wakely
2022-03-18 15:48 ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACb0b4m9_F9ek9hDEn9Q2JohapO7jxAC0_q6kvT5ApCbYSZKHw@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).