• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Type Traits - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="C_002b_002b-Extensions.html#C_002b_002b-Extensions" title="C++ Extensions">
9<link rel="prev" href="Namespace-Association.html#Namespace-Association" title="Namespace Association">
10<link rel="next" href="Java-Exceptions.html#Java-Exceptions" title="Java Exceptions">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
152010 Free Software Foundation, Inc.
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with the
20Invariant Sections being ``Funding Free Software'', the Front-Cover
21Texts being (a) (see below), and with the Back-Cover Texts being (b)
22(see below).  A copy of the license is included in the section entitled
23``GNU Free Documentation License''.
24
25(a) The FSF's Front-Cover Text is:
26
27     A GNU Manual
28
29(b) The FSF's Back-Cover Text is:
30
31     You have freedom to copy and modify this GNU Manual, like GNU
32     software.  Copies published by the Free Software Foundation raise
33     funds for GNU development.-->
34<meta http-equiv="Content-Style-Type" content="text/css">
35<style type="text/css"><!--
36  pre.display { font-family:inherit }
37  pre.format  { font-family:inherit }
38  pre.smalldisplay { font-family:inherit; font-size:smaller }
39  pre.smallformat  { font-family:inherit; font-size:smaller }
40  pre.smallexample { font-size:smaller }
41  pre.smalllisp    { font-size:smaller }
42  span.sc    { font-variant:small-caps }
43  span.roman { font-family:serif; font-weight:normal; } 
44  span.sansserif { font-family:sans-serif; font-weight:normal; } 
45--></style>
46<link rel="stylesheet" type="text/css" href="../cs.css">
47</head>
48<body>
49<div class="node">
50<a name="Type-Traits"></a>
51<p>
52Next:&nbsp;<a rel="next" accesskey="n" href="Java-Exceptions.html#Java-Exceptions">Java Exceptions</a>,
53Previous:&nbsp;<a rel="previous" accesskey="p" href="Namespace-Association.html#Namespace-Association">Namespace Association</a>,
54Up:&nbsp;<a rel="up" accesskey="u" href="C_002b_002b-Extensions.html#C_002b_002b-Extensions">C++ Extensions</a>
55<hr>
56</div>
57
58<h3 class="section">7.9 Type Traits</h3>
59
60<p>The C++ front-end implements syntactic extensions that allow to
61determine at compile time various characteristics of a type (or of a
62pair of types).
63
64     <dl>
65<dt><code>__has_nothrow_assign (type)</code><dd>If <code>type</code> is const qualified or is a reference type then the trait is
66false.  Otherwise if <code>__has_trivial_assign (type)</code> is true then the trait
67is true, else if <code>type</code> is a cv class or union type with copy assignment
68operators that are known not to throw an exception then the trait is true,
69else it is false.  Requires: <code>type</code> shall be a complete type,
70(possibly cv-qualified) <code>void</code>, or an array of unknown bound.
71
72     <br><dt><code>__has_nothrow_copy (type)</code><dd>If <code>__has_trivial_copy (type)</code> is true then the trait is true, else if
73<code>type</code> is a cv class or union type with copy constructors that
74are known not to throw an exception then the trait is true, else it is false. 
75Requires: <code>type</code> shall be a complete type, (possibly cv-qualified)
76<code>void</code>, or an array of unknown bound.
77
78     <br><dt><code>__has_nothrow_constructor (type)</code><dd>If <code>__has_trivial_constructor (type)</code> is true then the trait is
79true, else if <code>type</code> is a cv class or union type (or array
80thereof) with a default constructor that is known not to throw an
81exception then the trait is true, else it is false.  Requires:
82<code>type</code> shall be a complete type, (possibly cv-qualified)
83<code>void</code>, or an array of unknown bound.
84
85     <br><dt><code>__has_trivial_assign (type)</code><dd>If <code>type</code> is const qualified or is a reference type then the trait is
86false.  Otherwise if <code>__is_pod (type)</code> is true then the trait is
87true, else if <code>type</code> is a cv class or union type with a trivial
88copy assignment ([class.copy]) then the trait is true, else it is
89false.  Requires: <code>type</code> shall be a complete type, (possibly
90cv-qualified) <code>void</code>, or an array of unknown bound.
91
92     <br><dt><code>__has_trivial_copy (type)</code><dd>If <code>__is_pod (type)</code> is true or <code>type</code> is a reference type
93then the trait is true, else if <code>type</code> is a cv class or union type
94with a trivial copy constructor ([class.copy]) then the trait
95is true, else it is false.  Requires: <code>type</code> shall be a complete
96type, (possibly cv-qualified) <code>void</code>, or an array of unknown bound.
97
98     <br><dt><code>__has_trivial_constructor (type)</code><dd>If <code>__is_pod (type)</code> is true then the trait is true, else if
99<code>type</code> is a cv class or union type (or array thereof) with a
100trivial default constructor ([class.ctor]) then the trait is true,
101else it is false.  Requires: <code>type</code> shall be a complete
102type, (possibly cv-qualified) <code>void</code>, or an array of unknown bound.
103
104     <br><dt><code>__has_trivial_destructor (type)</code><dd>If <code>__is_pod (type)</code> is true or <code>type</code> is a reference type then
105the trait is true, else if <code>type</code> is a cv class or union type (or
106array thereof) with a trivial destructor ([class.dtor]) then the trait
107is true, else it is false.  Requires: <code>type</code> shall be a complete
108type, (possibly cv-qualified) <code>void</code>, or an array of unknown bound.
109
110     <br><dt><code>__has_virtual_destructor (type)</code><dd>If <code>type</code> is a class type with a virtual destructor
111([class.dtor]) then the trait is true, else it is false.  Requires:
112<code>type</code> shall be a complete type, (possibly cv-qualified)
113<code>void</code>, or an array of unknown bound.
114
115     <br><dt><code>__is_abstract (type)</code><dd>If <code>type</code> is an abstract class ([class.abstract]) then the trait
116is true, else it is false.  Requires: <code>type</code> shall be a complete
117type, (possibly cv-qualified) <code>void</code>, or an array of unknown bound.
118
119     <br><dt><code>__is_base_of (base_type, derived_type)</code><dd>If <code>base_type</code> is a base class of <code>derived_type</code>
120([class.derived]) then the trait is true, otherwise it is false. 
121Top-level cv qualifications of <code>base_type</code> and
122<code>derived_type</code> are ignored.  For the purposes of this trait, a
123class type is considered is own base.  Requires: if <code>__is_class
124(base_type)</code> and <code>__is_class (derived_type)</code> are true and
125<code>base_type</code> and <code>derived_type</code> are not the same type
126(disregarding cv-qualifiers), <code>derived_type</code> shall be a complete
127type.  Diagnostic is produced if this requirement is not met.
128
129     <br><dt><code>__is_class (type)</code><dd>If <code>type</code> is a cv class type, and not a union type
130([basic.compound]) the trait is true, else it is false.
131
132     <br><dt><code>__is_empty (type)</code><dd>If <code>__is_class (type)</code> is false then the trait is false. 
133Otherwise <code>type</code> is considered empty if and only if: <code>type</code>
134has no non-static data members, or all non-static data members, if
135any, are bit-fields of length 0, and <code>type</code> has no virtual
136members, and <code>type</code> has no virtual base classes, and <code>type</code>
137has no base classes <code>base_type</code> for which
138<code>__is_empty (base_type)</code> is false.  Requires: <code>type</code> shall
139be a complete type, (possibly cv-qualified) <code>void</code>, or an array
140of unknown bound.
141
142     <br><dt><code>__is_enum (type)</code><dd>If <code>type</code> is a cv enumeration type ([basic.compound]) the trait is
143true, else it is false.
144
145     <br><dt><code>__is_literal_type (type)</code><dd>If <code>type</code> is a literal type ([basic.types]) the trait is
146true, else it is false.  Requires: <code>type</code> shall be a complete type,
147(possibly cv-qualified) <code>void</code>, or an array of unknown bound.
148
149     <br><dt><code>__is_pod (type)</code><dd>If <code>type</code> is a cv POD type ([basic.types]) then the trait is true,
150else it is false.  Requires: <code>type</code> shall be a complete type,
151(possibly cv-qualified) <code>void</code>, or an array of unknown bound.
152
153     <br><dt><code>__is_polymorphic (type)</code><dd>If <code>type</code> is a polymorphic class ([class.virtual]) then the trait
154is true, else it is false.  Requires: <code>type</code> shall be a complete
155type, (possibly cv-qualified) <code>void</code>, or an array of unknown bound.
156
157     <br><dt><code>__is_standard_layout (type)</code><dd>If <code>type</code> is a standard-layout type ([basic.types]) the trait is
158true, else it is false.  Requires: <code>type</code> shall be a complete
159type, (possibly cv-qualified) <code>void</code>, or an array of unknown bound.
160
161     <br><dt><code>__is_trivial (type)</code><dd>If <code>type</code> is a trivial type ([basic.types]) the trait is
162true, else it is false.  Requires: <code>type</code> shall be a complete
163type, (possibly cv-qualified) <code>void</code>, or an array of unknown bound.
164
165     <br><dt><code>__is_union (type)</code><dd>If <code>type</code> is a cv union type ([basic.compound]) the trait is
166true, else it is false.
167
168 </dl>
169
170 </body></html>
171
172