From patchwork Sat Mar 16 09:47:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 1912793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=WU7MSBeI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Txbtw6y4dz1yX0 for ; Sat, 16 Mar 2024 20:49:43 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA329385E451 for ; Sat, 16 Mar 2024 09:49:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA329385E451 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710582580; bh=UmYh24FM94e4gzf5A0nsX0NQXgKyK8BVhs6CryQz1PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WU7MSBeIsWlF1p82XmcuIX1lkXwlSXf2lXxnN3Htkd4Oa8VNvU5zbfjj0YWWqzYXo /aMVMOjXlOLgNdSxcg6DRZhp7okUG1NRHY2toHyF/gJq3Bkf228imLuU0xoqg7zXHM OXLyKGvP8u2VCLl7M4E1H0A92FHBML7vt6nqV86E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id AE80C3858426; Sat, 16 Mar 2024 09:49:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE80C3858426 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AE80C3858426 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710582548; cv=none; b=XBFyA9cgy8Yr6wRfsoAw9U6MHb07wrfsNWuVG19YiVcWovZHaBLYpk0LNxscjvcIM3YMDoTXObmeVrHrr62xCBEA4GiV7MNrvm9VgdqEmWAMMv7IvK/cxOtzCvIULvkLU93lNOPoyUb6ARAu5NxGt+DsbIeQU/EdECj6ST42XP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710582548; c=relaxed/simple; bh=Hp+BXxfXjfAeNQnscXEhyMc2fy0TlLZfqwNsJYJa82g=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=lrX8JkGgfLEssWmY6HIK5AQUTjRdCTQ2zqkMzED4F5sN8sCsV2bALk7rFjCfjoP4peqTtQrb6Ot4N7NdbDnjETIulnbE3gjdrxoZ09VQXgLAYNrQe79z848LLNEVlG5ZMcjxBPQTF0WHIEMcInA1GX39rkElm1Mevy24Gc8lKpQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247479.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42G9l28E022792; Sat, 16 Mar 2024 09:49:04 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3ww3h10u61-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Mar 2024 09:49:03 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.132]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW24.02) with ESMTP id 42G9mvFd019827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Mar 2024 02:48:57 -0700 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.128]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW24.02) with ESMTPSA id 42G9mv4H001158 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Mar 2024 02:48:57 -0700 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, ppalka@redhat.com, Ken Matsui Subject: [PATCH v4 2/2] extend.texi: Add documentation for all missing built-in traits [PR87343] Date: Sat, 16 Mar 2024 02:47:45 -0700 Message-ID: <20240316094744.3421487-3-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240315072042.1751225-3-kmatsui@gcc.gnu.org> References: <20240315072042.1751225-3-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Zuee_YFdtlZo-WGTtu4VHahrs889NgNy X-Proofpoint-GUID: Zuee_YFdtlZo-WGTtu4VHahrs889NgNy X-outbound-general: 1 x-header: uw-relay-non-domains X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-16_08,2024-03-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1034 bulkscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403140000 definitions=main-2403160076 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Fixed some wording and consistency issues in the documentation. -- >8 -- PR c++/87343 gcc/ChangeLog: * doc/extend.texi (Expression-yielding Type Traits): New subsection. (Type-yielding Type Traits): Likewise. (C++ Concepts): Move __is_same to ... (Expression-yielding Type Traits): ... here. (__is_enum): Add @anchor and @ref to related traits. (__is_trivial): Likewise. (__is_class): Fix documentation. (__underlying_type): Likewise. (__has_nothrow_assign): Ensure consistency. (__has_trivial_constructor): Likewise. (__has_trivial_copy): Likewise. (__has_trivial_assign): Likewise. (__has_trivial_constructor): Likewise. (__has_trivial_copy): Likewise. (__has_trivial_destructor): Likewise. (__has_virtual_destructor): Likewise. (__is_abstract): Likewise. (__is_aggregate): Likewise. (__is_base_of): Likewise. (__is_empty): Likewise. (__is_enum): Likewise. (__is_literal_type): Likewise. (__is_pod): Likewise. (__is_polymorphic): Likewise. (__is_standard_layout): Likewise. (__is_trivial): Likewise. (__is_union): Likewise. (__has_unique_object_representations): New documentation. (__is_array): Likewise. (__is_assignable): Likewise. (__is_bounded_array): Likewise. (__is_constructible): Likewise. (__is_convertible): Likewise. (__is_function): Likewise. (__is_layout_compatible): Likewise. (__is_member_function_pointer): Likewise. (__is_member_object_pointer): Likewise. (__is_member_pointer): Likewise. (__is_nothrow_assignable): Likewise. (__is_nothrow_constructible): Likewise. (__is_nothrow_convertible): Likewise. (__is_object): Likewise. (__is_pointer_interconvertible_base_of): Likewise. (__is_reference): Likewise. (__is_scoped_enum): Likewise. (__is_trivially_assignable): Likewise. (__is_trivially_constructible): Likewise. (__is_trivially_copyable): Likewise. (__reference_constructs_from_temporary): Likewise. (__reference_converts_from_temporary): Likewise. (__bases): Likewise. (__direct_bases): Likewise. (__remove_cv): Likewise. (__remove_cvref): Likewise. (__remove_pointer): Likewise. (__remove_reference): Likewise. (__type_pack_element): Likewise. Signed-off-by: Ken Matsui --- gcc/doc/extend.texi | 355 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 304 insertions(+), 51 deletions(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 1c61682b102..eb61f619e02 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -29485,79 +29485,91 @@ Function Multiversioning} for more details. @section Type Traits The C++ front end implements syntactic extensions that allow -compile-time determination of -various characteristics of a type (or of a -pair of types). +compile-time determination of various characteristics of a type +(or of a pair of types). + + +@subsection Value-yielding Type Traits + +Most of these built-ins return a @code{bool} result when invoked; the rest +yields a @code{size_t} value. @defbuiltin{bool __has_nothrow_assign (@var{type})} -If @var{type} is @code{const}-qualified or is a reference type then -the trait is @code{false}. Otherwise if @code{__has_trivial_assign (type)} -is @code{true} then the trait is @code{true}, else if @var{type} is +If @var{type} is @code{const}-qualified or is a reference type, then +the trait is @code{false}. Otherwise, if @code{__has_trivial_assign (type)} +is @code{true}, then the trait is @code{true}, else if @var{type} is a cv-qualified class or union type with copy assignment operators that are -known not to throw an exception then the trait is @code{true}, else it is +known not to throw an exception, then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin @defbuiltin{bool __has_nothrow_constructor (@var{type})} -If @code{__has_trivial_constructor (type)} is @code{true} then the trait +If @code{__has_trivial_constructor (type)} is @code{true}, then the trait is @code{true}, else if @var{type} is a cv class or union type (or array thereof) with a default constructor that is known not to throw an -exception then the trait is @code{true}, else it is @code{false}. +exception, then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin @defbuiltin{bool __has_nothrow_copy (@var{type})} -If @code{__has_trivial_copy (type)} is @code{true} then the trait is +If @code{__has_trivial_copy (type)} is @code{true}, then the trait is @code{true}, else if @var{type} is a cv-qualified class or union type -with copy constructors that are known not to throw an exception then +with copy constructors that are known not to throw an exception, then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin @defbuiltin{bool __has_trivial_assign (@var{type})} -If @var{type} is @code{const}- qualified or is a reference type then +If @var{type} is @code{const}-qualified or is a reference type, then the trait is @code{false}. Otherwise if @code{__is_trivial (type)} is -@code{true} then the trait is @code{true}, else if @var{type} is +@code{true}, then the trait is @code{true}, else if @var{type} is a cv-qualified class or union type with a trivial copy assignment -([class.copy]) then the trait is @code{true}, else it is @code{false}. +([class.copy]), then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin @defbuiltin{bool __has_trivial_constructor (@var{type})} -If @code{__is_trivial (type)} is @code{true} then the trait is @code{true}, +If @code{__is_trivial (type)} is @code{true}, then the trait is @code{true}, else if @var{type} is a cv-qualified class or union type (or array thereof) -with a trivial default constructor ([class.ctor]) then the trait is @code{true}, -else it is @code{false}. +with a trivial default constructor ([class.ctor]), then +the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin @defbuiltin{bool __has_trivial_copy (@var{type})} If @code{__is_trivial (type)} is @code{true} or @var{type} is a reference -type then the trait is @code{true}, else if @var{type} is a cv class -or union type with a trivial copy constructor ([class.copy]) then the trait -is @code{true}, else it is @code{false}. Requires: @var{type} shall be -a complete type, (possibly cv-qualified) @code{void}, or an array of unknown -bound. +type, then the trait is @code{true}, else if @var{type} is a cv class +or union type with a trivial copy constructor ([class.copy]), then the trait +is @code{true}, else it is @code{false}. +Requires: @var{type} shall be a complete type, (possibly cv-qualified) +@code{void}, or an array of unknown bound. @enddefbuiltin @defbuiltin{bool __has_trivial_destructor (@var{type})} -If @code{__is_trivial (type)} is @code{true} or @var{type} is a reference type +If @code{__is_trivial (type)} is @code{true} or @var{type} is a reference type, then the trait is @code{true}, else if @var{type} is a cv class or union -type (or array thereof) with a trivial destructor ([class.dtor]) then +type (or array thereof) with a trivial destructor ([class.dtor]), then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin +@defbuiltin{bool __has_unique_object_representations (@var{type})} +If @code{__is_trivially_copyable (type)} is @code{true} and @var{type} +has no padding bits, then the trait is @code{true}, else it is @code{false}. +Requires: @var{type} shall be a complete type, (possibly cv-qualified) +@code{void}, or an array of unknown bound. +@enddefbuiltin + @defbuiltin{bool __has_virtual_destructor (@var{type})} If @var{type} is a class type with a virtual destructor -([class.dtor]) then the trait is @code{true}, else it is @code{false}. +([class.dtor]), then the trait is @code{true}, else it is @code{false}. Requires: If @var{type} is a non-union class type, it shall be a complete type. @enddefbuiltin @@ -29569,20 +29581,36 @@ efficient implementation of @code{std::make_integer_sequence}. @enddefbuiltin @defbuiltin{bool __is_abstract (@var{type})} -If @var{type} is an abstract class ([class.abstract]) then the trait +If @var{type} is an abstract class ([class.abstract]), then the trait is @code{true}, else it is @code{false}. Requires: If @var{type} is a non-union class type, it shall be a complete type. @enddefbuiltin @defbuiltin{bool __is_aggregate (@var{type})} -If @var{type} is an aggregate type ([dcl.init.aggr]) the trait is +If @var{type} is an aggregate type ([dcl.init.aggr]), then the trait is @code{true}, else it is @code{false}. Requires: If @var{type} is a class type, it shall be a complete type. @enddefbuiltin +@anchor{__is_array} +@defbuiltin{bool __is_array (@var{type})} +If @var{type} is an array type ([dcl.array]), then the trait is @code{true}, +else it is @code{false}. +See also: @ref{__is_bounded_array}. +@enddefbuiltin + +@anchor{__is_assignable} +@defbuiltin{bool __is_assignable (@var{type1}, @var{type2})} +If @var{type1} is a class type that has @var{type2} of an assignment +operator's right operand, then the trait is @code{true}, +else it is @code{false}. +Requires: If @var{type1} is a class type, it shall be a complete type. +See also: @ref{__is_nothrow_assignable}, @ref{__is_trivially_assignable}. +@enddefbuiltin + @defbuiltin{bool __is_base_of (@var{base_type}, @var{derived_type})} If @var{base_type} is a base class of @var{derived_type} -([class.derived]) then the trait is @code{true}, otherwise it is @code{false}. +([class.derived]), then the trait is @code{true}, else it is @code{false}. Top-level cv-qualifications of @var{base_type} and @var{derived_type} are ignored. For the purposes of this trait, a class type is considered is own base. @@ -29592,9 +29620,35 @@ type (disregarding cv-qualifiers), @var{derived_type} shall be a complete type. A diagnostic is produced if this requirement is not met. @enddefbuiltin +@anchor{__is_bounded_array} +@defbuiltin{bool __is_bounded_array (@var{type})} +If @var{type} is an array type of known bound ([dcl.array]), then +the trait is @code{true}, else it is @code{false}. +See also: @ref{__is_array}. +@enddefbuiltin + @defbuiltin{bool __is_class (@var{type})} -If @var{type} is a cv-qualified class type, and not a union type -([basic.compound]) the trait is @code{true}, else it is @code{false}. +If @var{type} is a (possibly cv-qualified) non-union class type +([basic.compound]), then the trait is @code{true}, else it is @code{false}. +@enddefbuiltin + +@anchor{__is_constructible} +@defbuiltin{bool __is_constructible (@var{type}, @var{arg_types}...)} +If @var{type} is an object or reference type that can be constructed with +arguments of types @var{arg_types}..., then the trait is @code{true}, +else it is @code{false}. +Requires: Each of @var{type} or @var{arg_types}... being a class type +shall be a complete type. +See also: @ref{__is_nothrow_constructible}, @ref{__is_trivially_constructible}. +@enddefbuiltin + +@anchor{__is_convertible} +@defbuiltin{bool __is_convertible (@var{from_type}, @var{to_type})} +If a value of @var{from_type} can be implicitly converted to a value of +@var{to_type}, then the trait is @code{true}, else it is @code{false}. +Requires: Each of @var{from_type} or @var{to_type} being a class type +shall be a complete type. +See also: @ref{__is_nothrow_convertible}. @enddefbuiltin @c FIXME Commented out for GCC 13, discuss user interface for GCC 14. @@ -29604,8 +29658,8 @@ If @var{type} is a cv-qualified class type, and not a union type @c @enddefbuiltin @defbuiltin{bool __is_empty (@var{type})} -If @code{__is_class (type)} is @code{false} then the trait is @code{false}. -Otherwise @var{type} is considered empty if and only if: @var{type} +If @code{__is_class (type)} is @code{false}, then the trait is @code{false}. +Otherwise, @var{type} is considered empty if and only if: @var{type} has no non-static data members, or all non-static data members, if any, are bit-fields of length 0, and @var{type} has no virtual members, and @var{type} has no virtual base classes, and @var{type} @@ -29614,9 +29668,11 @@ has no base classes @var{base_type} for which Requires: If @var{type} is a non-union class type, it shall be a complete type. @enddefbuiltin +@anchor{__is_enum} @defbuiltin{bool __is_enum (@var{type})} -If @var{type} is a cv enumeration type ([basic.compound]) the trait is +If @var{type} is a cv enumeration type ([basic.compound]), then the trait is @code{true}, else it is @code{false}. +See also: @ref{__is_scoped_enum}. @enddefbuiltin @defbuiltin{bool __is_final (@var{type})} @@ -29625,48 +29681,254 @@ is @code{true}, else it is @code{false}. Requires: If @var{type} is a class type, it shall be a complete type. @enddefbuiltin +@defbuiltin{bool __is_function (@var{type})} +If @var{type} is a function type ([dcl.fct]), then the trait is @code{true}, +else it is @code{false}. +@enddefbuiltin + +@defbuiltin{bool __is_layout_compatible (@var{type1}, @var{type2})} +If @var{type1} and @var{type2} are layout-compatible ([basic.types]), then +the trait is @code{true}, else it is @code{false}. +Requires: @var{type1} and @var{type2} shall be complete types, (possibly +cv-qualified) @code{void}, or arrays of unknown bound. +@enddefbuiltin + @defbuiltin{bool __is_literal_type (@var{type})} -If @var{type} is a literal type ([basic.types]) the trait is +If @var{type} is a literal type ([basic.types]), then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin +@anchor{__is_member_function_pointer} +@defbuiltin{bool __is_member_function_pointer (@var{type})} +If @var{type} is a pointer to member function type ([dcl.mptr]), then +the trait is @code{true}, else it is @code{false}. +See also: @ref{__is_member_object_pointer}, @ref{__is_member_pointer}. +@enddefbuiltin + +@anchor{__is_member_object_pointer} +@defbuiltin{bool __is_member_object_pointer (@var{type})} +If @var{type} is a pointer to member object type ([dcl.mptr]), then +the trait is @code{true}, else it is @code{false}. +See also: @ref{__is_member_function_pointer}, @ref{__is_member_pointer}. +@enddefbuiltin + +@anchor{__is_member_pointer} +@defbuiltin{bool __is_member_pointer (@var{type})} +If @var{type} is a pointer to member type ([dcl.mptr]), then the trait is +@code{true}, else it is @code{false}. +See also: @ref{__is_member_function_pointer}, @ref{__is_member_object_pointer}. +@enddefbuiltin + +@anchor{__is_nothrow_assignable} +@defbuiltin{bool __is_nothrow_assignable (@var{type1}, @var{type2})} +If @code{__is_assignable (type1, type2)} is @code{true} and the assignment +operation does not throw an exception, then the trait is @code{true}, else +it is @code{false}. +Requires: Each of @var{type1} or @var{type2} being a class type +shall be a complete type. +See also: @ref{__is_assignable}, @ref{__is_trivially_assignable}. +@enddefbuiltin + +@anchor{__is_nothrow_constructible} +@defbuiltin{bool __is_nothrow_constructible (@var{type}, @var{arg_types}...)} +If @code{__is_constructible (type, arg_types...)} is @code{true} and the +construction does not throw an exception, then the trait is @code{true}, +else it is @code{false}. +Requires: Each of @var{type} or @var{arg_types}... being a class type +shall be a complete type. +See also: @ref{__is_constructible}, @ref{__is_trivially_constructible}. +@enddefbuiltin + +@anchor{__is_nothrow_convertible} +@defbuiltin{bool __is_nothrow_convertible (@var{from_type}, @var{to_type})} +If @code{__is_convertible (from_type, to_type)} is @code{true} and the +conversion does not throw an exception, then the trait is @code{true}, +else it is @code{false}. +Requires: Each of @var{from_type} or @var{to_type} being a class type +shall be a complete type. +See also: @ref{__is_convertible}. +@enddefbuiltin + +@defbuiltin{bool __is_object (@var{type})} +If @var{type} is an object type ([basic.types]), then the trait is +@code{true}, else it is @code{false}. +@enddefbuiltin + +@defbuiltin{bool __is_pointer_interconvertible_base_of (@var{base_type}, @var{derived_type})} +If @var{base_type} and @var{derived_type} are pointer-interconvertible +([conv.ptr]) and @var{base_type} is a base class of @var{derived_type} +([class.derived]), then the trait is @code{true}, else it is @code{false}. +Requires: if @code{__is_class (base_type)} and @code{__is_class (derived_type)} +are @code{true} and @var{base_type} and @var{derived_type} are not the same +type (disregarding cv-qualifiers), @var{derived_type} shall be a complete +type. A diagnostic is produced if this requirement is not met. +@enddefbuiltin + @defbuiltin{bool __is_pod (@var{type})} -If @var{type} is a cv POD type ([basic.types]) then the trait is @code{true}, +If @var{type} is a cv POD type ([basic.types]), then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, (possibly cv-qualified) @code{void}, or an array of unknown bound. @enddefbuiltin @defbuiltin{bool __is_polymorphic (@var{type})} -If @var{type} is a polymorphic class ([class.virtual]) then the trait +If @var{type} is a polymorphic class ([class.virtual]), then the trait is @code{true}, else it is @code{false}. Requires: If @var{type} is a non-union class type, it shall be a complete type. @enddefbuiltin +@defbuiltin{bool __is_reference (@var{type})} +If @var{type} is a reference type ([dcl.ref]), then the trait is @code{true}, +else it is @code{false}. +@enddefbuiltin + +@defbuiltin{bool __is_same (@var{type1}, @var{type2})} +If @var{type1} and @var{type2} refer to the same type, then the trait is +@code{true}, else it is @code{false}. +@enddefbuiltin + +@anchor{__is_scoped_enum} +@defbuiltin{bool __is_scoped_enum (@var{type})} +If @var{type} is a scoped enumeration type ([dcl.enum]), then the trait is +@code{true}, else it is @code{false}. +See also: @ref{__is_enum}. +@enddefbuiltin + @defbuiltin{bool __is_standard_layout (@var{type})} -If @var{type} is a standard-layout type ([basic.types]) the trait is +If @var{type} is a standard-layout type ([basic.types]), then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, an array of complete types, or (possibly cv-qualified) @code{void}. @enddefbuiltin +@anchor{__is_trivial} @defbuiltin{bool __is_trivial (@var{type})} -If @var{type} is a trivial type ([basic.types]) the trait is +If @var{type} is a trivial type ([basic.types]), then the trait is @code{true}, else it is @code{false}. Requires: @var{type} shall be a complete type, an array of complete types, or (possibly cv-qualified) @code{void}. +See also: @ref{__is_trivially_assignable}, @ref{__is_trivially_constructible}, +@ref{__is_trivially_copyable}. +@enddefbuiltin + +@anchor{__is_trivially_assignable} +@defbuiltin{bool __is_trivially_assignable (@var{type1}, @var{type2})} +If @code{__is_assignable (type1, type2)} is @code{true} and +@code{__is_trivial (type1)} is @code{true}, then the trait is @code{true}, +else it is @code{false}. +Requires: Each of @var{type1} or @var{type2} being a class type +shall be a complete type. +See also: @ref{__is_trivial}, @ref{__is_assignable}, +@ref{__is_nothrow_assignable}. +@enddefbuiltin + +@anchor{__is_trivially_constructible} +@defbuiltin{bool __is_trivially_constructible (@var{type}, @var{arg_types}...)} +If @code{__is_constructible (type, arg_types...)} is @code{true} and +@code{__is_trivial (type)} is @code{true}, then the trait is @code{true}, +else it is @code{false}. +Requires: Each of @var{type} or @var{arg_types}... being a class type +shall be a complete type. +See also: @ref{__is_trivial}, @ref{__is_constructible}, +@ref{__is_nothrow_constructible}. +@enddefbuiltin + +@anchor{__is_trivially_copyable} +@defbuiltin{bool __is_trivially_copyable (@var{type})} +If @var{type} is a trivially copyable type ([basic.types]), then the trait is +@code{true}, else it is @code{false}. +Requires: @var{type} shall be a complete type, an array of complete types, +or (possibly cv-qualified) @code{void}. +See also: @ref{__is_trivial}. @enddefbuiltin @defbuiltin{bool __is_union (@var{type})} -If @var{type} is a cv union type ([basic.compound]) the trait is +If @var{type} is a cv union type ([basic.compound]), then the trait is @code{true}, else it is @code{false}. @enddefbuiltin -@defbuiltin{bool __underlying_type (@var{type})} -The underlying type of @var{type}. -Requires: @var{type} shall be an enumeration type ([dcl.enum]). +@anchor{__reference_constructs_from_temporary} +@defbuiltin{bool __reference_constructs_from_temporary (@var{type1}, @var{type2})} +If @var{type1} is a reference type and a value of type @var{type2} can be +bound to @var{type1} in direct-initialization, such that a temporary object +would be bound to the reference, then the trait is @code{true}, +else it is @code{false}. +Requires: Each of @var{type1} or @var{type2} being a class type shall be +a complete type. +See also: @ref{__reference_converts_from_temporary} +@enddefbuiltin + +@anchor{__reference_converts_from_temporary} +@defbuiltin{bool __reference_converts_from_temporary (@var{type1}, @var{type2})} +If @var{type1} is a reference type and a value of type @var{type2} can be +bound to @var{type1} in copy-initialization, such that a temporary object +would be bound to the reference, then the trait is @code{true}, +else it is @code{false}. +Requires: Each of @var{type1} or @var{type2} being a class type shall be +a complete type. +See also: @ref{__reference_constructs_from_temporary} +@enddefbuiltin + + +@subsection Type-yielding Type Traits + +Most of these built-ins return a type when invoked; the rest yields +a list of types. + +@anchor{__bases} +@defbuiltin{@var{types}... __bases (@var{type})} +If @var{type} is a class type ([class.derived]), then the trait is a +typelist of the base classes of @var{type}, else it is an empty typelist. +See also: @ref{__direct_bases}. +@enddefbuiltin + +@anchor{__direct_bases} +@defbuiltin{@var{types}... __direct_bases (@var{type})} +If @var{type} is a class type ([class.derived]), then the trait is a +typelist of the direct base classes of @var{type}, else it is an empty +typelist. +See also: @ref{__bases}. +@enddefbuiltin + +@anchor{__remove_cv} +@defbuiltin{@var{type} __remove_cv (@var{cv_type})} +If @var{cv_type} is a cv-qualified type ([basic.type.qualifier]), then the +trait is the type @var{type} of @var{cv_type} with its top-level cv-qualifiers +removed, else it is @var{cv_type}. +See also: @ref{__remove_cvref} +@enddefbuiltin + +@anchor{__remove_cvref} +@defbuiltin{@var{type} __remove_cvref (@var{cvref_type})} +If @var{cvref_type} is a cv-qualified ([basic.type.qualifier]) or reference +type ([dcl.ref]), then the trait is the type @var{type} of +@var{cvref_type} with its top-level cv-qualifiers and reference removed, +else it is @var{cvref_type}. +See also: @ref{__remove_cv}, @ref{__remove_reference}. +@enddefbuiltin + +@defbuiltin{@var{type} __remove_pointer (@var{ptr_type})} +If @var{ptr_type} is a pointer type ([dcl.ptr]), then the trait is the +@var{type} pointed to by @var{ptr_type}, else it is @var{ptr_type}. +@enddefbuiltin + +@anchor{__remove_reference} +@defbuiltin{@var{type} __remove_reference (@var{ref_type})} +If @var{ref_type} is a reference type ([dcl.ref]), then the trait is the +@var{type} referred to by @var{ref_type}, else it is @var{ref_type}. +See also: @ref{__remove_cvref} +@enddefbuiltin + +@defbuiltin{@var{type} __type_pack_element (int @var{index}, @var{types}...)} +If @code{0 < @var{index} < sizeof...(@var{types})}, then the trait is the +@var{index}-th type in the pack @var{types}..., else it emits an error. +@enddefbuiltin + +@defbuiltin{@var{type} __underlying_type (@var{enum_type})} +If @var{enum_type} is a complete enumeration type ([dcl.enum]), then +the trait is the underlying type of @var{enum_type}, else it emits an error. @enddefbuiltin @@ -29708,15 +29970,6 @@ Introduces constraints on template arguments or requirements for a member function of a class template. @end table -The front end also exposes a number of internal mechanism that can be used -to simplify the writing of type traits. Note that some of these traits are -likely to be removed in the future. - -@defbuiltin{bool __is_same (@var{type1}, @var{type2})} -A binary type trait: @code{true} whenever the @var{type1} and -@var{type2} refer to the same type. -@enddefbuiltin - @node Deprecated Features @section Deprecated Features