From e66ffd9a993396d95871d600e56d8bf3bb0f5fb8 Mon Sep 17 00:00:00 2001
From: John Maddock
Date: Sat, 11 Sep 2010 18:00:56 +0000
Subject: [PATCH] Add new traits add_lvalue_reference and add_rvalue_reference.
[SVN r65387]
---
doc/add_lvalue_reference.qbk | 47 +++++++++++
doc/add_reference.qbk | 6 ++
doc/add_rvalue_reference.qbk | 50 ++++++++++++
doc/html/boost_typetraits/background.html | 22 ++---
.../boost_typetraits/category/transform.html | 8 +-
doc/html/boost_typetraits/history.html | 4 +-
doc/html/boost_typetraits/intrinsics.html | 2 +-
doc/html/boost_typetraits/reference.html | 2 +
.../boost_typetraits/reference/add_const.html | 2 +-
.../boost_typetraits/reference/add_cv.html | 8 +-
.../reference/add_pointer.html | 8 +-
.../reference/add_reference.html | 20 ++++-
.../reference/add_volatile.html | 8 +-
.../boost_typetraits/reference/decay.html | 2 +-
.../reference/floating_point_promotion.html | 2 +-
.../reference/function_traits.html | 4 +-
.../reference/integral_promotion.html | 2 +-
.../reference/make_signed.html | 2 +-
.../reference/make_unsigned.html | 2 +-
.../boost_typetraits/reference/promote.html | 2 +-
.../reference/remove_all_extents.html | 2 +-
.../reference/remove_const.html | 2 +-
.../boost_typetraits/reference/remove_cv.html | 2 +-
.../reference/remove_extent.html | 2 +-
.../reference/remove_pointer.html | 2 +-
.../reference/remove_reference.html | 2 +-
.../reference/remove_volatile.html | 2 +-
doc/html/index.html | 4 +-
doc/transform_traits.qbk | 6 ++
doc/type_traits.qbk | 4 +
.../type_traits/add_lvalue_reference.hpp | 26 ++++++
.../type_traits/add_rvalue_reference.hpp | 67 ++++++++++++++++
test/add_lvalue_reference_test.cpp | 63 +++++++++++++++
test/add_rvalue_reference_test.cpp | 80 +++++++++++++++++++
34 files changed, 419 insertions(+), 48 deletions(-)
create mode 100644 doc/add_lvalue_reference.qbk
create mode 100644 doc/add_rvalue_reference.qbk
create mode 100644 include/boost/type_traits/add_lvalue_reference.hpp
create mode 100644 include/boost/type_traits/add_rvalue_reference.hpp
create mode 100644 test/add_lvalue_reference_test.cpp
create mode 100644 test/add_rvalue_reference_test.cpp
diff --git a/doc/add_lvalue_reference.qbk b/doc/add_lvalue_reference.qbk
new file mode 100644
index 0000000..4416816
--- /dev/null
+++ b/doc/add_lvalue_reference.qbk
@@ -0,0 +1,47 @@
+[/
+ Copyright 2010 John Maddock.
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt).
+]
+
+[section:add_lvalue_reference add_lvalue_reference]
+
+ template
+ struct add_lvalue_reference
+ {
+ typedef __below type;
+ };
+
+__type If `T` names an object or function type then the member typedef `type`
+shall name `T&`; otherwise, if `T` names a type ['rvalue reference to U] then
+the member typedef type shall name `U&`; otherwise, type shall name `T`.
+
+__std_ref 20.7.6.2.
+
+__compat If the compiler does not support partial specialization of class-templates
+then this template will compile, but the member `type` will always be the same as
+type `T` except where __transform_workaround have been applied.
+
+__header ` #include ` or ` #include `
+
+[table Examples
+
+[ [Expression] [Result Type]]
+
+[[`add_lvalue_reference::type`][`int&`]]
+
+[[`add_lvalue_reference::type`] [`int const&`]]
+
+[[`add_lvalue_reference::type`] [`int*&`]]
+
+[[`add_lvalue_reference::type`] [`int*&`]]
+
+[[`add_lvalue_reference::type`][`int&`]]
+
+[[`add_lvalue_reference::type`][`void`]]
+
+]
+
+[endsect]
+
diff --git a/doc/add_reference.qbk b/doc/add_reference.qbk
index fd37bd6..a36e59d 100644
--- a/doc/add_reference.qbk
+++ b/doc/add_reference.qbk
@@ -7,6 +7,12 @@
[section:add_reference add_reference]
+[note This trait has been made obsolete by __add_lvalue_reference and __add_rvalue_reference,
+and new code should use these new traits rather than __is_reference which is retained
+for backwards compatibility only.
+]
+
+
template
struct add_reference
{
diff --git a/doc/add_rvalue_reference.qbk b/doc/add_rvalue_reference.qbk
new file mode 100644
index 0000000..e3f561b
--- /dev/null
+++ b/doc/add_rvalue_reference.qbk
@@ -0,0 +1,50 @@
+[/
+ Copyright 2010 John Maddock.
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt).
+]
+
+[section:add_rvalue_reference add_rvalue_reference]
+
+ template
+ struct add_rvalue_reference
+ {
+ typedef __below type;
+ };
+
+__type If `T` names an object or function type then the member typedef type
+shall name `T&&`; otherwise, type shall name `T`. ['\[Note: This rule reflects
+the semantics of reference collapsing. For example, when a type `T` names
+a type U&, the type `add_rvalue_reference::type` is not an rvalue
+reference. -end note\]].
+
+__std_ref 20.7.6.2.
+
+__compat If the compiler does not support partial specialization of class-templates
+and rvalue references
+then this template will compile, but the member `type` will always be the same as
+type `T`.
+
+__header ` #include ` or ` #include `
+
+[table Examples
+
+[ [Expression] [Result Type]]
+
+[[`add_rvalue_reference::type`][`int&&`]]
+
+[[`add_rvalue_reference::type`] [`int const&`]]
+
+[[`add_rvalue_reference::type`] [`int*&&`]]
+
+[[`add_rvalue_reference::type`] [`int*&`]]
+
+[[`add_rvalue_reference::type`][`int&&`]]
+
+[[`add_rvalue_reference::type`][`void`]]
+
+]
+
+[endsect]
+
diff --git a/doc/html/boost_typetraits/background.html b/doc/html/boost_typetraits/background.html
index cb8e3e2..9c24e88 100644
--- a/doc/html/boost_typetraits/background.html
+++ b/doc/html/boost_typetraits/background.html
@@ -56,7 +56,7 @@
method available to them.
@@ -84,7 +84,7 @@
given.
@@ -174,7 +174,7 @@
in the default template.
@@ -247,7 +247,7 @@
otherwise it will call the "slow but safe version".
@@ -280,7 +280,7 @@
-
Table 1.1. Time taken to copy 1000 elements using `copy<const T*, T*>` (times
+
Table 1.1. Time taken to copy 1000 elements using `copy<const T*, T*>` (times
in micro-seconds)
@@ -416,7 +416,7 @@
to hold non-reference types, references, and constant references:
-
Table 1.2. Required Constructor Argument Types
+
Table 1.2. Required Constructor Argument Types
@@ -481,7 +481,7 @@
adds a reference to its type, unless it is already a reference.
-
Table 1.3. Using add_reference to synthesize the correct constructor type
+
Table 1.3. Using add_reference to synthesize the correct constructor type
@@ -597,7 +597,7 @@
easier to maintain and easier to understand.
@@ -610,7 +610,7 @@
can be optimal as well as generic.
@@ -618,7 +618,7 @@
comments when preparing this article.
diff --git a/doc/html/boost_typetraits/category/transform.html b/doc/html/boost_typetraits/category/transform.html
index eb81b03..09fd6bf 100644
--- a/doc/html/boost_typetraits/category/transform.html
+++ b/doc/html/boost_typetraits/category/transform.html
@@ -42,12 +42,18 @@
template < class T >
struct add_cv ;
+template < class T >
+struct add_lvalue_reference ;
+
template < class T >
struct add_pointer ;
template < class T >
struct add_reference ;
+template < class T >
+struct add_rvalue_reference ;
+
template < class T >
struct add_volatile ;
@@ -91,7 +97,7 @@
struct remove_volatile ;
diff --git a/doc/html/boost_typetraits/history.html b/doc/html/boost_typetraits/history.html
index d1923ff..2ba39c1 100644
--- a/doc/html/boost_typetraits/history.html
+++ b/doc/html/boost_typetraits/history.html
@@ -27,7 +27,7 @@
History
diff --git a/doc/html/boost_typetraits/intrinsics.html b/doc/html/boost_typetraits/intrinsics.html
index b89d232..493a7c9 100644
--- a/doc/html/boost_typetraits/intrinsics.html
+++ b/doc/html/boost_typetraits/intrinsics.html
@@ -99,7 +99,7 @@
of the following macros:
-
Table 1.4. Macros for Compiler Intrinsics
+
Table 1.4. Macros for Compiler Intrinsics
diff --git a/doc/html/boost_typetraits/reference.html b/doc/html/boost_typetraits/reference.html
index 8bd4ae8..168559c 100644
--- a/doc/html/boost_typetraits/reference.html
+++ b/doc/html/boost_typetraits/reference.html
@@ -29,8 +29,10 @@
add_const
add_cv
+ add_lvalue_reference
add_pointer
add_reference
+ add_rvalue_reference
add_volatile
aligned_storage
alignment_of
diff --git a/doc/html/boost_typetraits/reference/add_const.html b/doc/html/boost_typetraits/reference/add_const.html
index db48dad..90a2851 100644
--- a/doc/html/boost_typetraits/reference/add_const.html
+++ b/doc/html/boost_typetraits/reference/add_const.html
@@ -53,7 +53,7 @@
or #include < boost / type_traits . hpp >
-
Table 1.5. Examples
+
Table 1.5. Examples
diff --git a/doc/html/boost_typetraits/reference/add_cv.html b/doc/html/boost_typetraits/reference/add_cv.html
index e071c71..34ca868 100644
--- a/doc/html/boost_typetraits/reference/add_cv.html
+++ b/doc/html/boost_typetraits/reference/add_cv.html
@@ -7,7 +7,7 @@
-
+
@@ -54,7 +54,7 @@
or #include < boost / type_traits . hpp >
-
Table 1.6. Examples
+
Table 1.6. Examples