forked from boostorg/type_traits
Added new type traits files.
[SVN r9238]
This commit is contained in:
1 parent
6fda1821b2
commit
f3976d8060
32 files changed
+6095
-24
No files matched your search
@@ -1,5 +1,5 @@
|
||||
|
||||
// (C) Copyright John Maddock 2000.
|
||||
// (C) Copyright John Maddock and Steve Cleary 2000.
|
||||
// Permission to copy, use, modify, sell and
|
||||
// distribute this software is granted provided this copyright notice appears
|
||||
// in all copies. This software is provided "as is" without express or implied
|
||||
@@ -73,3 +73,4 @@ struct ice_and<true, true, true, true, true, true, true>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
||||
// (C) Copyright Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant & John Maddock 2000.
|
||||
// Permission to copy, use, modify, sell and
|
||||
// distribute this software is granted provided this copyright notice appears
|
||||
// in all copies. This software is provided "as is" without express or implied
|
||||
@@ -87,3 +87,4 @@ public:
|
||||
#endif // SAME_TRAITS_HPP
|
||||
|
||||
|
||||
|
||||
@@ -175,6 +175,8 @@ public:
|
||||
// include a bunch of full specialisations as a workaround:
|
||||
//
|
||||
#include <boost/type_traits/transform_traits_spec.hpp>
|
||||
#else
|
||||
#define BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(x)
|
||||
#endif
|
||||
|
||||
#endif // TRANSFORM_TRAITS_HPP
|
||||
@@ -182,3 +184,4 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
#ifndef BOOST_TT_TRANSFORM_TRAITS_SPEC_HPP
|
||||
#define BOOST_TT_TRANSFORM_TRAITS_SPEC_HPP
|
||||
|
||||
#ifndef TRANSFORM_TRAITS_HPP
|
||||
#include <boost/type_traits/transform_traits.hpp>
|
||||
#endif
|
||||
@@ -67,9 +70,5 @@ BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(float)
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(double)
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(long double)
|
||||
|
||||
#undef BOOST_TYPE_TRAITS_SPECIALIZATION_REMOVE_CONST_VOLATILE_RANK1
|
||||
#undef BOOST_TYPE_TRAITS_SPECIALIZATION_REMOVE_PTR_REF_RANK_1
|
||||
#undef BOOST_TYPE_TRAITS_SPECIALIZATION_REMOVE_PTR_REF_RANK_2
|
||||
#undef BOOST_TYPE_TRAITS_SPECIALIZATION_REMOVE_ALL_RANK_1
|
||||
#undef BOOST_TYPE_TRAITS_SPECIALIZATION_REMOVE_ALL_RANK_2
|
||||
#endif // BOOST_TT_TRANSFORM_TRAITS_SPEC_HPP
|
||||
|
||||
+66
-9
@@ -5,7 +5,7 @@
|
||||
content="text/html; charset=iso-8859-1">
|
||||
<meta name="Template"
|
||||
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
|
||||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
||||
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
|
||||
<title>Type Traits</title>
|
||||
</head>
|
||||
|
||||
@@ -471,8 +471,8 @@ relationship between two types:</p>
|
||||
<p align="center">8.5</p>
|
||||
</td>
|
||||
<td valign="top" width="25%" bgcolor="#C0C0C0">Note that
|
||||
this template is currently broken with Borland's compiler,
|
||||
for constructor-based conversions.</td>
|
||||
this template is currently broken with Borland's
|
||||
compiler, for constructor-based conversions.</td>
|
||||
<td valign="top" width="5%"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -595,7 +595,64 @@ transformation to the template argument T:</p>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p> </p>
|
||||
<p>As the table above indicates, support for partial
|
||||
specialization of class templates is required to correctly
|
||||
implement the type transformation templates. On the other hand,
|
||||
practice shows that many of the templates from this category are
|
||||
very useful, and often essential for implementing some generic
|
||||
libraries. Lack of these templates is often one of the major
|
||||
limiting factors in porting those libraries to compilers that do
|
||||
not yet support this language feature. As some of these compilers
|
||||
are going to be around for a while, and at least one of them is
|
||||
very wide-spread, it was decided that the library should provide
|
||||
workarounds where possible. The basic idea behind the workaround
|
||||
is</p>
|
||||
|
||||
<ol>
|
||||
<li>To manually define full specializations of all type
|
||||
transformation templates for all fundamental types, and
|
||||
all their 1st and 2nd rank cv-[un]qualified derivative
|
||||
pointer types, and to</li>
|
||||
<li>Provide a user-level macro that will define such explicit
|
||||
specializations for any user-defined type T.</li>
|
||||
</ol>
|
||||
|
||||
<p>The first part guarantees the successful compilation of
|
||||
something like this:</p>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<char, remove_reference<char&>::type>::value));</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<char const, remove_reference<char const&>::type>::value));</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<char volatile, remove_reference<char volatile&>::type>::value));</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<char const volatile, remove_reference<char const volatile&>::type>::value));</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<char*, remove_reference<char*&>::type>::value));</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<char const*, remove_reference<char const*&>::type>::value));</pre>
|
||||
|
||||
<pre>...</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<char const volatile* const volatile* const volatile, remove_reference<char const volatile* const volatile* const volatile&>::type>::value));</pre>
|
||||
|
||||
<p>and the second part provides library's users with a mechanism
|
||||
to make the above code work not only for 'char', 'int' or other
|
||||
built-in type, but for they own types too:</p>
|
||||
|
||||
<pre>struct my {};</pre>
|
||||
|
||||
<pre>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(my)</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<my, remove_reference<my&>::type>::value));</pre>
|
||||
|
||||
<pre>BOOST_STATIC_ASSERT((is_same<my, remove_const<my const>::type>::value));</pre>
|
||||
|
||||
<pre>// etc.</pre>
|
||||
|
||||
<p>Note that the maco
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION evaluates to
|
||||
nothing on those compilers that do support partial specialisation.</p>
|
||||
|
||||
<h2><a name="compiler"></a>Compiler Support Information</h2>
|
||||
|
||||
@@ -637,11 +694,11 @@ happen if: T is a union or T is a compiler-supplied scalar type
|
||||
that is not specialised for in these type traits.</p>
|
||||
|
||||
<p><i>If there is no compiler support</i>, to ensure that these
|
||||
traits <i>always</i> return the correct values, specialise 'is_union'
|
||||
for each user-defined union type, 'is_empty' for each user-defined
|
||||
empty composite type, and 'is_POD' for each user-defined POD type.
|
||||
The 'has_*' traits should also be specialized if the user-defined
|
||||
type has those traits and is <i>not</i> a POD.</p>
|
||||
traits <i>always</i> return the correct values, specialise
|
||||
'is_union' for each user-defined union type, 'is_empty' for each
|
||||
user-defined empty composite type, and 'is_POD' for each user-defined
|
||||
POD type. The 'has_*' traits should also be specialized if the
|
||||
user-defined type has those traits and is <i>not</i> a POD.</p>
|
||||
|
||||
<p>The following rules are automatically enforced:</p>
|
||||
|
||||
|
||||
Reference in new issue
Block a user