diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-03 21:57:35 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-03 21:57:35 +0000 |
commit | afdf137c50f7f96ef865cf007f660dd663a8731f (patch) | |
tree | 880d81a66bcc4dafedeaa9e8f03c8488f566dc7b /docs/LanguageExtensions.html | |
parent | 67410b34bc82af0d16e3a7b531d260e4ef72ce11 (diff) |
Add __has_feature() for each of the type traits
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LanguageExtensions.html')
-rw-r--r-- | docs/LanguageExtensions.html | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/docs/LanguageExtensions.html b/docs/LanguageExtensions.html index 30c85ffcbd..8b6b96f6f2 100644 --- a/docs/LanguageExtensions.html +++ b/docs/LanguageExtensions.html @@ -46,13 +46,14 @@ td { <li><a href="#cxx_strong_enums">C++0x strongly-typed enumerations</a></li> <li><a href="#cxx_trailing_return">C++0x trailing return type</a></li> </ul> +<li><a href="#checking_type_traits">Checks for Type Traits</a></li> <li><a href="#blocks">Blocks</a></li> <li><a href="#overloading-in-c">Function Overloading in C</a></li> <li><a href="#builtins">Builtin Functions</a> <ul> <li><a href="#__builtin_shufflevector">__builtin_shufflevector</a></li> <li><a href="#__builtin_unreachable">__builtin_unreachable</a></li> - </ul> + </ul> </li> <li><a href="#targetspecific">Target-Specific Extensions</a> <ul> @@ -437,6 +438,46 @@ the alternate function declaration syntax with trailing return type is enabled.< strongly typed, scoped enumerations is enabled.</p> <!-- ======================================================================= --> +<h2 id="checking_type_traits">Checks for Type Traits</h2> +<!-- ======================================================================= --> + +<p>Clang supports the <a hef="http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html">GNU C++ type traits</a> and a subset of the <a href="http://msdn.microsoft.com/en-us/library/ms177194(v=VS.100).aspx">Microsoft Visual C++ Type traits</a>. For each supported type trait <code>__X</code>, <code>__has_feature(X)</code> indicates the presence of the type trait. For example: +<blockquote> +<pre> +#if __has_feature(is_convertible_to) +template<typename From, typename To> +struct is_convertible_to { + static const bool value = __is_convertible_to(From, To); +}; +#else +// Emulate type trait +#endif +</pre> +</blockquote> + +<p>The following type traits are supported by Clang:</p> +<ul> + <li><code>__has_nothrow_assign</code> (GNU, Microsoft)</li> + <li><code>__has_nothrow_copy</code> (GNU, Microsoft)</li> + <li><code>__has_nothrow_constructor</code> (GNU, Microsoft)</li> + <li><code>__has_trivial_assign</code> (GNU, Microsoft)</li> + <li><code>__has_trivial_copy</code> (GNU, Microsoft)</li> + <li><code>__has_trivial_constructor</code> (GNU, Microsoft)</li> + <li><code>__has_trivial_destructor</code> (GNU, Microsoft)</li> + <li><code>__has_virtual_destructor</code> (GNU, Microsoft)</li> + <li><code>__is_abstract</code> (GNU, Microsoft)</li> + <li><code>__is_base_of</code> (GNU, Microsoft)</li> + <li><code>__is_class</code> (GNU, Microsoft)</li> + <li><code>__is_convertible_to</code> (Microsoft)</li> + <li><code>__is_empty</code> (GNU, Microsoft)</li> + <li><code>__is_enum</code> (GNU, Microsoft)</li> + <li><code>__is_pod</code> (GNU, Microsoft)</li> + <li><code>__is_polymorphic</code> (GNU, Microsoft)</li> + <li><code>__is_union</code> (GNU, Microsoft)</li> + <li><code>__is_literal(type)</code>: Determines whether the given type is a literal type</li> +</ul> + +<!-- ======================================================================= --> <h2 id="blocks">Blocks</h2> <!-- ======================================================================= --> |