3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>Support for Compiler Intrinsics
</title>
5 <link rel=
"stylesheet" href=
"../../../../../doc/src/boostbook.css" type=
"text/css">
6 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.77.1">
7 <link rel=
"home" href=
"../index.html" title=
"Chapter 1. Boost.TypeTraits">
8 <link rel=
"up" href=
"../index.html" title=
"Chapter 1. Boost.TypeTraits">
9 <link rel=
"prev" href=
"user_defined.html" title=
"User Defined Specializations">
10 <link rel=
"next" href=
"mpl.html" title=
"MPL Interoperability">
12 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF">
13 <table cellpadding=
"2" width=
"100%"><tr>
14 <td valign=
"top"><img alt=
"Boost C++ Libraries" width=
"277" height=
"86" src=
"../../../../../boost.png"></td>
15 <td align=
"center"><a href=
"../../../../../index.html">Home
</a></td>
16 <td align=
"center"><a href=
"../../../../../libs/libraries.htm">Libraries
</a></td>
17 <td align=
"center"><a href=
"http://www.boost.org/users/people.html">People
</a></td>
18 <td align=
"center"><a href=
"http://www.boost.org/users/faq.html">FAQ
</a></td>
19 <td align=
"center"><a href=
"../../../../../more/index.htm">More
</a></td>
22 <div class=
"spirit-nav">
23 <a accesskey=
"p" href=
"user_defined.html"><img src=
"../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../index.html"><img src=
"../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../index.html"><img src=
"../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"mpl.html"><img src=
"../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h2 class=
"title" style=
"clear: both">
27 <a name=
"boost_typetraits.intrinsics"></a><a class=
"link" href=
"intrinsics.html" title=
"Support for Compiler Intrinsics">Support for Compiler Intrinsics
</a>
28 </h2></div></div></div>
30 There are some traits that can not be implemented within the current C++ language:
31 to make these traits
"just work" with user defined types, some kind
32 of additional help from the compiler is required. Currently (April
2008) Visual
33 C++
8 and
9, GNU GCC
4.3 and MWCW
9 provide at least some of the the necessary
34 intrinsics, and other compilers will no doubt follow in due course.
37 The Following traits classes always need compiler support to do the right thing
38 for all types (but all have safe fallback positions if this support is unavailable):
40 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
42 <a class=
"link" href=
"reference/is_final.html" title=
"is_final">is_final
</a>
45 <a class=
"link" href=
"reference/is_union.html" title=
"is_union">is_union
</a>
48 <a class=
"link" href=
"reference/is_pod.html" title=
"is_pod">is_pod
</a>
51 <a class=
"link" href=
"reference/is_nothrow_move_assignable.html" title=
"is_nothrow_move_assignable">is_nothrow_move_assignable
</a>
54 <a class=
"link" href=
"reference/is_nothrow_move_constructible.html" title=
"is_nothrow_move_constructible">is_nothrow_move_constructible
</a>
57 <a class=
"link" href=
"reference/has_trivial_constructor.html" title=
"has_trivial_constructor">has_trivial_constructor
</a>
60 <a class=
"link" href=
"reference/has_trivial_copy.html" title=
"has_trivial_copy">has_trivial_copy
</a>
63 <a class=
"link" href=
"reference/has_trivial_move_constructor.html" title=
"has_trivial_move_constructor">has_trivial_move_constructor
</a>
66 <a class=
"link" href=
"reference/has_trivial_assign.html" title=
"has_trivial_assign">has_trivial_assign
</a>
69 <a class=
"link" href=
"reference/has_trivial_move_assign.html" title=
"has_trivial_move_assign">has_trivial_move_assign
</a>
72 <a class=
"link" href=
"reference/has_trivial_destructor.html" title=
"has_trivial_destructor">has_trivial_destructor
</a>
75 <a class=
"link" href=
"reference/has_nothrow_constructor.html" title=
"has_nothrow_constructor">has_nothrow_constructor
</a>
78 <a class=
"link" href=
"reference/has_nothrow_copy.html" title=
"has_nothrow_copy">has_nothrow_copy
</a>
81 <a class=
"link" href=
"reference/has_nothrow_assign.html" title=
"has_nothrow_assign">has_nothrow_assign
</a>
84 <a class=
"link" href=
"reference/has_virtual_destructor.html" title=
"has_virtual_destructor">has_virtual_destructor
</a>
88 The following traits classes can't be portably implemented in the C++ language,
89 although in practice, the implementations do in fact do the right thing on
90 all the compilers we know about:
92 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
94 <a class=
"link" href=
"reference/is_empty.html" title=
"is_empty">is_empty
</a>
97 <a class=
"link" href=
"reference/is_polymorphic.html" title=
"is_polymorphic">is_polymorphic
</a>
100 <a class=
"link" href=
"reference/is_virtual_base_of.html" title=
"is_virtual_base_of">is_virtual_base_of
</a>
104 The following traits classes are dependent on one or more of the above:
106 <div class=
"itemizedlist"><ul class=
"itemizedlist" style=
"list-style-type: disc; ">
107 <li class=
"listitem">
108 <a class=
"link" href=
"reference/is_class.html" title=
"is_class">is_class
</a>
110 <li class=
"listitem">
111 <a class=
"link" href=
"reference/is_stateless.html" title=
"is_stateless">is_stateless
</a>
115 The hooks for compiler-intrinsic support are defined in
<a href=
"../../../../../boost/type_traits/intrinsics.hpp" target=
"_top">boost/type_traits/intrinsics.hpp
</a>,
116 adding support for new compilers is simply a matter of defining one of more
117 of the following macros:
120 <a name=
"boost_typetraits.intrinsics.macros_for_compiler_intrinsics"></a><p class=
"title"><b>Table
 1.9.
 Macros for Compiler Intrinsics
</b></p>
121 <div class=
"table-contents"><table class=
"table" summary=
"Macros for Compiler Intrinsics">
129 BOOST_ALIGNMENT_OF(T)
134 Should evaluate to the alignment requirements of type T
147 Should evaluate to true if T is an abstract type
154 BOOST_IS_BASE_OF(T,U)
159 Should evaluate to true if T is a base class of U
171 Should evaluate to true if T is a class type
178 BOOST_IS_CONVERTIBLE(T,U)
183 Should evaluate to true if T is convertible to U
195 Should evaluate to true if T is an empty struct or union
207 Should evaluate to true is T is an enum
219 Should evaluate to true if T is a class type declared with the final
227 BOOST_IS_NOTHROW_MOVE_ASSIGN(T)
232 Should evaluate to true T has a non-throwing move assign operator.
239 BOOST_IS_NOTHROW_MOVE_CONSTRUCT(T)
244 Should evaluate to true T has a non-throwing move constructor.
251 BOOST_IS_POLYMORPHIC(T)
256 Should evaluate to true if T is a polymorphic type
268 Should evaluate to true if T is a POD type
280 Should evaluate to true if T is a union type
287 BOOST_HAS_NOTHROW_ASSIGN(T)
292 Should evaluate to true if
<code class=
"computeroutput"><span class=
"identifier">T
</span>
293 <span class=
"identifier">t
</span><span class=
"special">,
</span>
294 <span class=
"identifier">u
</span><span class=
"special">;
</span>
295 <span class=
"identifier">t
</span> <span class=
"special">=
</span>
296 <span class=
"identifier">u
</span></code> can not throw
303 BOOST_HAS_NOTHROW_CONSTRUCTOR(T)
308 Should evaluate to true if
<code class=
"computeroutput"><span class=
"identifier">T
</span>
309 <span class=
"identifier">x
</span><span class=
"special">;
</span></code>
317 BOOST_HAS_NOTHROW_COPY(T)
322 Should evaluate to true if
<code class=
"computeroutput"><span class=
"identifier">T
</span><span class=
"special">(
</span><span class=
"identifier">t
</span><span class=
"special">)
</span></code> can not throw
329 BOOST_HAS_TRIVIAL_ASSIGN(T)
334 Should evaluate to true if T has a trivial assignment operator (and
335 can therefore be replaced by a call to memcpy)
342 BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)
347 Should evaluate to true if the default constructor for T is trivial
355 BOOST_HAS_TRIVIAL_COPY(T)
360 Should evaluate to true if T has a trivial copy constructor (and
361 can therefore be replaced by a call to memcpy)
368 BOOST_HAS_TRIVIAL_DESTRUCTOR(T)
373 Should evaluate to true if T has a trivial destructor (i.e. ~T()
381 BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T)
386 Should evaluate to true if T has a trivial move constructor (and
387 can therefore be replaced by a call to memcpy)
394 BOOST_HAS_TRIVIAL_MOVE_ASSIGN(T)
399 Should evaluate to true if T has a trivial move assignment operator
400 (and can therefore be replaced by a call to memcpy)
407 BOOST_HAS_VIRTUAL_DESTRUCTOR(T)
412 Should evaluate to true T has a virtual destructor
419 <br class=
"table-break">
421 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
422 <td align=
"left"></td>
423 <td align=
"right"><div class=
"copyright-footer">Copyright
© 2000,
2011 Adobe Systems Inc, David Abrahams,
424 Frederic Bron, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant,
425 Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten
426 Ottosen, Roman Perepelitsa, Robert Ramey, Jeremy Siek, Robert Stewart and Steven
428 Distributed under the Boost Software License, Version
1.0. (See accompanying
429 file LICENSE_1_0.txt or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt" target=
"_top">http://www.boost.org/LICENSE_1_0.txt
</a>)
434 <div class=
"spirit-nav">
435 <a accesskey=
"p" href=
"user_defined.html"><img src=
"../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../index.html"><img src=
"../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../index.html"><img src=
"../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"mpl.html"><img src=
"../../../../../doc/src/images/next.png" alt=
"Next"></a>