|
Boost-Commit : |
From: asutton_at_[hidden]
Date: 2007-08-13 19:18:16
Author: asutton
Date: 2007-08-13 19:18:14 EDT (Mon, 13 Aug 2007)
New Revision: 38637
URL: http://svn.boost.org/trac/boost/changeset/38637
Log:
More (subtle) revisions to concept docs
Text files modified:
sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/assignable.qbk | 44 ++++++++++++++++++++++++++-------------
sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/copy_constructible.qbk | 33 ++++++++++++++++++++----------
sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/default_constructible.qbk | 8 +++---
3 files changed, 55 insertions(+), 30 deletions(-)
Modified: sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/assignable.qbk
==============================================================================
--- sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/assignable.qbk (original)
+++ sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/assignable.qbk 2007-08-13 19:18:14 EDT (Mon, 13 Aug 2007)
@@ -6,9 +6,17 @@
/]
[section Assignable]
-A type `T` is said to be /assignable/ if the value of one instance, `u`, can be copied
-to the value of another, `t` through an assignment expression. The type of `u` must
-be `T` or `const T`.
+A type `T` is /assignable/ if an object of type `T` can be assigned
+the value of another object `u` using the assignment operator. The type
+of `u` is either `T` or `const T`. A type `T` is assignable if it has
+a compiler-generated or user-defined assignment operator. After the
+assignment the object `t` is equivalent to `u`.
+
+[note
+This type of assignment is properly referred to as /copy assignment/
+since, after the copy operation since both assignment operators and
+constructors can be provided for types that are not `T` or `const T`.
+]
[heading Notation]
[table
@@ -24,22 +32,28 @@
[
[`t = u`]
[`T&`]
- [`t` is equivalent to `u`.]
+ [
+ Assigns the object `u` to the object `t`.
+
+ *Requirements:* The type of `u` is either `T` or `const T`.
+
+ *Postconditions:* `t` is equivalent to `u`.
+ ]
]
]
-[heading C++0x]
-In the next version of the C++ standards, the [StdAssignable] concept has been refined
-into a set of two distinct concepts: `CopyAssignable` and `MoveAssignable`. The
-`CopyAssignable` concept is defined as:
-
- auto concept CopyAssignable<typename T, typename U = T>
+[heading Examples]
+A type `T` is required to be [StdAssignable] when an object of type `T` is
+assigned to an object of type `T` or `const T`.
+
+ // This function requires T to be ``[StdAssignable]`` because it assigns
+ // an object of type `T` to the value of another object of the same type.
+ // If T is not assignable, calling this function will result in a compiler
+ // error.
+ template <typename T>
+ void assign(T& t, const T& u)
{
- typename result_type;
- result_type operator =(T&, const U&);
+ t = u;
}
-The `result_type` associated type is used to indicate that the return type is not
-required (as above) to be `T&` and could be any type.
-
[endsect]
\ No newline at end of file
Modified: sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/copy_constructible.qbk
==============================================================================
--- sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/copy_constructible.qbk (original)
+++ sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/copy_constructible.qbk 2007-08-13 19:18:14 EDT (Mon, 13 Aug 2007)
@@ -6,11 +6,12 @@
/]
[section Copy Constructible]
-A type `T` is /copy constructible/ if it is possible to create copies of an
-object that type using a copy constructor. `T` is only copy constructible
-if it has either a compiler-generated or user-defined copy constructor that
-accepts a single argument: a `const` reference to `T`. After construction,
-a constructed object is equivalent to the object passed as an argument.
+A type `T` is /copy constructible/ if it an object `t` of type `T` can
+be constructed as a copy of another object `u`. The type of `u` is either
+`T` or `const T`. A type `T` is only copy constructible if it has either a
+compiler-generated or user-defined copy constructor that accepts a single
+argument: a `const` reference to `T`. After copy construction, the
+constructed object is equivalent to the object passed as an argument.
[note
Two objects `t` and `u` are equivalent if the expression `t == u` returns
@@ -26,7 +27,7 @@
[[Expression] [Description]]
[[T] [A [StdCopyConstructible] type.]]
[[t] [An object of type `T`.]]
- [[u] [An object of type `T` or `const T`]]
+ [[u] [An object of type `T` or `const T`.]]
]
[heading Requirements]
@@ -35,7 +36,7 @@
[
[Copy Constructor]
[
- `T t(u);` [br/]
+ `T t(u);`[br/]
`T t = u;`
]
[]
@@ -68,14 +69,24 @@
is when the copy constructor of `T` is invoked passing another object of
type `T` as an argument.
- // This function requires `T` to be copy constructible because it declares
- // an object of type T constructed with the value of u. If T is not
- // ``[StdCopyConstructible]``, calling this function will result in a
- // compiler error.
+ // This function requires T to be ``[StdCopyConstructible]`` because
+ // it declares an object of type T constructed with the value of u. If
+ // T is not ``[StdCopyConstructible]``, calling this function will
+ // result in a compiler error.
template <typename T>
void copy_declare(const T& u)
{
T t(u);
}
+
+ // This function requires T to be ``[StdCopyConstructible]`` because
+ // it explitcly constructs a copy of an object of the same type. If
+ // T is not ``[StdCopyConstructible]``, then calling this function will
+ // result in a compiler error.
+ template <typename T>
+ T copy_construct(const T& u)
+ {
+ return T(u);
+ }
[endsect]
\ No newline at end of file
Modified: sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/default_constructible.qbk
==============================================================================
--- sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/default_constructible.qbk (original)
+++ sandbox/boost_docs/trunk/libs/standard/doc/concepts/utilities/default_constructible.qbk 2007-08-13 19:18:14 EDT (Mon, 13 Aug 2007)
@@ -64,8 +64,8 @@
// This functions requires T to be ``[StdDefaultConstructible]`` because it
// declares an object of type T without providing any arguments to the default
- // constructor. If T is not default constructible, calling this function will
- // result in a compiler error.
+ // constructor. If T is not ``[StdDefaultConstructible]``, calling this function
+ // will result in a compiler error.
template <typename T>
void default_declare()
{
@@ -74,8 +74,8 @@
// This function requires T to be ``[StdDefaultConstructible]`` because it
// explicitly invokes a constructor of T wihtout any arguments. If T is not
- // default constructible, calling this function will result in a compiler
- // error.
+ // ``[StdDefaultConstructible]``, calling this function will result in a
+ // compiler error.
template <typename T>
T default_construct()
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk