From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D91643858D38 for ; Fri, 23 Sep 2022 16:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D91643858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663951040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DFgl/eeXbF17sWaAhvIgqzFsvqq4MMLhil3V+4IXyXE=; b=QpjyzLBF/kgetjUmBsdI6colYIeVwbx6Jup1aI8VhEzTrQwRFVvRnzZ2omGSNMRQL8kqo3 nOr47LYYERvjkN0Lt2FGUMOlz/7DF5EiA61JUNFHQFJlH4Kc6iKJJ/Imi+vBXf/PzjDVOX lWEUC6i0BDg42r1XjNk6WBHdA2o/7w8= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-628-Au-5FzX6MLG6wK1AMN_skw-1; Fri, 23 Sep 2022 12:37:19 -0400 X-MC-Unique: Au-5FzX6MLG6wK1AMN_skw-1 Received: by mail-qt1-f200.google.com with SMTP id v9-20020a05622a188900b0035cc030ca25so332031qtc.1 for ; Fri, 23 Sep 2022 09:37:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=DFgl/eeXbF17sWaAhvIgqzFsvqq4MMLhil3V+4IXyXE=; b=AFwETgKp7iks5sOYhb1jy8thszt3nUyYGQe2JlS2oIS33/CHq/1CApNMhTG4kailyA HdCug4pGK2E98YgU+8HtcIZkZooGHlDiR0AW0q4t1HqRuHVc6fzUAgB9am7u5qnbNkPY lZT5skq0xPl8mO/4EEL88a9qbJ1EsNqV2wxQOUxPG8fMHmbY+P8ueO3OtK4IH8MshETn Cf8emGk/V6zipdrk36C6Qgb3hmciLqWLck4tr02I3nYtkVA9oWkCmG/yjL1pO2KvRv/A FVSBbwT9Z5z0zskjplaPZhsNM8FTckp9WoRbVH4/Y2ypa4g0cMARRq7m84iPtpcsO9rG fFRA== X-Gm-Message-State: ACrzQf3rMShohypGGxkRLX4QtGoUnvvNXgssUr4LbQU98wp1UJpjTgmR gYqsXIKJ9NdjcJiUQpEI1SjX81679tMhVT7bsUKxjRRKGva0AXn9QuSwa6JkWH1vay/NrppFqrf +c0gbdc8f/Q6JjuM= X-Received: by 2002:a05:622a:451:b0:35d:57:e1c9 with SMTP id o17-20020a05622a045100b0035d0057e1c9mr8006848qtx.49.1663951039232; Fri, 23 Sep 2022 09:37:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7GocjAl2l75kCpd49VrqFK1ISu0xN8MNxWIIIxbF47YXQXaB41F/hPRNK+upcpcnxsfG+vJA== X-Received: by 2002:a05:622a:451:b0:35d:57:e1c9 with SMTP id o17-20020a05622a045100b0035d0057e1c9mr8006834qtx.49.1663951039026; Fri, 23 Sep 2022 09:37:19 -0700 (PDT) Received: from redhat.com (2603-7000-9500-2e39-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:2e39::1db4]) by smtp.gmail.com with ESMTPSA id e24-20020ac84918000000b003445d06a622sm5411531qtq.86.2022.09.23.09.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 09:37:18 -0700 (PDT) Date: Fri, 23 Sep 2022 12:37:16 -0400 From: Marek Polacek To: Jonathan Wakely Cc: Jason Merrill , GCC Patches , libstdc++ Subject: Re: [PATCH] c++: Implement __is_{nothrow_,}convertible [PR106784] Message-ID: References: <20220922133900.142238-1-polacek@redhat.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/2.2.7 (2022-08-07) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Sep 23, 2022 at 05:34:21PM +0100, Jonathan Wakely wrote: > On Fri, 23 Sept 2022 at 15:43, Jonathan Wakely wrote: > > > > On Fri, 23 Sept 2022 at 15:34, Marek Polacek wrote: > > > > > > On Thu, Sep 22, 2022 at 06:14:44PM -0400, Jason Merrill wrote: > > > > On 9/22/22 09:39, Marek Polacek wrote: > > > > > To improve compile times, the C++ library could use compiler built-ins > > > > > rather than implementing std::is_convertible (and _nothrow) as class > > > > > templates. This patch adds the built-ins. We already have > > > > > __is_constructible and __is_assignable, and the nothrow forms of those. > > > > > > > > > > Microsoft (and clang, for compatibility) also provide an alias called > > > > > __is_convertible_to. I did not add it, but it would be trivial to do > > > > > so. > > > > > > > > > > I noticed that our __is_assignable doesn't implement the "Access checks > > > > > are performed as if from a context unrelated to either type" requirement, > > > > > therefore std::is_assignable / __is_assignable give two different results > > > > > here: > > > > > > > > > > class S { > > > > > operator int(); > > > > > friend void g(); // #1 > > > > > }; > > > > > > > > > > void > > > > > g () > > > > > { > > > > > // #1 doesn't matter > > > > > static_assert(std::is_assignable::value, ""); > > > > > static_assert(__is_assignable(int&, S), ""); > > > > > } > > > > > > > > > > This is not a problem if __is_assignable is not meant to be used by > > > > > the users. > > > > > > > > That's fine, it's not. > > > > > > Okay then. libstdc++ needs to make sure then that it's handled right. > > > > That's fine, the type traits in libstdc++ are always "a context > > unrelated to either type", unless users do something idiotic like > > declare std::is_assignable as a friend. > > > > https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1339r1.pdf > > wants to explicitly say that's idiotic. > > And I just checked that a variable template like std::is_assignable_v > also counts as "a context unrelated to either type", even when > instantiated inside a member function of the type: > > #include > > template > constexpr bool is_assignable_v = __is_assignable(T, U); > > class S { > operator int(); > friend void g(); // #1 > }; > > void > g () > { > // #1 doesn't matter > static_assert(std::is_assignable::value, ""); > static_assert(std::is_assignable_v, ""); > static_assert(__is_assignable(int&, S), ""); > } > > The first two assertions are consistent, and fail, which is what we > want. The direct use of the built-in succeeds, but we don't care. Great, thanks. Marek