[boost-doc-zh] r391 committed - 翻译 optional 库的 qbk 文件并生成 html 目录

  • From: boost-doc-zh@xxxxxxxxxxxxxx
  • To: boost-doc-zh-notify@xxxxxxxxxxxxx
  • Date: Wed, 24 Mar 2010 07:55:55 +0000

Revision: 391
Author: alai04
Date: Wed Mar 24 00:54:49 2010
Log: 翻译 optional 库的 qbk 文件并生成 html 目录
http://code.google.com/p/boost-doc-zh/source/detail?r=391

Modified:
 /trunk/libs/optional/doc/acknowledgments.qbk
 /trunk/libs/optional/doc/dependencies.qbk
 /trunk/libs/optional/doc/development.qbk
 /trunk/libs/optional/doc/examples.qbk
/trunk/libs/optional/doc/html/boost_optional/a_note_about_optional_bool_.html
 /trunk/libs/optional/doc/html/boost_optional/acknowledgments.html
/trunk/libs/optional/doc/html/boost_optional/dependencies_and_portability.html
 /trunk/libs/optional/doc/html/boost_optional/detailed_semantics.html
 /trunk/libs/optional/doc/html/boost_optional/development.html
 /trunk/libs/optional/doc/html/boost_optional/examples.html
/trunk/libs/optional/doc/html/boost_optional/exception_safety_guarantees.html
 /trunk/libs/optional/doc/html/boost_optional/implementation_notes.html
 /trunk/libs/optional/doc/html/boost_optional/in_place_factories.html
 /trunk/libs/optional/doc/html/boost_optional/optional_references.html
/trunk/libs/optional/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html
 /trunk/libs/optional/doc/html/boost_optional/synopsis.html
 /trunk/libs/optional/doc/html/boost_optional/type_requirements.html
 /trunk/libs/optional/doc/html/index.html
 /trunk/libs/optional/doc/implementation_notes.qbk
 /trunk/libs/optional/doc/optional.qbk
 /trunk/libs/optional/doc/reference.qbk
 /trunk/libs/optional/doc/special_cases.qbk

=======================================
--- /trunk/libs/optional/doc/acknowledgments.qbk        Mon Feb  8 07:24:10 2010
+++ /trunk/libs/optional/doc/acknowledgments.qbk        Wed Mar 24 00:54:49 2010
@@ -9,7 +9,7 @@
 ]


-[section Acknowledgments]
+[section:acknowledgments Acknowledgments 鸣谢]

 [heading Pre-formal review]

=======================================
--- /trunk/libs/optional/doc/dependencies.qbk   Mon Feb  8 07:24:10 2010
+++ /trunk/libs/optional/doc/dependencies.qbk   Wed Mar 24 00:54:49 2010
@@ -9,9 +9,10 @@
 ]


-[section Dependencies and Portability]
+[section:dependencies_and_portability Dependencies and Portability 依赖性和 可移植性]

 The implementation uses `type_traits/alignment_of.hpp` and
-`type_traits/type_with_alignment.hpp`
+`type_traits/type_with_alignment.hpp`\n
+该实现使用了 `type_traits/alignment_of.hpp` 和 `type_traits/type_with_alignment.hpp`

 [endsect]
=======================================
--- /trunk/libs/optional/doc/development.qbk    Mon Feb  8 07:24:10 2010
+++ /trunk/libs/optional/doc/development.qbk    Wed Mar 24 00:54:49 2010
@@ -8,9 +8,9 @@
     http://www.boost.org/LICENSE_1_0.txt)
 ]

-[section Development]
-
-[section The models]
+[section:development Development 发展]
+
+[section:the_models The models 模型]

In C++, we can ['declare] an object (a variable) of type `T`, and we can give this
 variable an ['initial value] (through an ['initializer]. (c.f. 8.5)).
@@ -29,7 +29,16 @@
is formally ['undefined behavior] to try to access the value of an uninitialized optional. An uninitialized optional can be assigned a value, in which case its initialization state changes to initialized. Furthermore, given the formal treatment of initialization states in optional objects, it is even possible to
-reset an optional to ['uninitialized].
+reset an optional to ['uninitialized].\n
+在C++中,我们可以['声明]类型 `T` 的一个对象(变量),并且我们可以给这个对象一 个['初始值](通过['初始化](参考 8.5))。
+当一个声明中包含非空的初始化(即给出一个初始值),就称这个对象已被初始化。
+如果一个声明使用了空的初始化(即未给出初始值),而且也没缺省值可用于初始 化,则称该对象是[*未初始化的]。
+它的真实值是存在的,但具有一个['不确定的初始值](参考 8.5.9)。
+`optional<T>` 的目的是规范初始化(或无初始化)的概念,让程序可以检测一个对象 是否已初始化, +并规定访问一个未初始化对象的值是未定义的行为。即,如果一个变量被声明为 `optional<T>` 而未给定初始值,则该变量就是['正式的]未初始化。 +一个正式的未初始化的 optional 对象是没有值的,并且可以在运行期对此状态进行 测试。 +尝试访问一个未初始化的 optional 被正式规定为['未定义行为]。一个未初始化的 optional 可以被赋予一个值,这时它的初始化状态就会变为已初始化。 +此外,还给出处理 optional 对象的初始化状态的方法,甚至可以将一个 optional 重新置为['未初始化]。

 In C++ there is no formal notion of uninitialized objects, which means that
 objects always have an initial value even if indeterminate.
@@ -45,59 +54,90 @@
Using the __BOOST_VARIANT__ library, this model can be implemented in terms of `boost::variant<T,nil_t>`. There is precedent for a discriminated union as a model for an optional value: the __HASKELL__ [*Maybe] built-in type constructor. Thus, a discriminated union
-`T+nil_t` serves as a conceptual foundation.
+`T+nil_t` serves as a conceptual foundation.\n
+在C++里没有未初始化对象的正式概念,即是说对象总是带有初始值的,即使是不确定 的值。 +正如前面所讨论的,这样有一个缺点,因为你需要用额外的信息来告知一个对象是不 是已经被有效地初始化了。 +一种以前常用的典型方法是使用特殊值:`EOF`, `npos`, -1, 等等... 这相当于增加 一个特殊值到给定类型的可取值的集合中。 +由 `T` 加上某个 ['nil_t] -- `nil_t` 是某个无状态的POD -- 组成的超集在现代语 言中可以被模仿为由 T 和 nil_t 组成的一个[*可识别联合]。 +可识别联合通常称为 ['variants]. 一个 variant 具有 ['当前类型],在我们的例子 中就是 `T` 或者 `nil_t`. +使用 __BOOST_VARIANT__ 库,以上模型可以用 `boost::variant<T,nil_t>` 来实 现。 +用可识别联合来模仿一个 optional 值是有先例的:__HASKELL__ 的 [*Maybe] 内建 类型构造器。
+所以,可识别联合 `T+nil_t` 可以作为一个概念上的基础。

A `variant<T,nil_t>` follows naturally from the traditional idiom of extending
 the range of possible values adding an additional sentinel value with the
special meaning of ['Nothing]. However, this additional ['Nothing] value is largely
 irrelevant for our purpose since our goal is to formalize the notion of
uninitialized objects and, while a special extended value can be used to convey
-that meaning, it is not strictly necessary in order to do so.
+that meaning, it is not strictly necessary in order to do so.\n
+`variant<T,nil_t>` 自然而然地可用于扩展可取值的传统惯用法,它增加一个"哨 兵"值用于表示['空值]。 +不过,这个新增的['空值]与我们意图大不相关,因为我们的目标是规范化未初始化对 象的概念,
+虽然一个特殊的扩展值可以用于表达这个意思,但是它并不是严格必要的。

The observation made in the last paragraph about the irrelevant nature of the
 additional `nil_t` with respect to [_purpose] of `optional<T>` suggests an
-alternative model: a ['container] that either has a value of `T` or nothing. +alternative model: a ['container] that either has a value of `T` or nothing.\n +最近的研究表明,额外的 `nil_t` 对于 `optional<T>` 的 [_目的] 是无关的,我们 建议另一种模型:一个['容器],它具有 `T` 的值,或者为空。

 As of this writing I don't know of any precedence for a variable-size
fixed-capacity (of 1) stack-based container model for optional values, yet I
 believe this is the consequence of the lack of practical implementations of
-such a container rather than an inherent shortcoming of the container model. +such a container rather than an inherent shortcoming of the container model.\n +在写这篇文档之时,我还不知道有任何一个大小可变、容量固定(为1)、基于栈的 optional 值的容器模型的先例, +但是我相信这只是因为还没有这样一个容器的实际实现,而不是这样一个容器模型的 固有缺点。

 In any event, both the discriminated-union or the single-element container
 models serve as a conceptual ground for a class representing optional--i.e.
 possibly uninitialized--objects.
For instance, these models show the ['exact] semantics required for a wrapper
-of optional values:
-
-Discriminated-union:
-
-* [*deep-copy] semantics: copies of the variant implies copies of the value.
+of optional values:\n
+无论如何,可识别联合或单元素容器模型均可作为表示 optional 类 -- 即可能未初始 化的 -- 对象的基础。
+例如,这些模型表现出了一个 optional 值包装器所需的['准确]语义:
+
+Discriminated-union:\n
+可识别联合:
+
+* [*deep-copy] semantics: copies of the variant implies copies of the value.\n
+  [*深复制] 语义:variant 的拷贝即为值的拷贝。
 * [*deep-relational] semantics: comparisons between variants matches both
-current types and values
-* If the variant's current type is `T`, it is modeling an ['initialized] optional.
+current types and values\n
+  [*深比较] 语义:比较两个 variants 要同时匹配类型和值。
+* If the variant's current type is `T`, it is modeling an ['initialized] optional.\n
+  如果 variant 的当前类型为 `T`, 它就代表['已初始化的] optional.
* If the variant's current type is not `T`, it is modeling an ['uninitialized]
-optional.
+optional.\n
+  如果 variant 的当前类型不是 `T`, 它就代表['未初始化的] optional.
* Testing if the variant's current type is `T` models testing if the optional
-is initialized
+is initialized\n
+  测试 variant 的当前类型是否为 `T` 即测试 optional 是否已初始化。
* Trying to extract a `T` from a variant when its current type is not `T`, models -the undefined behavior of trying to access the value of an uninitialized optional
-
-Single-element container:
-
-* [*deep-copy] semantics: copies of the container implies copies of the value. +the undefined behavior of trying to access the value of an uninitialized optional\n + 试图从一个 variant 取出 `T` 而它的当前类型不是 `T` 时,正好符合了访问一个 未初始化 optional 值的未定义行为。
+
+Single-element container:\n
+单元素容器:
+
+* [*deep-copy] semantics: copies of the container implies copies of the value.\n
+  [*深复制] 语义:container 的拷贝即为值的拷贝。
* [*deep-relational] semantics: comparisons between containers compare container
-size and if match, contained value
+size and if match, contained value\n
+ [*深比较] 语义:比较两个 containers 要先比较容器的大小,如果匹配再比较容 器中的值。 * If the container is not empty (contains an object of type `T`), it is modeling
-an ['initialized] optional.
-* If the container is empty, it is modeling an ['uninitialized] optional.
+an ['initialized] optional.\n
+ 如果 container 非空(包含一个类型为 `T` 的对象),它就代表['已初始化的] optional.
+* If the container is empty, it is modeling an ['uninitialized] optional.\n
+  如果 container 为空,它就代表['未初始化的] optional.
 * Testing if the container is empty models testing if the optional is
-initialized
+initialized\n
+  测试 container 是否为空即测试 optional 是否已初始化。
* Trying to extract a `T` from an empty container models the undefined behavior
-of trying to access the value of an uninitialized optional
+of trying to access the value of an uninitialized optional\n
+ 试图从一个空的 container 取出 `T`,正好符合了访问一个未初始化 optional 值 的未定义行为。
+

 [endsect]

-[section The semantics]
+[section:the_semantics The semantics 语义]

Objects of type `optional<T>` are intended to be used in places where objects of type `T` would but which might be uninitialized. Hence, `optional<T>`'s purpose is
@@ -110,40 +150,60 @@
 different mechanism.
Doing it the other way around, that is, making `optional<T>` a ['subtype] of `T`
 is not only conceptually wrong but also impractical: it is not allowed to
-derive from a non-class type, such as a built-in type.
-
-We can draw from the purpose of `optional<T>` the required basic semantics:
+derive from a non-class type, such as a built-in type.\n
+类型 `optional<T>` 的对象的设计意图是,用在那些使用可能未被初始化的类型 `T` 的对象的地方。
+因此,`optional<T>` 的意图是对增加可能的未初始化状态进行规范化。
+从这一任务的观点出发,`optional<T>` 可以具有与 `T` 相同的操作语义,再加上与 特殊状态相对应的额外语义。 +同样,`optional<T>` 可被视为 `T` 的一个 ['超类型]. 当然,我们不能在C++中这 样做,所以我们需要用一种不同的机制来得到想要的语义。 +使用其它方法实现它,如让 `optional<T>` 作为 `T` 的 ['子类],不仅是概念上的 错误,而且也是不实际的:
+因为不允许从非类类型派生,如从内建类型派生。
+
+We can draw from the purpose of `optional<T>` the required basic semantics:\n
+我们可以从 `optional<T>` 的目的描画出所需的基本语义:

 * [*Default Construction:] To introduce a formally uninitialized wrapped
-object.
+object.\n
+  [*缺省构造:]引入一个正式的未初始化包装对象。
* [*Direct Value Construction via copy:] To introduce a formally initialized
-wrapped object whose value is obtained as a copy of some object.
-* [*Deep Copy Construction:] To obtain a new yet equivalent wrapped object.
+wrapped object whose value is obtained as a copy of some object.\n
+ [*通过复制进行直接的值构造:]引入一个正式的已初始化包装对象,其值来自于某 个对象的拷贝。 +* [*Deep Copy Construction:] To obtain a new yet equivalent wrapped object.\n
+  [*深复制构造:]获得一个新的、等价的包装对象。
 * [*Direct Value Assignment (upon initialized):] To assign a value to the
-wrapped object.
+wrapped object.\n
+  [*直接的值赋值(到已初始化的对象):]将一个值赋值到包装对象。
* [*Direct Value Assignment (upon uninitialized):] To initialize the wrapped
-object with a value obtained as a copy of some object.
+object with a value obtained as a copy of some object.\n
+ [*直接的值赋值(到未初始化的对象):]从某个对象的拷贝取得值,初始化包装对 象。 * [*Assignment (upon initialized):] To assign to the wrapped object the value
-of another wrapped object.
+of another wrapped object.\n
+  [*赋值(到已初始化的对象):]将另一个包装对象的值赋值到包装对象。
 * [*Assignment (upon uninitialized):] To initialize the wrapped object with
-value of another wrapped object.
+value of another wrapped object.\n
+  [*赋值(到未初始化的对象):]以另一个包装对象的值初始化包装对象。
 * [*Deep Relational Operations (when supported by the type T):] To compare
-wrapped object values taking into account the presence of uninitialized states.
-* [*Value access:] To unwrap the wrapped object.
+wrapped object values taking into account the presence of uninitialized states.\n + [*深比较操作(仅当被类型T支持时):]比较两个包装对象的值,包括未初始化状态 的情形。
+* [*Value access:] To unwrap the wrapped object.\n
+  [*值访问:]对包装对象去包装。
 * [*Initialization state query:] To determine if the object is formally
-initialized or not.
+initialized or not.\n
+  [*初始化状态查询:]判断该对象是否已正式初始化。
 * [*Swap:] To exchange wrapped objects. (with whatever exception safety
-guarantees are provided by `T`'s swap).
+guarantees are provided by `T`'s swap).\n
+  [*交换:]交换包装的对象。(无论 `T` 的交换操作提供何种异常安全性保证)。
* [*De-initialization:] To release the wrapped object (if any) and leave the
-wrapper in the uninitialized state.
+wrapper in the uninitialized state.\n
+  [*去初始化:]释放包装的对象(如果有),并使包装器保留未初始化状态。

 Additional operations are useful, such as converting constructors and
 converting assignments, in-place construction and assignment, and safe
-value access via a pointer to the wrapped object or null.
+value access via a pointer to the wrapped object or null.\n
+其它操作也是有用的,如转换构造函数和转换赋值,就地构造和赋值,以及通过包装 对象的一个指针或空指针进行安全的值访问。

 [endsect]

-[section The Interface]
+[section:the_interface The Interface 接口]

 Since the purpose of optional is to allow us to use objects with a formal
 uninitialized additional state, the interface could try to follow the
@@ -152,31 +212,42 @@
be noted: Even if all the operations supported by an instance of type `T` are
 defined for the entire range of values for such a type, an `optional<T>`
 extends such a set of values with a new value for which most
-(otherwise valid) operations are not defined in terms of `T`.
+(otherwise valid) operations are not defined in terms of `T`.\n
+由于 optional 的目的是允许我们使用增加了正式的未初始化状态的对象,所以它的 接口应该尽可能跟随底层的类型 `T`. +为了选择适当的原本的 `T` 接口,应该留意以下几点:即使被类型 `T` 的实例所支 持的所有操作是为该类的整个值域所定义的, +但是 `optional<T>` 将该值域扩充了一个新值,所以很多(对其它值有效的)操作对该 值没有定义。

Furthermore, since `optional<T>` itself is merely a `T` wrapper (modeling a `T` supertype), any attempt to define such operations upon uninitialized optionals
-will be totally artificial w.r.t. `T`.
+will be totally artificial w.r.t. `T`.\n
+此外,由于 `optional<T>` 本身只不过是一个 `T` 的包装(类似于 `T` 的一个超类 ),任何针对未初始化的 optional 的操作定义都应完全与 `T` 相关。

This library chooses an interface which follows from `T`'s interface only for those operations which are well defined (w.r.t the type `T`) even if any of the
 operands are uninitialized. These operations include: construction,
-copy-construction, assignment, swap and relational operations.
+copy-construction, assignment, swap and relational operations.\n
+本库所选择的接口是,沿用 `T` 的接口,只要那些操作是有良好定义的(与类型 `T` 有关),即使某些操作数未初始化。
+这样的操作包括有:构造,复制构造,赋值,交换和比较操作。

For the value access operations, which are undefined (w.r.t the type `T`) when the operand is uninitialized, a different interface is chosen (which will be
-explained next).
+explained next).\n
+对于值访问操作,如果操作数是未初始化的,则是未定义的(与类型 `T` 有关),所以 选用了不同的接口(稍后将会解释)。

 Also, the presence of the possibly uninitialized state requires additional
-operations not provided by `T` itself which are supported by a special interface. +operations not provided by `T` itself which are supported by a special interface.\n +还有,未初始化状态的可能出现需要有更多的操作,这些操作是 `T` 本身所不具备 的,它们将以特定的接口提供。

 [heading Lexically-hinted Value Access in the presence of possibly
-untitialized optional objects: The operators * and ->]
+untitialized optional objects: The operators * and ->\n
+对可能未初始化的 optional 对象的带提示的值访问:操作符 * 和 ->]

A relevant feature of a pointer is that it can have a [*null pointer value]. This is a ['special] value which is used to indicate that the pointer is not
 referring to any object at all. In other words, null pointer values convey
-the notion of inexistent objects.
+the notion of inexistent objects.\n
+指针的一个特点是它可以具有 [*空指针值]。这是一个['特殊]值,用于表示该指针没 有指向任何对象。
+换句话说,空指针值表达的意思是不存在的对象。

 This meaning of the null pointer value allowed pointers to became a ['de
 facto] standard for handling optional objects because all you have to do
@@ -184,7 +255,10 @@
 value of the appropriate type. Pointers have been used for decades--from
the days of C APIs to modern C++ libraries--to ['refer] to optional (that is,
 possibly inexistent) objects; particularly as optional arguments to a
-function, but also quite often as optional data members.
+function, but also quite often as optional data members.\n
+空指针值的这个意义使得指针成为了处理 optional 对象的['事实]标准,因为当你要 引向一个实际上不存在的值时, +你要做的只是使用适当类型的空指针值。指针已经被使用了几十年 -- 从 C APIs 一直 到现代的 C++ 库 -- 用来['表示] optional
+(即可能不存在的)对象;尤其是用作函数的可选参数,但也常被用作可选数据成员。

 The possible presence of a null pointer value makes the operations that
 access the pointee's value possibly undefined, therefore, expressions which
@@ -192,12 +266,17 @@
implicitly convey the notion of optionality, and this information is tied to the ['syntax] of the expressions. That is, the presence of operators `*` and `->` tell by themselves --without any additional context-- that the expression will
-be undefined unless the implied pointee actually exist.
+be undefined unless the implied pointee actually exist.\n
+空指针值的可能出现使得访问被指物值的操作可能是无定义的,所以,使用提领和访 问操作符的表达式, +如 `( *p = 2 )` 和 `( p->foo() )`, 暗含了可选性的概念,此类信息被表达式的 ['语法]所依赖。 +即,操作符 `*` 和 `->` 本身 -- 无需任何额外的上下文 -- 就说明了该表达式可以是 无定义的,除非被指物确实存在。

Such a ['de facto] idiom for referring to optional objects can be formalized
 in the form of a concept: the __OPTIONAL_POINTEE__ concept.
 This concept captures the syntactic usage of operators `*`, `->` and
-conversion to `bool` to convey the notion of optionality.
+conversion to `bool` to convey the notion of optionality.\n
+这个表示 optional 对象的['事实上]的惯用法可以用一个概念来规范 化:__OPTIONAL_POINTEE__ 概念。
+该概念包含了操作符 `*`, `->` 以及转换到 `bool` 的语法,以表达可选性的概念。

However, pointers are good to [_refer] to optional objects, but not particularly good to handle the optional objects in all other respects, such as initializing
@@ -206,7 +285,10 @@
are not enough. The problem is that copies of pointers do not imply copies of
 pointees. For example, as was discussed in the motivation, pointers alone
cannot be used to return optional objects from a function because the object
-must move outside from the function and into the caller's context.
+must move outside from the function and into the caller's context.\n
+虽然指针适合于[_表示] optional 对象,但是并不特别适合处理 optional 对象的其 它方面,如初始化或移动/复制。 +问题主要在于指针语义的浅复制:如果你需要高效地移动或复制对象,那么仅有指针 是不够的。问题是指针的拷贝并不代表被指物的拷贝。 +例如,象在"动机"一节中所讨论的,仅用指针并不能从一个函数返回 optional 对 象,因为该对象必须从函数中移至外部,进入调用者的上下文。

 A solution to the shallow-copy problem that is often used is to resort to
dynamic allocation and use a smart pointer to automatically handle the details
@@ -219,18 +301,26 @@
 not have this semantics, so are inappropriate for the initialization and
transport of optional values, yet are quite convenient for handling the access
 to the possible undefined value because of the idiomatic aid present in the
-__OPTIONAL_POINTEE__ concept incarnated by pointers.
+__OPTIONAL_POINTEE__ concept incarnated by pointers.\n
+解决浅复制问题的一个常用方法是,采用动态分配并使用智能指针来自动处理其细 节。 +例如,如果一个函数可选性地返回一个对象 `X`, 则可以使用 `shared_ptr<X>` 作为 返回值。 +不过,这要求对 `X` 进行动态分配。如果 `X` 是内建的或是小的 POD, 该技术在资 源方面很不划算。 +Optional 对象本质上是值对象,所以,如果可以象我们处理普通的值对象那样,使用 自动存储和深复制语义来维护 optional 值,才是最方便的。 +指针不具有这种语义,所以不适于初始化和转移 optional 值,但还是非常适合于访 问有可能无定义的值,
+因为该用法已存在于以指针为代表的 __OPTIONAL_POINTEE__ 概念中。


-[heading Optional<T> as a model of OptionalPointee]
+[heading Optional<T> as a model of OptionalPointee Optional<T>作为 OptionalPointee的模型]

 For value access operations `optional<>` uses operators `*` and `->` to
 lexically warn about the possibly uninitialized state appealing to the
-familiar pointer semantics w.r.t. to null pointers.
+familiar pointer semantics w.r.t. to null pointers.\n
+对于值访问操作,`optional<>` 使用操作符 `*` 和 `->` 来提醒有可能出现的未初 始化状态,这类似于指针语义中的空指针用法。

 [warning
 However, it is particularly important to note that `optional<>` objects
-are not pointers. [_`optional<>` is not, and does not model, a pointer].
+are not pointers. [_`optional<>` is not, and does not model, a pointer].\n
+但是,要重点留意的是,`optional<>` 对象不是指针。[_`optional<>` 不是也不符 合指针的概念]。
 ]

 For instance, `optional<>` does not have shallow-copy so does not alias:
@@ -244,7 +334,13 @@
 As a result, you might be able to replace `optional<T>` by `T*` on some
 situations but not always. Specifically, on generic code written for both,
 you cannot use relational operators directly, and must use the template
-functions __FUNCTION_EQUAL_POINTEES__ and __FUNCTION_LESS_POINTEES__ instead. +functions __FUNCTION_EQUAL_POINTEES__ and __FUNCTION_LESS_POINTEES__ instead.\n +例如,`optional<>` 没有浅复制,所以也没有别名:两个不同的 optional 永远不会 引向['同一个]值, +除非 `T` 本身是一个引用(但可以有['相等的]值)。必须注意 `optional<T>` 和指针 间的区别,特别是因为它们的比较操作符的语义是不同的: +因为 `optional<T>` 是一个值包装器,比较操作符是"深"的:它们比较 optional 的 值;而指针的比较操作符则是"浅"的: +它们不比较被指物的值。所以,你也许可以在某些情形下用 `T*` 替换 `optional<T>`,但并不是总可以这样做。 +特别是,在为两者所写的泛型代码中,你不能直接使用比较操作符,而必须使用模板 函数 __FUNCTION_EQUAL_POINTEES__ 和
+__FUNCTION_LESS_POINTEES__ 来代替。

 [endsect]

=======================================
--- /trunk/libs/optional/doc/examples.qbk       Mon Feb  8 07:24:10 2010
+++ /trunk/libs/optional/doc/examples.qbk       Wed Mar 24 00:54:49 2010
@@ -9,28 +9,29 @@
 ]


-[section Examples]
-
-[section Optional return values]
+[section:examples Examples 例子]
+
+[section:optional_return_values Optional return values  Optional返回值]

     optional<char> get_async_input()
     {
         if ( !queue.empty() )
             return optional<char>(queue.top());
-        else return optional<char>(); // uninitialized
+        else return optional<char>(); // uninitialized 未初始化
     }

     void receive_async_message()
     {
         optional<char> rcv ;
-        // The safe boolean conversion from 'rcv' is used here.
+        // The safe boolean conversion from 'rcv' is used here.
+        // 此处使用了从 'rcv' 到布尔值的安全转换。
         while ( (rcv = get_async_input()) && !timeout() )
             output(*rcv);
     }

 [endsect]

-[section Optional local variables]
+[section:optional_local_variables Optional local variables Optional局部变 量]

     optional<string> name ;
     if ( database.open() )
@@ -49,7 +50,7 @@

 [endsect]

-[section Optional data members]
+[section:optional_data_members Optional data members  Optional数据成员]

     class figure
     {
@@ -58,12 +59,13 @@
         figure()
         {
// data member 'm_clipping_rect' is uninitialized at this point.
+            // 此处数据成员 'm_clipping_rect' 未初始化。
         }

         void clip_in_rect ( rect const& rect )
         {
             ....
-            m_clipping_rect.reset ( rect ) ; // initialized here.
+ m_clipping_rect.reset ( rect ) ; // initialized here. 此处初始 化。
         }

         void draw ( canvas& cvs )
@@ -74,7 +76,7 @@
             cvs.drawXXX(..);
         }

-        // this can return NULL.
+        // this can return NULL.  可以返回 NULL.
rect const* get_clipping_rect() { return get_pointer(m_clipping_rect); }

         private :
@@ -85,7 +87,8 @@

 [endsect]

-[section Bypassing expensive unnecessary default construction]
+[section:bypassing_expensive_unnecessary_default_construction Bypassing expensive unnecessary default construction
+避免不必要的昂贵的缺省构造]

     class ExpensiveCtor { ... } ;
     class Fred
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/a_note_about_optional_bool_.html Tue Nov 25 06:14:27 2008 +++ /trunk/libs/optional/doc/html/boost_optional/a_note_about_optional_bool_.html Wed Mar 24 00:54:49 2010
@@ -1,109 +1,98 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html><head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-
- <title>A note about optional&lt;bool&gt;</title><link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="in_place_factories.html" title="In-Place Factories">
-
- <link rel="next" href="exception_safety_guarantees.html" title="Exception Safety Guarantees"></head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>A note about optional&lt;bool&gt; &#20851;&#20110;optional&lt;bool&gt;&#30340;&#35828;&#26126;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="in_place_factories.html" title="In-Place Factories &#23601;&#22320;&#21019;&#24314;"> +<link rel="next" href="exception_safety_guarantees.html" title="Exception Safety Guarantees &#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="in_place_factories.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.a_note_about_optional_bool_"></a><a class="link" href="a_note_about_optional_bool_.html" title="A note about optional&lt;bool&gt;">关于
-    optional&lt;bool&gt; 的说明</a>
-</h2>
-</div>
-</div>
-</div>
-
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.a_note_about_optional_bool_"></a><a class="link" href="a_note_about_optional_bool_.html" title="A note about optional&lt;bool&gt; &#20851;&#20110;optional&lt;bool&gt;&#30340;&#35828;&#26126;"> A note about + optional&lt;bool&gt; &#20851;&#20110;optional&lt;bool&gt;&#30340;&#35828;&#26126;</a>
+</h2></div></div></div>
 <p>
- <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> 在使用时 需要特别小心和留意。</p>
-
-<p>首先,它的功能类似于三态布尔类型(false,maybe,true) -- 如 <a href="../../../../../doc/html/tribool.html">boost::tribool</a> -- -只有一点区别,即在三态布尔类型中,<i>maybe</i> 状态<span style="text-decoration: underline;">代表了一个有效的值</span>,而不是未初始 化的&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> -的相应状态。如果真的要用&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> 替代 &nbsp;<code class="computeroutput"><span class="identifier">tribool</span></code>,你要非常小心谨慎。</p>
-
-<p>其次,<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> - 提供了到&nbsp;<code class="computeroutput"><span class="keyword">bool</span></code> 的隐式转换。该转换表示了所含值是否为已初 始化状态。使用&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> 可能会由 于这个到&nbsp;<code class="computeroutput"><span class="keyword">bool</span></code>
- 的隐式转换而导致微妙的错误:<br>
-</p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> should + be used with special caution and consideration.<br> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> + &#22312;&#20351;&#29992;&#26102;&#38656;&#35201;&#29305;&#21035;&#23567;&#24515;&#21644;&#30041;&#24847;&#12290;
+    </p>
+<p>
+ First, it is functionally similar to a tristate boolean (false,maybe,true) + &#8212;such as <a href="../../../../../doc/html/tribool.html" target="_top">boost::tribool</a>&#8212; + except that in a tristate boolean, the maybe state <span class="underline">represents + a valid value</span>, unlike the corresponding state of an uninitialized + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code>. It + should be carefully considered if an <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> + instead of a <code class="computeroutput"><span class="identifier">tribool</span></code> is really + needed.<br> &#39318;&#20808;&#65292;&#23427;&#30340;&#21151;&#33021;&#31867;&#20284;&#20110;&#19977;&#24577;&#24067;&#23572;&#31867;&#22411;(false,maybe,true) + &#8212; &#22914; <a href="../../../../../doc/html/tribool.html" target="_top">boost::tribool</a> + &#8212; &#21482;&#26377;&#19968;&#28857;&#21306;&#21035;&#65292; &#21363;&#22312;&#19977;&#24577;&#24067;&#23572;&#31867;&#22411;&#20013;&#65292;maybe &#29366;&#24577;<span class="underline">&#20195;&#34920;&#20102;&#19968;&#20010;&#26377;&#25928;&#30340;&#20540;</span>&#65292;&#32780;&#19981;&#26159;&#26410;&#21021;&#22987;&#21270;&#30340; + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> &#30340;&#30456;&#24212;&#29366;&#24577;&#12290; + &#22914;&#26524;&#30495;&#30340;&#35201;&#29992; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> + &#26367;&#20195; <code class="computeroutput"><span class="identifier">tribool</span></code>&#65292;&#20320;&#35201;&#38750;&#24120;&#23567;&#24515;&#35880;&#24910;&#12290;
+    </p>
+<p>
+ Second, <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> + provides an implicit conversion to <code class="computeroutput"><span class="keyword">bool</span></code>. + This conversion refers to the initialization state and not to the contained + value. Using <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> can + lead to subtle errors due to the implicit <code class="computeroutput"><span class="keyword">bool</span></code> + conversion:<br> &#20854;&#27425;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> &#25552;&#20379;&#20102;&#21040; <code class="computeroutput"><span class="keyword">bool</span></code> + &#30340;&#38544;&#24335;&#36716;&#25442;&#12290;&#35813;&#36716;&#25442;&#34920;&#31034;&#20102;&#25152;&#21547;&#20540;&#26159;&#21542;&#20026;&#24050;&#21021;&#22987;&#21270;&#29366;&#24577;&#12290; + &#20351;&#29992; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span></code> &#21487;&#33021;&#20250;&#30001;&#20110;&#36825;&#20010;&#21040; + <code class="computeroutput"><span class="keyword">bool</span></code> &#30340;&#38544;&#24335;&#36716;&#25442;&#32780;&#23548;&#33268;&#24494;&#22937;&#30340;&#38169;&#35823;&#65306;
+    </p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <span class="keyword">void</span> <span class="identifier">bar</span><span class="special">()</span>
 <span class="special">{</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">bool</span><span class="special">&gt;</span> <span class="identifier">v</span> <span class="special">=</span> <span class="keyword">try</span><span class="special">();</span>

- <span class="comment">// 下面将 'v' 的值传递给 foo():<br></span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span> - <span class="comment">// 但是实际上,被传递的是初始化状态 <br></span> <span class="comment">// 正确的写法应该 是:foo(*v).<br></span><span class="special">}</span> + <span class="comment">// The following intended to pass the value of 'v' to foo(): +</span> <span class="comment">// &#19979;&#38754;&#23558; 'v' &#30340;&#20540;&#20256;&#36882;&#32473; foo(): +</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span> + <span class="comment">// But instead, the initialization state is passed +</span> <span class="comment">// due to a typo: it should have been foo(*v). +</span> <span class="comment">// &#20294;&#26159;&#23454;&#38469;&#19978;&#65292;&#34987;&#20256;&#36882;&#30340;&#26159;&#21021;&#22987;&#21270;&#29366;&#24577;&#12290;&#27491;&#30830;&#30340;&#20889;&#27861;&#24212;&#35813;&#26159;&#65306;foo(*v).
+</span><span class="special">}</span>
 </pre>
-
-<p>隐式转换只是转为&nbsp;<code class="computeroutput"><span class="keyword">bool</span></code>, 不会对其进行整型类型的提升,所以它还是 <span style="font-style: italic;">安全</span>的(例如,如果&nbsp;<code class="computeroutput"><span class="identifier">foo</span><span class="special">()</span></code> 接受的是一个&nbsp;<code class="computeroutput"><span class="keyword">int</span></code>, 它将不能编译 )。
+<p>
+ The only implicit conversion is to <code class="computeroutput"><span class="keyword">bool</span></code>, + and it is safe in the sense that typical integral promotions don't apply (i.e. + if <code class="computeroutput"><span class="identifier">foo</span><span class="special">()</span></code> + takes an <code class="computeroutput"><span class="keyword">int</span></code> instead, it won't + compile).<br> &#38544;&#24335;&#36716;&#25442;&#21482;&#26159;&#36716;&#20026; <code class="computeroutput"><span class="keyword">bool</span></code>, + &#19981;&#20250;&#23545;&#20854;&#36827;&#34892;&#25972;&#22411;&#31867;&#22411;&#30340;&#25552;&#21319;&#65292;&#25152;&#20197;&#23427;&#36824;&#26159;&#23433;&#20840;&#30340;(&#20363;&#22914;&#65292;&#22914;&#26524; + <code class="computeroutput"><span class="identifier">foo</span><span class="special">()</span></code> + &#25509;&#21463;&#30340;&#26159;&#19968;&#20010; <code class="computeroutput"><span class="keyword">int</span></code>, &#23427;&#23558;&#19981;&#33021;&#32534;&#35793;)&#12290;
     </p>
-
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright (c) 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="in_place_factories.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
-</body></html>
+</body>
+</html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/acknowledgments.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/acknowledgments.html Wed Mar 24 00:54:49 2010
@@ -1,197 +1,125 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Acknowledgments</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="dependencies_and_portability.html" title="Dependencies and Portability">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Acknowledgments &#40483;&#35874;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="dependencies_and_portability.html" title="Dependencies and Portability &#20381;&#36182;&#24615;&#21644;&#21487;&#31227;&#26893;&#24615;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.acknowledgments"></a><a class="link" href="acknowledgments.html" title="Acknowledgments">鸣谢</a>
-</h2>
-</div>
-</div>
-</div>
-
-<a name="boost_optional.acknowledgments.pre_formal_review"></a>
-<h4>
-<a name="id2665170"></a>
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.acknowledgments"></a><a class="link" href="acknowledgments.html" title="Acknowledgments &#40483;&#35874;"> Acknowledgments &#40483;&#35874;</a>
+</h2></div></div></div>
+<a name="boost_optional.acknowledgments.pre_formal_review"></a><h4>
+<a name="id4895857"></a>
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.pre_formal_review">Pre-formal
       review</a>
     </h4>
-
-<div class="itemizedlist">
-<ul type="disc">
-
-  <li>
+<div class="itemizedlist"><ul type="disc">
+<li>
Peter Dimov suggested the name 'optional', and was the first to point out
         the need for aligned storage.
       </li>
-
-  <li>
+<li>
Douglas Gregor developed 'type_with_alignment', and later Eric Friedman coded 'aligned_storage', which are the core of the optional class implementation.
       </li>
-
-  <li>
+<li>
Andrei Alexandrescu and Brian Parker also worked with aligned storage techniques
         and their work influenced the current implementation.
       </li>
-
-  <li>
+<li>
Gennadiy Rozental made extensive and important comments which shaped the
         design.
       </li>
-
-  <li>
+<li>
Vesa Karvonen and Douglas Gregor made quite useful comparisons between optional,
         variant and any; and made other relevant comments.
       </li>
-
-  <li>
+<li>
Douglas Gregor and Peter Dimov commented on comparisons and evaluation in
         boolean contexts.
       </li>
-
-  <li>
+<li>
Eric Friedman helped understand the issues involved with aligned storage,
         move/copy operations and exception safety.
       </li>
-
-  <li>
+<li>
Many others have participated with useful comments: Aleksey Gurotov, Kevlin
         Henney, David Abrahams, and others I can't recall.
       </li>
-
-</ul>
-</div>
-
-<a name="boost_optional.acknowledgments.post_formal_review"></a>
-<h4>
-<a name="id2665241"></a>
+</ul></div>
+<a name="boost_optional.acknowledgments.post_formal_review"></a><h4>
+<a name="id4895927"></a>
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.post_formal_review">Post-formal
       review</a>
     </h4>
-
-<div class="itemizedlist">
-<ul type="disc">
-
-  <li>
+<div class="itemizedlist"><ul type="disc">
+<li>
William Kempf carefully considered the originally proposed interface and suggested the new interface which is currently used. He also started and fueled the discussion about the analogy optional&lt;&gt;/smart pointer and
         about relational operators.
       </li>
-
-  <li>
+<li>
Peter Dimov, Joel de Guzman, David Abrahams, Tanton Gibbs and Ian Hanson focused on the relational semantics of optional (originally undefined); concluding with the fact that the pointer-like interface doesn't make it a pointer so
         it shall have deep relational operators.
       </li>
-
-  <li>
+<li>
Augustus Saunders also explored the different relational semantics between optional&lt;&gt; and a pointer and developed the OptionalPointee concept
         as an aid against potential conflicts on generic code.
       </li>
-
-  <li>
+<li>
Joel de Guzman noticed that optional&lt;&gt; can be seen as an API on top
         of variant&lt;T,nil_t&gt;.
       </li>
-
-  <li>
+<li>
Dave Gomboc explained the meaning and usage of the Haskell analog to optional&lt;&gt;: the Maybe type constructor (analogy originally pointed out by David Sankel).
       </li>
-
-  <li>
+<li>
Other comments were posted by Vincent Finn, Anthony Williams, Ed Brey, Rob
         Stewart, and others.
       </li>
-
-  <li>
+<li>
Joel de Guzman made the case for the support of references and helped with
         the proper semantics.
       </li>
-
-  <li>
+<li>
Mat Marcus shown the virtues of a value-oriented interface, influencing the
         current design, and contributed the idea of "none".
       </li>
-
-</ul>
+</ul></div>
 </div>
-
-</div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/dependencies_and_portability.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/dependencies_and_portability.html Wed Mar 24 00:54:49 2010
@@ -1,92 +1,48 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Dependencies and Portability</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="implementation_notes.html" title="Implementation Notes">
-
-  <link rel="next" href="acknowledgments.html" title="Acknowledgments">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Dependencies and Portability &#20381;&#36182;&#24615;&#21644;&#21487;&#31227;&#26893;&#24615;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="implementation_notes.html" title="Implementation Notes &#23454;&#29616;&#35828;&#26126;"> +<link rel="next" href="acknowledgments.html" title="Acknowledgments &#40483;&#35874;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="implementation_notes.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.dependencies_and_portability"></a><a class="link" href="dependencies_and_portability.html" title="Dependencies and Portability">依赖性和可移植性</a>
-</h2>
-</div>
-</div>
-</div>
-
-<p>该实现使用了 <code class="computeroutput"><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">alignment_of</span><span class="special">.</span><span class="identifier">hpp</span></code> 和 - <code class="computeroutput"><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">type_with_alignment</span><span class="special">.</span><span class="identifier">hpp</span></code>
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.dependencies_and_portability"></a><a class="link" href="dependencies_and_portability.html" title="Dependencies and Portability &#20381;&#36182;&#24615;&#21644;&#21487;&#31227;&#26893;&#24615;"> Dependencies + and Portability &#20381;&#36182;&#24615;&#21644;&#21487;&#31227;&#26893;&#24615;</a>
+</h2></div></div></div>
+<p>
+ The implementation uses <code class="computeroutput"><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">alignment_of</span><span class="special">.</span><span class="identifier">hpp</span></code> and + <code class="computeroutput"><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">type_with_alignment</span><span class="special">.</span><span class="identifier">hpp</span></code><br> &#35813;&#23454;&#29616;&#20351;&#29992;&#20102; <code class="computeroutput"><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">alignment_of</span><span class="special">.</span><span class="identifier">hpp</span></code> &#21644; <code class="computeroutput"><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">type_with_alignment</span><span class="special">.</span><span class="identifier">hpp</span></code>
     </p>
-
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="implementation_notes.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/detailed_semantics.html Tue Nov 25 06:14:27 2008 +++ /trunk/libs/optional/doc/html/boost_optional/detailed_semantics.html Wed Mar 24 00:54:49 2010
@@ -1,2780 +1,1869 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-
-
-
-  <title>Detailed Semantics</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
-
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-
-
-  <link rel="prev" href="synopsis.html" title="Synopsis">
-
-
-
-  <link rel="next" href="examples.html" title="Examples">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Detailed Semantics &#35814;&#32454;&#35821;&#20041;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional">
+<link rel="prev" href="synopsis.html" title="Synopsis &#25688;&#35201;">
+<link rel="next" href="examples.html" title="Examples &#20363;&#23376;">
 </head>
-
-
-<body style="color: black; background-color: white;" alink="#0000ff" link="#0000ff" vlink="#840084">
-
-
-<table cellpadding="2" width="100%">
-
-
-  <tbody>
-
-
-    <tr>
-
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-
-    </tr>
-
-
-
-  </tbody>
-</table>
-
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
-<div class="spirit-nav"><a accesskey="p" href="synopsis.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+<div class="spirit-nav">
+<a accesskey="p" href="synopsis.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;"><a name="boost_optional.detailed_semantics"></a><a class="link" href="detailed_semantics.html" title="Detailed Semantics">详细语义</a>
-</h2>
-
-
-</div>
-
-
-</div>
-
-
-</div>
-
-
-<p>因为 <code class="computeroutput"><span class="identifier">T</span></code> -可能是引用类型,所以,那些语义与 <code class="computeroutput"><span class="identifier">T</span></code>
-的类型是否为引用相关的项,将使用以下约定: </p>
-
-
-<div class="itemizedlist">
-<ul type="disc">
-
-
- <li>如果该项为: <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code><span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;</span></code>,
-则对应的描述仅适作于T不是引用类型时的情况。 </li>
-
-
- <li>如果该项为:<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code>,
-则对应的描述仅适用于T是引用类型时的情况。 </li>
-
-
- <li>如果该项为:<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>,
-则对应的描述适用于两种情况。 </li>
-
-
-</ul>
-
-
-</div>
-
-
-<div class="note">
-<table summary="Note" border="0">
-
-
-  <tbody>
-
-
-    <tr>
-
-
- <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/html/images/note.png"></td>
-
-
-      <th align="left">说明</th>
-
-
-    </tr>
-
-
-    <tr>
-
-
-      <td align="left" valign="top">
-
- <p>以下章节中包含多个 <code class="computeroutput"><span class="identifier">assert</span><span class="special">()</span></code>,仅用 于示范后续条件的例子代码。它 -并不意味着类型 <code class="computeroutput"><span class="identifier">T</span></code>
-必须支持每个单独的表达式,但是如果它支持某个表达式,则满足相应的条件。</p>
-
-
-      </td>
-
-
-    </tr>
-
-
-
-  </tbody>
-</table>
-
-
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.detailed_semantics"></a><a class="link" href="detailed_semantics.html" title="Detailed Semantics &#35814;&#32454;&#35821;&#20041;"> Detailed Semantics
+    &#35814;&#32454;&#35821;&#20041;</a>
+</h2></div></div></div>
+<p>
+ Because <code class="computeroutput"><span class="identifier">T</span></code> might be of reference + type, in the sequel, those entries whose semantic depends on <code class="computeroutput"><span class="identifier">T</span></code> being of reference type or not will be + distinguished using the following convention:<br> &#22240;&#20026; <code class="computeroutput"><span class="identifier">T</span></code> + &#21487;&#33021;&#26159;&#24341;&#29992;&#31867;&#22411;&#65292;&#25152;&#20197;&#65292;&#37027;&#20123;&#35821;&#20041;&#19982; <code class="computeroutput"><span class="identifier">T</span></code> + &#30340;&#31867;&#22411;&#26159;&#21542;&#20026;&#24341;&#29992;&#30456;&#20851;&#30340;&#39033;&#65292;&#23558;&#20351;&#29992;&#20197;&#19979;&#32422;&#23450;&#65306;
+    </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code><span class="emphasis"><em>(not + a ref)</em></span><code class="computeroutput"><span class="special">&gt;</span></code>, the description + corresponds only to the case where <code class="computeroutput"><span class="identifier">T</span></code> + is not of reference type.<br> &#22914;&#26524;&#35813;&#39033;&#20026;&#65306;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code><span class="emphasis"><em>(&#38750;&#24341;&#29992;)</em></span><code class="computeroutput"><span class="special">&gt;</span></code>, &#21017;&#23545;&#24212;&#30340;&#25551;&#36848;&#20165;&#36866;&#20316;&#20110; <code class="computeroutput"><span class="identifier">T</span></code> &#19981;&#26159;&#24341;&#29992;&#31867;&#22411;&#26102;&#30340;&#24773;&#20917;&#12290;
+      </li>
+<li>
+ If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code>, + the description corresponds only to the case where <code class="computeroutput"><span class="identifier">T</span></code> + is of reference type.<br> &#22914;&#26524;&#35813;&#39033;&#20026;&#65306;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code>, + &#21017;&#23545;&#24212;&#30340;&#25551;&#36848;&#20165;&#36866;&#29992;&#20110; <code class="computeroutput"><span class="identifier">T</span></code> + &#26159;&#24341;&#29992;&#31867;&#22411;&#26102;&#30340;&#24773;&#20917;&#12290;
+      </li>
+<li>
+ If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>, + the description is the same for both cases.<br> &#22914;&#26524;&#35813;&#39033;&#20026;&#65306;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>, + &#21017;&#23545;&#24212;&#30340;&#25551;&#36848;&#36866;&#29992;&#20110;&#20004;&#31181;&#24773;&#20917;&#12290;
+      </li>
+</ul></div>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ The following section contains various <code class="computeroutput"><span class="identifier">assert</span><span class="special">()</span></code> which are used only to show the postconditions + as sample code. It is not implied that the type <code class="computeroutput"><span class="identifier">T</span></code> + must support each particular expression but that if the expression is supported, + the implied condition holds.<br> &#20197;&#19979;&#31456;&#33410;&#20013;&#21253;&#21547;&#22810;&#20010; <code class="computeroutput"><span class="identifier">assert</span><span class="special">()</span></code>&#65292;&#20165;&#29992;&#20110;&#31034;&#33539;&#21518;&#32493;&#26465;&#20214;&#30340;&#20363;&#23376;&#20195;&#30721;&#12290; + &#23427;&#24182;&#19981;&#24847;&#21619;&#30528;&#31867;&#22411; <code class="computeroutput"><span class="identifier">T</span></code> + &#24517;&#39035;&#25903;&#25345;&#27599;&#20010;&#21333;&#29420;&#30340;&#34920;&#36798;&#24335;&#65292;&#20294;&#26159;&#22914;&#26524;&#23427;&#25903;&#25345;&#26576;&#20010;&#34920;&#36798;&#24335;&#65292;&#21017;&#28385;&#36275;&#30456;&#24212;&#30340;&#26465;&#20214;&#12290;
+      </p></td></tr>
+</table></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="boost_optional.detailed_semantics.optional_class_member_functions__optional__________________"></a><h4>
+<a name="id4865163"></a>
+ <a class="link" href="detailed_semantics.html#boost_optional.detailed_semantics.optional_class_member_functions__optional__________________">optional + class member functions optional&#31867;&#30340;&#25104;&#21592;&#20989;&#25968;</a>
+    </h4>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_constructor"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">();</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Default-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#32570;&#30465;&#26500;&#36896;&#19968;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">uninitialized</span>.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026; <span class="underline">&#26410;&#21021;&#22987;&#21270;&#30340;</span>&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Nothing.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span>&#26080;&#12290;
+      </li>
+<li>
+ Notes: T's default constructor <span class="underline">is not</span> + called.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>T &#30340;&#32570;&#30465;&#26500;&#36896;&#20989;&#25968;<span class="underline">&#26410;&#34987;</span>&#35843;&#29992;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">def</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">def</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_constructor_none_t"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">none_t</span> <span class="special">);</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Constructs an <code class="computeroutput"><span class="identifier">optional</span></code> + uninitialized.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#26500;&#36896;&#19968;&#20010;&#26410;&#21021;&#22987;&#21270;&#30340; + <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">uninitialized</span>.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026; <span class="underline">&#26410;&#21021;&#22987;&#21270;&#30340;</span>&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Nothing.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span>&#26080;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span><code class="computeroutput"><span class="identifier">T</span></code>'s
+        default constructor <span class="underline">is not</span> called.
+ The expression <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> denotes an instance of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none_t</span></code> that can be used as the parameter.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span><code class="computeroutput"><span class="identifier">T</span></code> + &#30340;&#32570;&#30465;&#26500;&#36896;&#20989;&#25968;<span class="underline">&#26410;&#34987;</span>&#35843;&#29992;&#12290;&#34920;&#36798;&#24335; + <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> &#34920;&#31034;&#19968;&#20010; <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none_t</span></code> + &#23454;&#20363;&#65292;&#21487;&#29992;&#20316;&#26412;&#26500;&#36896;&#20989;&#25968;&#30340;&#21442;&#25968;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">none</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">n</span><span class="special">(</span><span class="identifier">none</span><span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">n</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_constructor_value"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span> </code><span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Directly-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#30452;&#25509;&#26500;&#36896;&#19968;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span> + and its value is a<span class="emphasis"><em>copy</em></span> of <code class="computeroutput"><span class="identifier">v</span></code>.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026; <span class="underline">&#24050;&#21021;&#22987;&#21270;&#30340;</span>&#65292;&#23427;&#30340;&#20540;&#20026; + <code class="computeroutput"><span class="identifier">v</span></code> &#30340;<span class="emphasis"><em>&#25335;&#36125;</em></span>&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> throws.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> &#25152;&#25243;&#20986;&#30340;&#20219;&#20309;&#24322;&#24120;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes: </strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> is + called.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#35843;&#29992; <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be + thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="special">);</span></code> in that case, this constructor + has no effect.<br><span class="bold"><strong>&#24322;&#24120;&#23433;&#20840;&#24615;&#65306;</strong></span>&#20165;&#20250;&#22312; + <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="special">);</span></code> &#20013;&#25243;&#20986;&#24322;&#24120;&#65292;&#36825;&#26102;&#26500;&#36896;&#20989;&#25968;&#26080;&#25928;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">opt</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">ref</span> <span class="special">)</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Directly-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#30452;&#25509;&#26500;&#36896;&#19968;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span> + and its value is an instance of an internal type wrapping the reference + <code class="computeroutput"><span class="identifier">ref</span></code>.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026; + <span class="underline">&#24050;&#21021;&#22987;&#21270;&#30340;</span>&#65292;&#23427;&#30340;&#20540;&#20026;&#26576;&#20010;&#20869;&#37096;&#31867;&#22411;&#30340;&#23454;&#20363;&#65292;&#21253;&#35013;&#20102;&#24341;&#29992; + <code class="computeroutput"><span class="identifier">ref</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Nothing.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span>&#26080;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span> +<span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">vref</span> <span class="special">=</span> <span class="identifier">v</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> <span class="identifier">opt</span><span class="special">(</span><span class="identifier">vref</span><span class="special">);</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> +<span class="special">++</span> <span class="identifier">v</span> <span class="special">;</span> <span class="comment">// mutate referee +</span><span class="identifier">assert</span> <span class="special">(*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">v</span><span class="special">);</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_constructor_bool_value"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> + <span class="special">::</span><span class="identifier">optional</span><span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> + <span class="identifier">T</span><span class="special">&amp;</span>
+          <span class="identifier">v</span> <span class="special">)</span>
+          <span class="special">;</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc"><li>
+ If condition is true, same as:<br> &#22914;&#26524; condition &#20026; true, &#21017;&#30456;&#24403;&#20110;&#65306;
+      </li></ul></div>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> + <span class="special">::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">T</span><span class="special">&amp;</span> + <span class="identifier">v</span> <span class="special">)</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc"><li>
+ otherwise, same as:<br> &#21542;&#21017;&#30456;&#24403;&#20110;&#65306;
+      </li></ul></div>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span> <span class="special">[</span><span class="error">'</span><span class="special">(</span><span class="keyword">not</span> <span class="identifier">a</span> + <span class="identifier">ref</span><span class="special">)]&gt;::</span><span class="identifier">optional</span><span class="special">()</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> + <span class="special">::</span><span class="identifier">optional</span><span class="special">()</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_constructor_optional"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span> </code><span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">optional</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="identifier">rhs</span> <span class="special">);</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#22797;&#21046;&#26500;&#36896;&#19968;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span> If rhs is initialized, + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value + of <code class="computeroutput"><span class="identifier">rhs</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span>&#22914;&#26524; <code class="computeroutput"><span class="identifier">rhs</span></code> + &#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#20026;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#19988;&#20540;&#20026; <code class="computeroutput"><span class="identifier">rhs</span></code> + &#30340;&#20540;&#30340;<span class="emphasis"><em>&#25335;&#36125;</em></span>&#65307;&#21542;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026;&#26410;&#21021;&#22987;&#21270;&#30340;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> throws.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> &#25152;&#25243;&#20986;&#30340;&#20219;&#20309;&#24322;&#24120;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span> If rhs is initialized, <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> is + called.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#22914;&#26524; <code class="computeroutput"><span class="identifier">rhs</span></code> &#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017;&#35843;&#29992; <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> .
+      </li>
+<li>
+<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be + thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="special">);</span></code> in that case, this constructor + has no effect.<br><span class="bold"><strong>&#24322;&#24120;&#23433;&#20840;&#24615;&#65306;</strong></span>&#20165;&#20250;&#22312; + <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="special">);</span></code> &#20013;&#25243;&#20986;&#24322;&#24120;&#65292;&#36825;&#26102;&#26500;&#36896;&#20989;&#25968;&#26080;&#25928;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">uninit</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(!</span><span class="identifier">uninit</span><span class="special">);</span>
+
+<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">uinit2</span> <span class="special">(</span> <span class="identifier">uninit</span> <span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">uninit2</span> <span class="special">==</span> <span class="identifier">uninit</span> <span class="special">);</span>
+
+<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">init</span><span class="special">(</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">);</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">init</span> <span class="special">==</span> <span class="identifier">T</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
+
+<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">init2</span> <span class="special">(</span> <span class="identifier">init</span> <span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">init2</span> <span class="special">==</span> <span class="identifier">init</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">);</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#22797;&#21046;&#26500;&#36896;&#19968;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code> + is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is initialized and its value is another reference to the same object referenced + by <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>; + else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is uninitialized.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span>&#22914;&#26524; + <code class="computeroutput"><span class="identifier">rhs</span></code> &#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017; + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#20026;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#19988;&#20540;&#20026; <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> &#25152;&#24341;&#29992;&#30340;&#21516;&#19968;&#20010;&#23545;&#35937;&#30340;&#21478;&#19968;&#20010;&#24341;&#29992;&#65307;&#21542;&#21017; + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
+        &#20026;&#26410;&#21021;&#22987;&#21270;&#30340;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Nothing.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span>&#26080;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code> + is initialized, both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + and <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> + will reefer to the same object (they alias).<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#22914;&#26524; + <code class="computeroutput"><span class="identifier">rhs</span></code> &#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017; + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#19982; <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> + &#22343;&#24341;&#21521;&#21516;&#19968;&#20010;&#23545;&#35937;(&#23427;&#20204;&#20114;&#20026;&#21035;&#21517;)&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> <span class="identifier">uninit</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(!</span><span class="identifier">uninit</span><span class="special">);</span>
+
+<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> <span class="identifier">uinit2</span> <span class="special">(</span> <span class="identifier">uninit</span> <span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">uninit2</span> <span class="special">==</span> <span class="identifier">uninit</span> <span class="special">);</span>
+
+<span class="identifier">T</span> <span class="identifier">v</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">ref</span> <span class="special">=</span> <span class="identifier">v</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">init</span><span class="special">(</span><span class="identifier">ref</span><span class="special">);</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">init</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
+
+<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">init2</span> <span class="special">(</span> <span class="identifier">init</span> <span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">init2</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
+
+<span class="identifier">v</span> <span class="special">=</span> <span class="number">3</span> <span class="special">;</span>
+
+<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">init</span> <span class="special">==</span> <span class="number">3</span> <span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">init2</span> <span class="special">==</span> <span class="number">3</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_constructor_other_optional"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span> <span class="keyword">explicit</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> + <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">);</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#22797;&#21046;&#26500;&#36896;&#19968;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code> + is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value + of rhs converted to type <code class="computeroutput"><span class="identifier">T</span></code>; + else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is uninitialized.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span>&#22914;&#26524; + <code class="computeroutput"><span class="identifier">rhs</span></code> &#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017; + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#20026;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#19988;&#20540;&#20026; <code class="computeroutput"><span class="identifier">rhs</span></code> + &#36716;&#25442;&#20026;&#31867;&#22411;T&#30340;&#20540;&#30340;&#25335;&#36125;&#65307;&#21542;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026;&#26410;&#21021;&#22987;&#21270;&#30340;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">U</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> throws.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">U</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> &#25152;&#25243;&#20986;&#30340;&#20219;&#20309;&#24322;&#24120;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes: </strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">U</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> is + called if <code class="computeroutput"><span class="identifier">rhs</span></code> is initialized, + which requires a valid conversion from <code class="computeroutput"><span class="identifier">U</span></code> + to <code class="computeroutput"><span class="identifier">T</span></code>.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#22914;&#26524; + <code class="computeroutput"><span class="identifier">rhs</span></code> &#24050;&#21021;&#22987;&#21270;&#65292;&#21017;&#35843;&#29992; + <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">U</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="special">)</span></code>, &#35201;&#27714;&#26377;&#20174; <code class="computeroutput"><span class="identifier">U</span></code> + &#21040; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#26377;&#25928;&#36716;&#25442;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be + thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">U</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="special">);</span></code> in that case, this constructor + has no effect.<br><span class="bold"><strong>&#24322;&#24120;&#23433;&#20840;&#24615;&#65306;</strong></span>&#20165;&#20250;&#22312; + <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">U</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="special">);</span></code> &#20013;&#25243;&#20986;&#24322;&#24120;&#65292;&#36825;&#26102;&#26500;&#36896;&#20989;&#25968;&#26080;&#25928;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">x</span><span class="special">(</span><span class="number">123.4</span><span class="special">);</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">x</span> <span class="special">==</span> <span class="number">123.4</span> <span class="special">)</span> <span class="special">;</span>
+
+<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">y</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span><span class="special">(</span> <span class="special">*</span><span class="identifier">y</span> <span class="special">==</span> <span class="number">123</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_constructor_factory"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="identifier">InPlaceFactory</span><span class="special">&gt;</span> + <span class="keyword">explicit</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> + <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">f</span> <span class="special">);</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="identifier">TypedInPlaceFactory</span><span class="special">&gt;</span> + <span class="keyword">explicit</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> + <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="identifier">optional</span><span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">f</span> <span class="special">);</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Constructs an <code class="computeroutput"><span class="identifier">optional</span></code> + with a value of <code class="computeroutput"><span class="identifier">T</span></code> obtained + from the factory.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#26500;&#36896;&#19968;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code>&#65292;<code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#20540;&#20174;&#24037;&#21378;&#33719;&#24471;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span> + and its value is <span class="emphasis"><em>directly given</em></span> from the factory <code class="computeroutput"><span class="identifier">f</span></code> (i.e., the value <span class="underline">is + not copied</span>).<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code><span class="underline">&#24050;&#21021;&#22987;&#21270;</span> &#19988;&#20854;&#20540;<span class="emphasis"><em>&#30452;&#25509;</em></span>&#30001;&#24037;&#21378; + <code class="computeroutput"><span class="identifier">f</span></code> &#21462;&#24471;(&#21363;&#35813;&#20540;<span class="underline">&#19981;&#26159;&#22797;&#21046;&#30340;</span>)&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Whatever the <code class="computeroutput"><span class="identifier">T</span></code> + constructor called by the factory throws.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span>&#30001;&#24037;&#21378;&#25152;&#35843;&#29992;&#30340; + <code class="computeroutput"><span class="identifier">T</span></code> &#26500;&#36896;&#20989;&#25968;&#25152;&#25243;&#20986;&#30340;&#20219;&#20309;&#24322;&#24120;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span> See <a class="link" href="in_place_factories.html" title="In-Place Factories &#23601;&#22320;&#21019;&#24314;">In-Place + Factories</a><br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#35831;&#35265; + <a class="link" href="in_place_factories.html" title="In-Place Factories &#23601;&#22320;&#21019;&#24314;">&#23601;&#22320;&#21019;&#24314;</a>
+</li>
+<li>
+<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be + thrown during the call to the <code class="computeroutput"><span class="identifier">T</span></code> + constructor used by the factory; in that case, this constructor has no effect.<br><span class="bold"><strong>&#24322;&#24120;&#23433;&#20840;&#24615;&#65306;</strong></span>&#20165;&#20250;&#22312;&#24037;&#21378;&#35843;&#29992; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#26500;&#36896;&#20989;&#25968;&#26102;&#25243;&#20986;&#24322;&#24120;&#65292;&#36825;&#26102;&#26500;&#36896;&#20989;&#25968;&#26080;&#25928;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="keyword">class</span> <span class="identifier">C</span> <span class="special">{</span> <span class="identifier">C</span> <span class="special">(</span> <span class="keyword">char</span><span class="special">,</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">)</span> <span class="special">;</span> <span class="special">}</span> <span class="special">;</span>
+
+<span class="identifier">C</span> <span class="identifier">v</span><span class="special">(</span><span class="char">'A'</span><span class="special">,</span><span class="number">123.4</span><span class="special">,</span><span class="string">"hello"</span><span class="special">);</span>
+
+<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">&gt;</span> <span class="identifier">x</span><span class="special">(</span> <span class="identifier">in_place</span> <span class="special">(</span><span class="char">'A'</span><span class="special">,</span> <span class="number">123.4</span><span class="special">,</span> <span class="string">"hello"</span><span class="special">)</span> <span class="special">);</span> <span class="comment">// InPlaceFactory used +</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">&gt;</span> <span class="identifier">y</span><span class="special">(</span> <span class="identifier">in_place</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">&gt;(</span><span class="char">'A'</span><span class="special">,</span> <span class="number">123.4</span><span class="special">,</span> <span class="string">"hello"</span><span class="special">)</span> <span class="special">);</span> <span class="comment">// TypedInPlaceFactory used
+</span>
+<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">x</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">y</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_operator_equal_value"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&amp;</span> + <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="identifier">rhs</span> <span class="special">)</span>
+          <span class="special">;</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">rhs</span></code> to an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#23558;&#20540; <code class="computeroutput"><span class="identifier">rhs</span></code> + &#36171;&#32473;&#19968;&#20010; <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and its value is a <span class="emphasis"><em>copy</em></span> + of <code class="computeroutput"><span class="identifier">rhs</span></code>.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#20854;&#20540;&#20026; + <code class="computeroutput"><span class="identifier">rhs</span></code> &#30340;<span class="emphasis"><em>&#25335;&#36125;</em></span>&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> or + <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;)</span></code> + throws.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span>&#30001; <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> &#25110; + <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;)</span></code>
+        &#25243;&#20986;&#30340;&#20219;&#20309;&#24322;&#24120;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s + assignment operator is used, otherwise, its copy-constructor is used.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#22914;&#26524; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017;&#20351;&#29992; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#36171;&#20540;&#25805;&#20316;&#31526;&#65292;&#21542;&#21017;&#20351;&#29992;&#23427;&#30340;&#22797;&#21046;&#26500;&#36896;&#20989;&#25968;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception, + the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified + as far as <code class="computeroutput"><span class="identifier">optional</span></code> is concerned + (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s <code class="computeroutput"><span class="keyword">operator</span><span class="special">=()</span></code>). + If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s + <span class="emphasis"><em>copy constructor</em></span> fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.<br><span class="bold"><strong>&#24322;&#24120;&#23433;&#20840;&#24615;&#65306;</strong></span>&#22914;&#26524;&#21457;&#29983;&#24322;&#24120;&#65292;<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#30340;&#21021;&#22987;&#21270;&#29366;&#24577;&#19981;&#20250;&#25913;&#21464;&#65292;&#23427;&#30340;&#20540;&#26159;&#19981;&#30830;&#23450;&#30340;&#30452;&#33267; + <code class="computeroutput"><span class="identifier">optional</span></code> &#34987;&#20851;&#32852;(&#30001; <code class="computeroutput"><span class="identifier">T</span></code> &#30340; <code class="computeroutput"><span class="keyword">operator</span><span class="special">=()</span></code> &#36827;&#34892;)&#12290; &#22914; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#21407;&#26469;&#26159;&#26410;&#21021;&#22987;&#21270;&#30340;&#65292;&#19988; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;<span class="emphasis"><em>&#22797;&#21046;&#26500;&#36896;&#20989;&#25968;</em></span> + &#22833;&#36133;&#20102;&#65292;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
+        &#20173;&#20026;&#26410;&#21021;&#22987;&#21270;&#30340;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">def</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">opt</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">;</span>
+
+<span class="identifier">T</span> <span class="identifier">y</span><span class="special">;</span> +<span class="identifier">def</span> <span class="special">=</span> <span class="identifier">y</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">def</span> <span class="special">==</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> +<span class="identifier">opt</span> <span class="special">=</span> <span class="identifier">y</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;&amp;</span> + <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span><span class="special">&amp;</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="identifier">rhs</span> <span class="special">)</span>
+          <span class="special">;</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> (Re)binds thee wrapped reference.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>(&#37325;)&#32465;&#23450;&#34987;&#21253;&#35013;&#30340;&#24341;&#29992;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and it references the + same object referenced by <code class="computeroutput"><span class="identifier">rhs</span></code>.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#24050;&#21021;&#22987;&#21270;&#19988;&#24341;&#21521;&#30001; <code class="computeroutput"><span class="identifier">rhs</span></code> &#25152;&#24341;&#21521;&#30340;&#23545;&#35937;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized, is is <span class="emphasis"><em>rebound</em></span> + to the new object. See <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;">here</a> + for details on this behavior.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#22914;&#26524; + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#24050;&#21021;&#22987;&#21270;&#65292;&#21017;<span class="emphasis"><em>&#37325;&#32465;&#23450;</em></span>&#21040;&#26032;&#30340;&#23545;&#35937;&#12290;&#26377;&#20851;&#32454;&#33410;&#35831;&#35265; + <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;">&#36825;&#37324;</a>&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span> +<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span> +<span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span> +<span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">def</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">opt</span><span class="special">(</span><span class="identifier">ra</span><span class="special">)</span> <span class="special">;</span>
+
+<span class="identifier">def</span> <span class="special">=</span> <span class="identifier">rb</span> <span class="special">;</span> <span class="comment">// binds 'def' to 'b' through 'rb' +</span><span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">def</span> <span class="special">==</span> <span class="identifier">b</span> <span class="special">)</span> <span class="special">;</span> +<span class="special">*</span><span class="identifier">def</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span> <span class="comment">// changes the value of 'b' to a copy of the value of 'a' +</span><span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">b</span> <span class="special">==</span> <span class="identifier">a</span> <span class="special">)</span> <span class="special">;</span> +<span class="keyword">int</span> <span class="identifier">c</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span> +<span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">rc</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">;</span> +<span class="identifier">opt</span> <span class="special">=</span> <span class="identifier">rc</span> <span class="special">;</span> <span class="comment">// REBINDS to 'c' through 'rc' +</span><span class="identifier">c</span> <span class="special">=</span> <span class="number">4</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="number">4</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_operator_equal_optional"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&amp;</span> + <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span> + <span class="keyword">const</span><span class="special">&amp;</span> + <span class="identifier">rhs</span> <span class="special">)</span>
+          <span class="special">;</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> Assigns another <code class="computeroutput"><span class="identifier">optional</span></code> + to an <code class="computeroutput"><span class="identifier">optional</span></code>.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>&#23558;&#21478;&#19968;&#20010; <code class="computeroutput"><span class="identifier">optional</span></code> + &#36171;&#20540;&#32473;&#19968;&#20010; <code class="computeroutput"><span class="identifier">optional</span></code>.
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code> + is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value + of <code class="computeroutput"><span class="identifier">rhs</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span>&#22914;&#26524; <code class="computeroutput"><span class="identifier">rhs</span></code> + &#24050;&#21021;&#22987;&#21270;&#65292;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#20026;&#24050;&#21021;&#22987;&#21270;&#19988;&#20854;&#20540;&#20026; <code class="computeroutput"><span class="identifier">rhs</span></code> + &#20540;&#30340;<span class="emphasis"><em>&#25335;&#36125;</em></span>&#65307;&#21542;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026;&#26410;&#21021;&#22987;&#21270;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;)</span></code> or <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> throws.<br><span class="bold"><strong>&#25243;&#20986;&#65306;</strong></span>&#30001; <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;)</span></code> &#25110; <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> &#25243;&#20986;&#30340;&#20219;&#20309;&#24322;&#24120;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span> If both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and <code class="computeroutput"><span class="identifier">rhs</span></code> + are initially initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s + <span class="emphasis"><em>assignment operator</em></span> is used. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially initialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is uninitialized, <code class="computeroutput"><span class="identifier">T</span></code>'s + [destructor] is called. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially uninitialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s + <span class="emphasis"><em>copy constructor</em></span> is called.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#22914;&#26524; + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#21644; <code class="computeroutput"><span class="identifier">rhs</span></code> &#22343;&#24050;&#21021;&#22987;&#21270;&#65292;&#21017;&#20351;&#29992; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340; <span class="emphasis"><em>&#36171;&#20540;&#25805;&#20316;&#31526;</em></span>&#12290; + &#22914;&#26524; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#24050;&#21021;&#22987;&#21270;&#32780; <code class="computeroutput"><span class="identifier">rhs</span></code> &#26410;&#21021;&#22987;&#21270;&#65292;&#21017;&#35843;&#29992; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340; <span class="emphasis"><em>&#26512;&#26500;&#20989;&#25968;</em></span>&#12290; + &#22914;&#26524; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#26410;&#21021;&#22987;&#21270;&#32780; <code class="computeroutput"><span class="identifier">rhs</span></code> &#24050;&#21021;&#22987;&#21270;&#65292;&#21017;&#35843;&#29992; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340; <span class="emphasis"><em>&#22797;&#21046;&#26500;&#36896;&#20989;&#25968;</em></span>&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception, + the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified + as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s + <code class="computeroutput"><span class="keyword">operator</span><span class="special">=()</span></code>). + If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s + <span class="emphasis"><em>copy constructor</em></span> fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.<br><span class="bold"><strong>&#24322;&#24120;&#23433;&#20840;&#24615;&#65306;</strong></span>&#21457;&#29983;&#24322;&#24120;&#26102;&#65292;<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#30340;&#21021;&#22987;&#21270;&#29366;&#24577;&#19981;&#25913;&#21464;&#65292;&#20854;&#20540;&#26159;&#19981;&#30830;&#23450;&#30340;&#30452;&#33267; + <code class="computeroutput"><span class="identifier">optional</span></code> &#34987;&#20851;&#32852;(&#30001; T + &#30340; <code class="computeroutput"><span class="keyword">operator</span><span class="special">=()</span></code> + &#36827;&#34892;)&#12290; &#22914;&#26524; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#21407;&#26469;&#26159;&#26410;&#21021;&#22987;&#21270;&#30340;&#32780;&#19988; <code class="computeroutput"><span class="identifier">T</span></code> + &#30340; <span class="emphasis"><em>&#22797;&#21046;&#26500;&#36896;&#20989;&#25968;</em></span> &#22833;&#36133;&#65292;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20445;&#25345;&#20026;&#26410;&#21021;&#22987;&#21270;]
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">opt</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">def</span> <span class="special">;</span>
+
+<span class="identifier">opt</span> <span class="special">=</span> <span class="identifier">def</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">def</span> <span class="special">)</span> <span class="special">;</span> +<span class="comment">// previous value (copy of 'v') destroyed from within 'opt'. +</span><span class="comment">// 'opt'&#30340;&#21407;&#20540;('v'&#30340;&#25335;&#36125;)&#34987;&#38144;&#27585;
+</span></pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
+        </p>
+<p>
+ <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> + <span class="special">&amp;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span></code>
+        </p>
+<p>
+      </p>
+</blockquote></div>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Effect:</strong></span> (Re)binds thee wrapped reference.<br><span class="bold"><strong>&#20316;&#29992;&#65306;</strong></span>(&#37325;)&#32465;&#23450;&#34987;&#21253;&#35013;&#30340;&#24341;&#29992;&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and it references the + same object referenced by <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>; otherwise, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized (and references no object).<br><span class="bold"><strong>&#21518;&#32493;&#26465;&#20214;&#65306;</strong></span>&#22914;&#26524; <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> &#24050;&#21021;&#22987;&#21270;&#65292;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026;&#24050;&#21021;&#22987;&#21270;&#30340;&#19988;&#24341;&#21521;&#19988;&#24341;&#21521;&#30001; + <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> + &#25152;&#24341;&#21521;&#30340;&#23545;&#35937;&#65307;&#21542;&#21017; <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> &#20026;&#26410;&#21021;&#22987;&#21270;(&#19981;&#24341;&#21521;&#20219;&#20309;&#23545;&#35937;)&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized and so is *rhs, this + is is <span class="emphasis"><em>rebound</em></span> to the new object. See <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;">here</a> + for details on this behavior.<br><span class="bold"><strong>&#35828;&#26126;&#65306;</strong></span>&#22914;&#26524; + <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + &#24050;&#21021;&#22987;&#21270;&#19988; <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> + &#20063;&#26159;&#65292;&#21017;<span class="emphasis"><em>&#37325;&#32465;&#23450;</em></span>&#21040;&#26032;&#30340;&#23545;&#35937;&#12290;&#26377;&#20851;&#32454;&#33410;&#35831;&#35265; + <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;">&#36825;&#37324;</a>&#12290;
+      </li>
+<li>
+<span class="bold"><strong>Example:</strong></span><br><span class="bold"><strong>&#20363;&#23376;&#65306;</strong></span><pre class="programlisting"><span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span> +<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span> +<span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span> +<span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">def</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">ora</span><span class="special">(</span><span class="identifier">ra</span><span class="special">)</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">orb</span><span class="special">(</span><span class="identifier">rb</span><span class="special">)</span> <span class="special">;</span>
+
+<span class="identifier">def</span> <span class="special">=</span> <span class="identifier">orb</span> <span class="special">;</span> <span class="comment">// binds 'def' to 'b' through 'rb' wrapped within 'orb' +</span><span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">def</span> <span class="special">==</span> <span class="identifier">b</span> <span class="special">)</span> <span class="special">;</span> +<span class="special">*</span><span class="identifier">def</span> <span class="special">=</span> <span class="identifier">ora</span> <span class="special">;</span> <span class="comment">// changes the value of 'b' to a copy of the value of 'a' +</span><span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">b</span> <span class="special">==</span> <span class="identifier">a</span> <span class="special">)</span> <span class="special">;</span> +<span class="keyword">int</span> <span class="identifier">c</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span> +<span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">rc</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">;</span> +<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">orc</span><span class="special">(</span><span class="identifier">rc</span><span class="special">)</span> <span class="special">;</span> +<span class="identifier">ora</span> <span class="special">=</span> <span class="identifier">orc</span> <span class="special">;</span> <span class="comment">// REBINDS ora to 'c' through 'rc' +</span><span class="identifier">c</span> <span class="special">=</span> <span class="number">4</span> <span class="special">;</span> +<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">ora</span> <span class="special">==</span> <span class="number">4</span> <span class="special">)</span> <span class="special">;</span>
+</pre>
+</li>
+</ul></div>
+<p>
+ <span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
+    </p>
+<a name="reference_optional_operator_equal_other_optional"></a><p>
+    </p>
+<div class="blockquote"><blockquote class="blockquote">
+<p>
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/development.html Tue Nov 25 06:14:27 2008 +++ /trunk/libs/optional/doc/html/boost_optional/development.html Wed Mar 24 00:54:49 2010
@@ -1,339 +1,532 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html><head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-
- <title>Development</title><link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-  <link rel="next" href="synopsis.html" title="Synopsis"></head>
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Development &#21457;&#23637;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional">
+<link rel="next" href="synopsis.html" title="Synopsis &#25688;&#35201;">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="../index.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="synopsis.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.development"></a><a class="link" href="development.html" title="Development">发展</a>
-</h2>
-</div>
-</div>
-</div>
-
-<div class="toc">
-<dl>
-
- <dt><span class="section"><a href="development.html#boost_optional.development.the_models">模型 </a></span></dt>
-
- <dt><span class="section"><a href="development.html#boost_optional.development.the_semantics">语义 </a></span></dt>
-
- <dt><span class="section"><a href="development.html#boost_optional.development.the_interface">接口 </a></span></dt>
-
-</dl>
-</div>
-
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.development"></a><a class="link" href="development.html" title="Development &#21457;&#23637;"> Development &#21457;&#23637;</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="development.html#boost_optional.development.the_models"> The models &#27169;&#22411;</a></span></dt> +<dt><span class="section"><a href="development.html#boost_optional.development.the_semantics"> The semantics
+      &#35821;&#20041;</a></span></dt>
+<dt><span class="section"><a href="development.html#boost_optional.development.the_interface"> The Interface
+      &#25509;&#21475;</a></span></dt>
+</dl></div>
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h3 class="title">
-<a name="boost_optional.development.the_models"></a><a class="link" href="development.html#boost_optional.development.the_models" title="The models">模型</a>
-</h3>
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_optional.development.the_models"></a><a class="link" href="development.html#boost_optional.development.the_models" title="The models &#27169;&#22411;"> The models &#27169;&#22411;</a>
+</h3></div></div></div>
+<p>
+ In C++, we can <span class="emphasis"><em>declare</em></span> an object (a variable) of type + <code class="computeroutput"><span class="identifier">T</span></code>, and we can give this variable + an <span class="emphasis"><em>initial value</em></span> (through an <span class="emphasis"><em>initializer</em></span>. + (c.f. 8.5)). When a declaration includes a non-empty initializer (an initial + value is given), it is said that the object has been initialized. If the + declaration uses an empty initializer (no initial value is given), and neither + default nor value initialization applies, it is said that the object is + <span class="bold"><strong>uninitialized</strong></span>. Its actual value exist but + has an <span class="emphasis"><em>indeterminate initial value</em></span> (c.f. 8.5.9). <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> intends + to formalize the notion of initialization (or lack of it) allowing a program + to test whether an object has been initialized and stating that access to + the value of an uninitialized object is undefined behavior. That is, when + a variable is declared as <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + and no initial value is given, the variable is <span class="emphasis"><em>formally</em></span> + uninitialized. A formally uninitialized optional object has conceptually + no value at all and this situation can be tested at runtime. It is formally + <span class="emphasis"><em>undefined behavior</em></span> to try to access the value of an + uninitialized optional. An uninitialized optional can be assigned a value, + in which case its initialization state changes to initialized. Furthermore, + given the formal treatment of initialization states in optional objects, + it is even possible to reset an optional to <span class="emphasis"><em>uninitialized</em></span>.<br> + &#22312;C++&#20013;&#65292;&#25105;&#20204;&#21487;&#20197;<span class="emphasis"><em>&#22768;&#26126;</em></span>&#31867;&#22411; <code class="computeroutput"><span class="identifier">T</span></code> + &#30340;&#19968;&#20010;&#23545;&#35937;(&#21464;&#37327;)&#65292;&#24182;&#19988;&#25105;&#20204;&#21487;&#20197;&#32473;&#36825;&#20010;&#23545;&#35937;&#19968;&#20010;<span class="emphasis"><em>&#21021;&#22987;&#20540;</em></span>(&#36890;&#36807;<span class="emphasis"><em>&#21021;&#22987;&#21270;</em></span>(&#21442;&#32771; + 8.5))&#12290; &#24403;&#19968;&#20010;&#22768;&#26126;&#20013;&#21253;&#21547;&#38750;&#31354;&#30340;&#21021;&#22987;&#21270;(&#21363;&#32473;&#20986;&#19968;&#20010;&#21021;&#22987;&#20540;)&#65292;&#23601;&#31216;&#36825;&#20010;&#23545;&#35937;&#24050;&#34987;&#21021;&#22987;&#21270;&#12290; + &#22914;&#26524;&#19968;&#20010;&#22768;&#26126;&#20351;&#29992;&#20102;&#31354;&#30340;&#21021;&#22987;&#21270;(&#21363;&#26410;&#32473;&#20986;&#21021;&#22987;&#20540;)&#65292;&#32780;&#19988;&#20063;&#27809;&#32570;&#30465;&#20540;&#21487;&#29992;&#20110;&#21021;&#22987;&#21270;&#65292;&#21017;&#31216;&#35813;&#23545;&#35937;&#26159;<span class="bold"><strong>&#26410;&#21021;&#22987;&#21270;&#30340;</strong></span>&#12290; &#23427;&#30340;&#30495;&#23454;&#20540;&#26159;&#23384;&#22312;&#30340;&#65292;&#20294;&#20855;&#26377;&#19968;&#20010;<span class="emphasis"><em>&#19981;&#30830;&#23450;&#30340;&#21021;&#22987;&#20540;</em></span>(&#21442;&#32771; + 8.5.9)&#12290; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#30340;&#30446;&#30340;&#26159;&#35268;&#33539;&#21021;&#22987;&#21270;(&#25110;&#26080;&#21021;&#22987;&#21270;)&#30340;&#27010;&#24565;&#65292;&#35753;&#31243;&#24207;&#21487;&#20197;&#26816;&#27979;&#19968;&#20010;&#23545;&#35937;&#26159;&#21542;&#24050;&#21021;&#22987;&#21270;&#65292; + &#24182;&#35268;&#23450;&#35775;&#38382;&#19968;&#20010;&#26410;&#21021;&#22987;&#21270;&#23545;&#35937;&#30340;&#20540;&#26159;&#26410;&#23450;&#20041;&#30340;&#34892;&#20026;&#12290;&#21363;&#65292;&#22914;&#26524;&#19968;&#20010;&#21464;&#37327;&#34987;&#22768;&#26126;&#20026; + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#32780;&#26410;&#32473;&#23450;&#21021;&#22987;&#20540;&#65292;&#21017;&#35813;&#21464;&#37327;&#23601;&#26159;<span class="emphasis"><em>&#27491;&#24335;&#30340;</em></span>&#26410;&#21021;&#22987;&#21270;&#12290; + &#19968;&#20010;&#27491;&#24335;&#30340;&#26410;&#21021;&#22987;&#21270;&#30340; optional &#23545;&#35937;&#26159;&#27809;&#26377;&#20540;&#30340;&#65292;&#24182;&#19988;&#21487;&#20197;&#22312;&#36816;&#34892;&#26399;&#23545;&#27492;&#29366;&#24577;&#36827;&#34892;&#27979;&#35797;&#12290; + &#23581;&#35797;&#35775;&#38382;&#19968;&#20010;&#26410;&#21021;&#22987;&#21270;&#30340; optional &#34987;&#27491;&#24335;&#35268;&#23450;&#20026;<span class="emphasis"><em>&#26410;&#23450;&#20041;&#34892;&#20026;</em></span>&#12290;&#19968;&#20010;&#26410;&#21021;&#22987;&#21270;&#30340; + optional &#21487;&#20197;&#34987;&#36171;&#20104;&#19968;&#20010;&#20540;&#65292;&#36825;&#26102;&#23427;&#30340;&#21021;&#22987;&#21270;&#29366;&#24577;&#23601;&#20250;&#21464;&#20026;&#24050;&#21021;&#22987;&#21270;&#12290; + &#27492;&#22806;&#65292;&#36824;&#32473;&#20986;&#22788;&#29702; optional &#23545;&#35937;&#30340;&#21021;&#22987;&#21270;&#29366;&#24577;&#30340;&#26041;&#27861;&#65292;&#29978;&#33267;&#21487;&#20197;&#23558;&#19968;&#20010; + optional &#37325;&#26032;&#32622;&#20026;<span class="emphasis"><em>&#26410;&#21021;&#22987;&#21270;</em></span>&#12290;
+      </p>
+<p>
+ In C++ there is no formal notion of uninitialized objects, which means that + objects always have an initial value even if indeterminate. As discussed + on the previous section, this has a drawback because you need additional + information to tell if an object has been effectively initialized. One of + the typical ways in which this has been historically dealt with is via a + special value: <code class="computeroutput"><span class="identifier">EOF</span></code>, <code class="computeroutput"><span class="identifier">npos</span></code>, -1, etc... This is equivalent to + adding the special value to the set of possible values of a given type. This + super set of <code class="computeroutput"><span class="identifier">T</span></code> plus some + <span class="emphasis"><em>nil_t</em></span>&#8212;were <code class="computeroutput"><span class="identifier">nil_t</span></code> + is some stateless POD-can be modeled in modern languages as a <span class="bold"><strong>discriminated + union</strong></span> of T and nil_t. Discriminated unions are often called <span class="emphasis"><em>variants</em></span>. + A variant has a <span class="emphasis"><em>current type</em></span>, which in our case is either + <code class="computeroutput"><span class="identifier">T</span></code> or <code class="computeroutput"><span class="identifier">nil_t</span></code>. + Using the <a href="../../../../variant/index.html" target="_top">Boost.Variant</a> + library, this model can be implemented in terms of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">nil_t</span><span class="special">&gt;</span></code>. + There is precedent for a discriminated union as a model for an optional value: + the <a href="http://www.haskell.org/"; target="_top">Haskell</a> <span class="bold"><strong>Maybe</strong></span> + built-in type constructor. Thus, a discriminated union <code class="computeroutput"><span class="identifier">T</span><span class="special">+</span><span class="identifier">nil_t</span></code> + serves as a conceptual foundation.<br> &#22312;C++&#37324;&#27809;&#26377;&#26410;&#21021;&#22987;&#21270;&#23545;&#35937;&#30340;&#27491;&#24335;&#27010;&#24565;&#65292;&#21363;&#26159;&#35828;&#23545;&#35937;&#24635;&#26159;&#24102;&#26377;&#21021;&#22987;&#20540;&#30340;&#65292;&#21363;&#20351;&#26159;&#19981;&#30830;&#23450;&#30340;&#20540;&#12290; + &#27491;&#22914;&#21069;&#38754;&#25152;&#35752;&#35770;&#30340;&#65292;&#36825;&#26679;&#26377;&#19968;&#20010;&#32570;&#28857;&#65292;&#22240;&#20026;&#20320;&#38656;&#35201;&#29992;&#39069;&#22806;&#30340;&#20449;&#24687;&#26469;&#21578;&#30693;&#19968;&#20010;&#23545;&#35937;&#26159;&#19981;&#26159;&#24050;&#32463;&#34987;&#26377;&#25928;&#22320;&#21021;&#22987;&#21270;&#20102;&#12290; + &#19968;&#31181;&#20197;&#21069;&#24120;&#29992;&#30340;&#20856;&#22411;&#26041;&#27861;&#26159;&#20351;&#29992;&#29305;&#27530;&#20540;&#65306;<code class="computeroutput"><span class="identifier">EOF</span></code>, + <code class="computeroutput"><span class="identifier">npos</span></code>, -1, &#31561;&#31561;... &#36825;&#30456;&#24403;&#20110;&#22686;&#21152;&#19968;&#20010;&#29305;&#27530;&#20540;&#21040;&#32473;&#23450;&#31867;&#22411;&#30340;&#21487;&#21462;&#20540;&#30340;&#38598;&#21512;&#20013;&#12290; + &#30001; <code class="computeroutput"><span class="identifier">T</span></code> &#21152;&#19978;&#26576;&#20010; <span class="emphasis"><em>nil_t</em></span> + &#8212; <code class="computeroutput"><span class="identifier">nil_t</span></code> &#26159;&#26576;&#20010;&#26080;&#29366;&#24577;&#30340;POD + -- &#32452;&#25104;&#30340;&#36229;&#38598;&#22312;&#29616;&#20195;&#35821;&#35328;&#20013;&#21487;&#20197;&#34987;&#27169;&#20223;&#20026;&#30001; T &#21644; nil_t &#32452;&#25104;&#30340;&#19968;&#20010;<span class="bold"><strong>&#21487;&#35782;&#21035;&#32852;&#21512;</strong></span>&#12290; &#21487;&#35782;&#21035;&#32852;&#21512;&#36890;&#24120;&#31216;&#20026; <span class="emphasis"><em>variants</em></span>. + &#19968;&#20010; variant &#20855;&#26377; <span class="emphasis"><em>&#24403;&#21069;&#31867;&#22411;</em></span>&#65292;&#22312;&#25105;&#20204;&#30340;&#20363;&#23376;&#20013;&#23601;&#26159; + <code class="computeroutput"><span class="identifier">T</span></code> &#25110;&#32773; <code class="computeroutput"><span class="identifier">nil_t</span></code>. + &#20351;&#29992; <a href="../../../../variant/index.html" target="_top">Boost.Variant</a> &#24211;&#65292;&#20197;&#19978;&#27169;&#22411;&#21487;&#20197;&#29992; + <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">nil_t</span><span class="special">&gt;</span></code> &#26469;&#23454;&#29616;&#12290; &#29992;&#21487;&#35782;&#21035;&#32852;&#21512;&#26469;&#27169;&#20223;&#19968;&#20010; + optional &#20540;&#26159;&#26377;&#20808;&#20363;&#30340;&#65306;<a href="http://www.haskell.org/"; target="_top">Haskell</a> + &#30340; <span class="bold"><strong>Maybe</strong></span> &#20869;&#24314;&#31867;&#22411;&#26500;&#36896;&#22120;&#12290; &#25152;&#20197;&#65292;&#21487;&#35782;&#21035;&#32852;&#21512; + <code class="computeroutput"><span class="identifier">T</span><span class="special">+</span><span class="identifier">nil_t</span></code> &#21487;&#20197;&#20316;&#20026;&#19968;&#20010;&#27010;&#24565;&#19978;&#30340;&#22522;&#30784;&#12290;
+      </p>
+<p>
+ A <code class="computeroutput"><span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">nil_t</span><span class="special">&gt;</span></code> follows naturally from the traditional + idiom of extending the range of possible values adding an additional sentinel + value with the special meaning of <span class="emphasis"><em>Nothing</em></span>. However, + this additional <span class="emphasis"><em>Nothing</em></span> value is largely irrelevant + for our purpose since our goal is to formalize the notion of uninitialized + objects and, while a special extended value can be used to convey that meaning, + it is not strictly necessary in order to do so.<br> <code class="computeroutput"><span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">nil_t</span><span class="special">&gt;</span></code> + &#33258;&#28982;&#32780;&#28982;&#22320;&#21487;&#29992;&#20110;&#25193;&#23637;&#21487;&#21462;&#20540;&#30340;&#20256;&#32479;&#24815;&#29992;&#27861;&#65292;&#23427;&#22686;&#21152;&#19968;&#20010;"&#21736;&#20853;"&#20540;&#29992;&#20110;&#34920;&#31034;<span class="emphasis"><em>&#31354;&#20540;</em></span>&#12290; + &#19981;&#36807;&#65292;&#36825;&#20010;&#26032;&#22686;&#30340;<span class="emphasis"><em>&#31354;&#20540;</em></span>&#19982;&#25105;&#20204;&#24847;&#22270;&#22823;&#19981;&#30456;&#20851;&#65292;&#22240;&#20026;&#25105;&#20204;&#30340;&#30446;&#26631;&#26159;&#35268;&#33539;&#21270;&#26410;&#21021;&#22987;&#21270;&#23545;&#35937;&#30340;&#27010;&#24565;&#65292; + &#34429;&#28982;&#19968;&#20010;&#29305;&#27530;&#30340;&#25193;&#23637;&#20540;&#21487;&#20197;&#29992;&#20110;&#34920;&#36798;&#36825;&#20010;&#24847;&#24605;&#65292;&#20294;&#26159;&#23427;&#24182;&#19981;&#26159;&#20005;&#26684;&#24517;&#35201;&#30340;&#12290;
+      </p>
+<p>
+ The observation made in the last paragraph about the irrelevant nature of + the additional <code class="computeroutput"><span class="identifier">nil_t</span></code> with + respect to <span class="underline">purpose</span> of <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> suggests + an alternative model: a <span class="emphasis"><em>container</em></span> that either has a + value of <code class="computeroutput"><span class="identifier">T</span></code> or nothing.<br> + &#26368;&#36817;&#30340;&#30740;&#31350;&#34920;&#26126;&#65292;&#39069;&#22806;&#30340; <code class="computeroutput"><span class="identifier">nil_t</span></code> + &#23545;&#20110; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#30340; + <span class="underline">&#30446;&#30340;</span> &#26159;&#26080;&#20851;&#30340;&#65292;&#25105;&#20204;&#24314;&#35758;&#21478;&#19968;&#31181;&#27169;&#22411;&#65306;&#19968;&#20010;<span class="emphasis"><em>&#23481;&#22120;</em></span>&#65292;&#23427;&#20855;&#26377; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#20540;&#65292;&#25110;&#32773;&#20026;&#31354;&#12290;
+      </p>
+<p>
+ As of this writing I don't know of any precedence for a variable-size fixed-capacity + (of 1) stack-based container model for optional values, yet I believe this + is the consequence of the lack of practical implementations of such a container + rather than an inherent shortcoming of the container model.<br> &#22312;&#20889;&#36825;&#31687;&#25991;&#26723;&#20043;&#26102;&#65292;&#25105;&#36824;&#19981;&#30693;&#36947;&#26377;&#20219;&#20309;&#19968;&#20010;&#22823;&#23567;&#21487;&#21464;&#12289;&#23481;&#37327;&#22266;&#23450;(&#20026;1)&#12289;&#22522;&#20110;&#26632;&#30340; + optional &#20540;&#30340;&#23481;&#22120;&#27169;&#22411;&#30340;&#20808;&#20363;&#65292; &#20294;&#26159;&#25105;&#30456;&#20449;&#36825;&#21482;&#26159;&#22240;&#20026;&#36824;&#27809;&#26377;&#36825;&#26679;&#19968;&#20010;&#23481;&#22120;&#30340;&#23454;&#38469;&#23454;&#29616;&#65292;&#32780;&#19981;&#26159;&#36825;&#26679;&#19968;&#20010;&#23481;&#22120;&#27169;&#22411;&#30340;&#22266;&#26377;&#32570;&#28857;&#12290;
+      </p>
+<p>
+ In any event, both the discriminated-union or the single-element container + models serve as a conceptual ground for a class representing optional&#8212;i.e. + possibly uninitialized&#8212;objects. For instance, these models show the <span class="emphasis"><em>exact</em></span> + semantics required for a wrapper of optional values:<br> &#26080;&#35770;&#22914;&#20309;&#65292;&#21487;&#35782;&#21035;&#32852;&#21512;&#25110;&#21333;&#20803;&#32032;&#23481;&#22120;&#27169;&#22411;&#22343;&#21487;&#20316;&#20026;&#34920;&#31034; + optional &#31867; &#8212; &#21363;&#21487;&#33021;&#26410;&#21021;&#22987;&#21270;&#30340; &#8212; &#23545;&#35937;&#30340;&#22522;&#30784;&#12290; &#20363;&#22914;&#65292;&#36825;&#20123;&#27169;&#22411;&#34920;&#29616;&#20986;&#20102;&#19968;&#20010; + optional &#20540;&#21253;&#35013;&#22120;&#25152;&#38656;&#30340;<span class="emphasis"><em>&#20934;&#30830;</em></span>&#35821;&#20041;&#65306;
+      </p>
+<p>
+ Discriminated-union:<br> &#21487;&#35782;&#21035;&#32852;&#21512;&#65306;
+      </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>deep-copy</strong></span> semantics: copies of the variant + implies copies of the value.<br><span class="bold"><strong>&#28145;&#22797;&#21046;</strong></span> + &#35821;&#20041;&#65306;variant &#30340;&#25335;&#36125;&#21363;&#20026;&#20540;&#30340;&#25335;&#36125;&#12290;
+        </li>
+<li>
+<span class="bold"><strong>deep-relational</strong></span> semantics: comparisons + between variants matches both current types and values<br><span class="bold"><strong>&#28145;&#27604;&#36739;</strong></span> &#35821;&#20041;&#65306;&#27604;&#36739;&#20004;&#20010; variants &#35201;&#21516;&#26102;&#21305;&#37197;&#31867;&#22411;&#21644;&#20540;&#12290;
+        </li>
+<li>
+ If the variant's current type is <code class="computeroutput"><span class="identifier">T</span></code>, + it is modeling an <span class="emphasis"><em>initialized</em></span> optional.<br> &#22914;&#26524; + variant &#30340;&#24403;&#21069;&#31867;&#22411;&#20026; <code class="computeroutput"><span class="identifier">T</span></code>, + &#23427;&#23601;&#20195;&#34920;<span class="emphasis"><em>&#24050;&#21021;&#22987;&#21270;&#30340;</em></span> optional.
+        </li>
+<li>
+ If the variant's current type is not <code class="computeroutput"><span class="identifier">T</span></code>, + it is modeling an <span class="emphasis"><em>uninitialized</em></span> optional.<br> &#22914;&#26524; + variant &#30340;&#24403;&#21069;&#31867;&#22411;&#19981;&#26159; <code class="computeroutput"><span class="identifier">T</span></code>, + &#23427;&#23601;&#20195;&#34920;<span class="emphasis"><em>&#26410;&#21021;&#22987;&#21270;&#30340;</em></span> optional.
+        </li>
+<li>
+ Testing if the variant's current type is <code class="computeroutput"><span class="identifier">T</span></code> + models testing if the optional is initialized<br> &#27979;&#35797; variant &#30340;&#24403;&#21069;&#31867;&#22411;&#26159;&#21542;&#20026; + <code class="computeroutput"><span class="identifier">T</span></code> &#21363;&#27979;&#35797; optional &#26159;&#21542;&#24050;&#21021;&#22987;&#21270;&#12290;
+        </li>
+<li>
+ Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> from + a variant when its current type is not <code class="computeroutput"><span class="identifier">T</span></code>, + models the undefined behavior of trying to access the value of an uninitialized + optional<br> &#35797;&#22270;&#20174;&#19968;&#20010; variant &#21462;&#20986; <code class="computeroutput"><span class="identifier">T</span></code> + &#32780;&#23427;&#30340;&#24403;&#21069;&#31867;&#22411;&#19981;&#26159; <code class="computeroutput"><span class="identifier">T</span></code> + &#26102;&#65292;&#27491;&#22909;&#31526;&#21512;&#20102;&#35775;&#38382;&#19968;&#20010;&#26410;&#21021;&#22987;&#21270; optional &#20540;&#30340;&#26410;&#23450;&#20041;&#34892;&#20026;&#12290;
+        </li>
+</ul></div>
+<p>
+ Single-element container:<br> &#21333;&#20803;&#32032;&#23481;&#22120;&#65306;
+      </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>deep-copy</strong></span> semantics: copies of the container + implies copies of the value.<br><span class="bold"><strong>&#28145;&#22797;&#21046;</strong></span> + &#35821;&#20041;&#65306;container &#30340;&#25335;&#36125;&#21363;&#20026;&#20540;&#30340;&#25335;&#36125;&#12290;
+        </li>
+<li>
+<span class="bold"><strong>deep-relational</strong></span> semantics: comparisons + between containers compare container size and if match, contained value<br><span class="bold"><strong>&#28145;&#27604;&#36739;</strong></span> &#35821;&#20041;&#65306;&#27604;&#36739;&#20004;&#20010; containers + &#35201;&#20808;&#27604;&#36739;&#23481;&#22120;&#30340;&#22823;&#23567;&#65292;&#22914;&#26524;&#21305;&#37197;&#20877;&#27604;&#36739;&#23481;&#22120;&#20013;&#30340;&#20540;&#12290;
+        </li>
+<li>
+ If the container is not empty (contains an object of type <code class="computeroutput"><span class="identifier">T</span></code>), it is modeling an <span class="emphasis"><em>initialized</em></span> + optional.<br> &#22914;&#26524; container &#38750;&#31354;(&#21253;&#21547;&#19968;&#20010;&#31867;&#22411;&#20026; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#23545;&#35937;)&#65292;&#23427;&#23601;&#20195;&#34920;<span class="emphasis"><em>&#24050;&#21021;&#22987;&#21270;&#30340;</em></span>
+          optional.
+        </li>
+<li>
+ If the container is empty, it is modeling an <span class="emphasis"><em>uninitialized</em></span> + optional.<br> &#22914;&#26524; container &#20026;&#31354;&#65292;&#23427;&#23601;&#20195;&#34920;<span class="emphasis"><em>&#26410;&#21021;&#22987;&#21270;&#30340;</em></span>
+          optional.
+        </li>
+<li>
+ Testing if the container is empty models testing if the optional is initialized<br> + &#27979;&#35797; container &#26159;&#21542;&#20026;&#31354;&#21363;&#27979;&#35797; optional &#26159;&#21542;&#24050;&#21021;&#22987;&#21270;&#12290;
+        </li>
+<li>
+ Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> from + an empty container models the undefined behavior of trying to access the + value of an uninitialized optional<br> &#35797;&#22270;&#20174;&#19968;&#20010;&#31354;&#30340; container + &#21462;&#20986; <code class="computeroutput"><span class="identifier">T</span></code>&#65292;&#27491;&#22909;&#31526;&#21512;&#20102;&#35775;&#38382;&#19968;&#20010;&#26410;&#21021;&#22987;&#21270; + optional &#20540;&#30340;&#26410;&#23450;&#20041;&#34892;&#20026;&#12290;
+        </li>
+</ul></div>
 </div>
-</div>
-</div>
-
-<p>在C++中,我们可以<span style="font-style: italic;">声明</span>类型T的一 个对象(变量),并且我们可以给这个对象一个<span style="font-style: italic;">初 始值</span>(通过<i>初始化</i> (参考 -8.5))。当一个声明中包含非空的初始化(即给出一个初始值),就称这个对象已被 <span style="font-weight: bold; font-style: italic;">初始化</span>。如果一个 声明使用了空的初始化(即未给出初始值),而且也没缺省值可用于初始化,则称该对象 是<span style="font-weight: bold; font-style: italic;">未初始化</span>的。它 的真实值是存在的,但具有一个<span style="font-style: italic;">不确定的初始值 </span>(参考
-8.5.9)。<code>optional&lt;T&gt;</code>
-的目的是规范初始化(或无初始化)的概念,让程序可以检测一个对象是否已初始 化,并规定访问一个未初始化对象的值是未定义的行为。即,如果一个变量被声明为 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> 而未给定初始值,则该变量就是<span style="font-style: italic;">正式的</span>未初始化。一个正式的未初始化的 optional -对象是没有值的,并且可以在运行期对此状态进行测试。尝试访问一个未初始化的 optional 被正式规定为<span style="font-style: italic;">未定义行为</span>。一 个未初始化的 optional 可以被<span style="font-style: italic;">赋予</span>一 个值,这时它的初始化状态就会变为已初始化。此外,还给出处理 optional -对象的初始化状态的方法,甚至可以将一个 optional 重新置为<span style="font-style: italic;">未初始化</span>。<br>
-</p>
-<p>在C++里没有未初始化对象的正式概念,即是说对象总是带有初始值的,即使是不 确定的值。正如前面所讨论的,这样有一个缺点,因为你需要用额外的信息来告知一个 对象是不是已经被有效地初始化了。一种以前常用的典型方法是使用特殊值:<code class="computeroutput"><span class="identifier">EOF</span></code>, <code class="computeroutput"><span class="identifier">npos</span></code>, -1, -等等... 这相当于增加一个特殊值到给定类型的可取值的集合中。由 <code class="computeroutput"><span class="identifier">T</span></code> 加上某个 <i>nil_t</i> -- <code class="computeroutput"><span class="identifier">nil_t</span></code> 是某个无状态的POD -- -组成的超集在现代语言中可以被模仿为由 <code>T</code> 和 <code>nil_t</code> 组成的一个<span style="font-weight: bold;">可识别联合</span>。可识别联合通常 称为 <i>variants</i>. 一个 variant 具有 -<span style="font-style: italic;">当前类型</span>,在我们的例子中就是 <code>T</code> 或者 -<code>nil_t</code>.使用 <a href="../../../../variant/index.html">Boost.Variant</a> 库,以上模型可以用 -<code>boost::variant&lt;T,nil_t&gt;</code> 来实现。用可识别联合来模仿一个 optional -值是有先例的:<a href="http://www.haskell.org/";><u>Haskell</u></a> 的 <b>Maybe</b> -内建类型构造器。所以,可识别联合 <code>T+nil_t</code> 可以作为一个概念上的 基础。<br>
-</p>
-<p><code>variant&lt;T,nil_t&gt;</code> 自然而然地可用于扩展可取值的传统惯用 法,它增加一个"哨兵"值用于表示<span style="font-style: italic;">空值 </span>。不过,这个新增的<span style="font-style: italic;">空值</span>与我们 意图大不相关,因为我们的目标是规范化未初始化对象的概念,虽然一个特殊的扩展值 可以用于表达这个意思,但是它并不是严格必要的。</p>
-
-<p>最近的研究表明,额外的 <code>nil_t</code> 对于 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> 的 <u>目的</u> -是无关的,我们建议另一种模型:一个<span style="font-style: italic;">容器 </span>,它具有 <code class="computeroutput"><span class="identifier">T</span></code> 的值,或者为空。 </p>
-
-<p>在写这篇文档之时,我还不知道有任何一个大小可变、容量固定(为1)、基于栈的 optional -值的容器模型的先例,但是我相信这只是因为还没有这样一个容器的实际实现,而不 是这样一个容器模型的固有缺点。</p>
-
-<p>无论如何,可识别联合或单元素容器模型均可作为表示 optional&nbsp;类 -- 即可 能未初始化的 -- 对象的基础。<br>
-例如,这些模型表现出了一个
-optional 值包装器所需的<span style="font-style: italic;">准确</span>语 义:</p>
-
-<p>可识别联合:</p>
-
-<blockquote>
-  <li><b>深复制</b> 语义:variant 的拷贝即为值的拷贝。
-  </li>
-  <li><b>深比较</b> 语义:比较两个 variants 要同时匹配类型和值。
-  </li>
- <li>如果 variant 的当前类型为 T, 它就代表<span style="font-style: italic;">已初始化的</span>
-optional.
-  </li>
- <li>如果 variant 的当前类型不是 T, 它就代表<span style="font-style: italic;">未初始化的</span>
-optional.
-  </li>
-  <li>测试 variant 的当前类型是否为 T 即测试 optional 是否已初始化。
-  </li>
- <li>试图从一个 variant 取出 T 而它的当前类型不是 T 时,正好符合了访问一个 未初始化 optional 值的未定义行为。
-  </li>
-</blockquote>
-
-<p>单元素容器:</p>
-
-<blockquote>
-  <li><b>深复制</b> 语义:container 的拷贝即为值的拷贝。
-  </li>
- <li><b>深比较</b> 语义:比较两个&nbsp;containers 要先比较容器的大小,如果 匹配再比较容器中的值。
-  </li>
- <li>如果&nbsp;container 非空(包含一个类型为 T 的对象),它就代表<span style="font-style: italic;">已初始化的</span> optional.
-  </li>
- <li>如果&nbsp;container 为空,它就代表<span style="font-style: italic;">未初始化的</span> optional.
-  </li>
-  <li>测试&nbsp;container&nbsp;是否为空即测试 optional 是否已初始化。
-  </li>
- <li>试图从一个空的 container 取出 T,正好符合了访问一个未初始化 optional 值的未定义行为。<br>
-  </li>
-</blockquote>
-</div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h3 class="title">
-<a name="boost_optional.development.the_semantics"></a>语义
-</h3>
-</div>
-</div>
-</div>
-
-<p>类型 <code>optional&lt;T&gt;</code> 的对象的设计意图是,用在那些使用可能 未被初始化的类型 <code class="computeroutput"><span class="identifier">T</span></code>
-的对象的地方。因此,<code>optional&lt;T&gt;</code>
-的意图是对增加可能的未初始化状态进行规范化。从这一任务的观点出 发,<code>optional&lt;T&gt;</code> 可以具有与 <code class="computeroutput"><span class="identifier">T</span></code> -相同的操作语义,再加上与特殊状态相对应的额外语义。同 样,<code>optional&lt;T&gt;</code> 可被视为 <code class="computeroutput"><span class="identifier">T</span></code> 的一个 -<i>超类型supertype</i>. 当然,我们不能在C++中这样做,所以我们需要用一种不同 的机制来得到想要的语义。使用其它方法实现它,如让 -<code>optional&lt;T&gt;</code> 作为 <code class="computeroutput"><span class="identifier">T</span></code> 的 -<i>子类</i>,不仅是概念上的错误,而且也是不实际的:因为不允许从非类类型派 生,如从内建类型派生。</p>
-
-<p>我们可以从 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> 的目的描 画出所需的基本语义:</p>
-<div class="itemizedlist">
-<ul type="disc">
-
-  <li>
-    <b>缺省构造:</b>引入一个正式的未初始化包装对象。
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_optional.development.the_semantics"></a><a class="link" href="development.html#boost_optional.development.the_semantics" title="The semantics &#35821;&#20041;"> The semantics
+      &#35821;&#20041;</a>
+</h3></div></div></div>
+<p>
+ Objects of type <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + are intended to be used in places where objects of type <code class="computeroutput"><span class="identifier">T</span></code> + would but which might be uninitialized. Hence, <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>'s + purpose is to formalize the additional possibly uninitialized state. From + the perspective of this role, <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + can have the same operational semantics of <code class="computeroutput"><span class="identifier">T</span></code> + plus the additional semantics corresponding to this special state. As such, + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> could + be thought of as a <span class="emphasis"><em>supertype</em></span> of <code class="computeroutput"><span class="identifier">T</span></code>. + Of course, we can't do that in C++, so we need to compose the desired semantics + using a different mechanism. Doing it the other way around, that is, making + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> a + <span class="emphasis"><em>subtype</em></span> of <code class="computeroutput"><span class="identifier">T</span></code> + is not only conceptually wrong but also impractical: it is not allowed to + derive from a non-class type, such as a built-in type.<br> &#31867;&#22411; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#30340;&#23545;&#35937;&#30340;&#35774;&#35745;&#24847;&#22270;&#26159;&#65292;&#29992;&#22312;&#37027;&#20123;&#20351;&#29992;&#21487;&#33021;&#26410;&#34987;&#21021;&#22987;&#21270;&#30340;&#31867;&#22411; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#23545;&#35937;&#30340;&#22320;&#26041;&#12290; &#22240;&#27492;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#30340;&#24847;&#22270;&#26159;&#23545;&#22686;&#21152;&#21487;&#33021;&#30340;&#26410;&#21021;&#22987;&#21270;&#29366;&#24577;&#36827;&#34892;&#35268;&#33539;&#21270;&#12290; + &#20174;&#36825;&#19968;&#20219;&#21153;&#30340;&#35266;&#28857;&#20986;&#21457;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + &#21487;&#20197;&#20855;&#26377;&#19982; <code class="computeroutput"><span class="identifier">T</span></code> &#30456;&#21516;&#30340;&#25805;&#20316;&#35821;&#20041;&#65292;&#20877;&#21152;&#19978;&#19982;&#29305;&#27530;&#29366;&#24577;&#30456;&#23545;&#24212;&#30340;&#39069;&#22806;&#35821;&#20041;&#12290; + &#21516;&#26679;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#21487;&#34987;&#35270;&#20026; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#19968;&#20010; <span class="emphasis"><em>&#36229;&#31867;&#22411;</em></span>. + &#24403;&#28982;&#65292;&#25105;&#20204;&#19981;&#33021;&#22312;C++&#20013;&#36825;&#26679;&#20570;&#65292;&#25152;&#20197;&#25105;&#20204;&#38656;&#35201;&#29992;&#19968;&#31181;&#19981;&#21516;&#30340;&#26426;&#21046;&#26469;&#24471;&#21040;&#24819;&#35201;&#30340;&#35821;&#20041;&#12290; + &#20351;&#29992;&#20854;&#23427;&#26041;&#27861;&#23454;&#29616;&#23427;&#65292;&#22914;&#35753; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + &#20316;&#20026; <code class="computeroutput"><span class="identifier">T</span></code> &#30340; <span class="emphasis"><em>&#23376;&#31867;</em></span>&#65292;&#19981;&#20165;&#26159;&#27010;&#24565;&#19978;&#30340;&#38169;&#35823;&#65292;&#32780;&#19988;&#20063;&#26159;&#19981;&#23454;&#38469;&#30340;&#65306; + &#22240;&#20026;&#19981;&#20801;&#35768;&#20174;&#38750;&#31867;&#31867;&#22411;&#27966;&#29983;&#65292;&#22914;&#20174;&#20869;&#24314;&#31867;&#22411;&#27966;&#29983;&#12290;
+      </p>
+<p>
+ We can draw from the purpose of <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + the required basic semantics:<br> &#25105;&#20204;&#21487;&#20197;&#20174; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + &#30340;&#30446;&#30340;&#25551;&#30011;&#20986;&#25152;&#38656;&#30340;&#22522;&#26412;&#35821;&#20041;&#65306;
+      </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="bold"><strong>Default Construction:</strong></span> To introduce a formally + uninitialized wrapped object.<br><span class="bold"><strong>&#32570;&#30465;&#26500;&#36896;&#65306;</strong></span>&#24341;&#20837;&#19968;&#20010;&#27491;&#24335;&#30340;&#26410;&#21021;&#22987;&#21270;&#21253;&#35013;&#23545;&#35937;&#12290;
         </li>
-
-  <li>
- <b>通过复制进行直接的值构造:</b>引入一个正式的已初始化包装对象,其值来 自于某个对象的拷贝。
+<li>
+<span class="bold"><strong>Direct Value Construction via copy:</strong></span> To + introduce a formally initialized wrapped object whose value is obtained + as a copy of some object.<br><span class="bold"><strong>&#36890;&#36807;&#22797;&#21046;&#36827;&#34892;&#30452;&#25509;&#30340;&#20540;&#26500;&#36896;&#65306;</strong></span>&#24341;&#20837;&#19968;&#20010;&#27491;&#24335;&#30340;&#24050;&#21021;&#22987;&#21270;&#21253;&#35013;&#23545;&#35937;&#65292;&#20854;&#20540;&#26469;&#33258;&#20110;&#26576;&#20010;&#23545;&#35937;&#30340;&#25335;&#36125;&#12290;
         </li>
-
-  <li>
-    <b>深复制构造:</b>获得一个新的、等价的包装对象。
+<li>
+<span class="bold"><strong>Deep Copy Construction:</strong></span> To obtain a new + yet equivalent wrapped object.<br><span class="bold"><strong>&#28145;&#22797;&#21046;&#26500;&#36896;&#65306;</strong></span>&#33719;&#24471;&#19968;&#20010;&#26032;&#30340;&#12289;&#31561;&#20215;&#30340;&#21253;&#35013;&#23545;&#35937;&#12290;
         </li>
-
-  <li>
-    <b>直接的值赋值(到已初始化的对象):</b>将一个值赋值到包装对象。
+<li>
+<span class="bold"><strong>Direct Value Assignment (upon initialized):</strong></span> + To assign a value to the wrapped object.<br><span class="bold"><strong>&#30452;&#25509;&#30340;&#20540;&#36171;&#20540;(&#21040;&#24050;&#21021;&#22987;&#21270;&#30340;&#23545;&#35937;)&#65306;</strong></span>&#23558;&#19968;&#20010;&#20540;&#36171;&#20540;&#21040;&#21253;&#35013;&#23545;&#35937;&#12290;
         </li>
-
-  <li>
- <b>直接的值赋值(到未初始化的对象):</b>从某个对象的拷贝取得值,初始化包 装对象。
+<li>
+<span class="bold"><strong>Direct Value Assignment (upon uninitialized):</strong></span> + To initialize the wrapped object with a value obtained as a copy of some + object.<br><span class="bold"><strong>&#30452;&#25509;&#30340;&#20540;&#36171;&#20540;(&#21040;&#26410;&#21021;&#22987;&#21270;&#30340;&#23545;&#35937;)&#65306;</strong></span>&#20174;&#26576;&#20010;&#23545;&#35937;&#30340;&#25335;&#36125;&#21462;&#24471;&#20540;&#65292;&#21021;&#22987;&#21270;&#21253;&#35013;&#23545;&#35937;&#12290;
         </li>
-
-  <li>
-    <b>赋值(到已初始化的对象):</b>将另一个包装对象的值赋值到包装对象。
+<li>
+<span class="bold"><strong>Assignment (upon initialized):</strong></span> To assign + to the wrapped object the value of another wrapped object.<br><span class="bold"><strong>&#36171;&#20540;(&#21040;&#24050;&#21021;&#22987;&#21270;&#30340;&#23545;&#35937;)&#65306;</strong></span>&#23558;&#21478;&#19968;&#20010;&#21253;&#35013;&#23545;&#35937;&#30340;&#20540;&#36171;&#20540;&#21040;&#21253;&#35013;&#23545;&#35937;&#12290;
         </li>
-
-  <li>
-    <b>赋值(到未初始化的对象):</b>以另一个包装对象的值初始化包装对象。
+<li>
+<span class="bold"><strong>Assignment (upon uninitialized):</strong></span> To initialize + the wrapped object with value of another wrapped object.<br><span class="bold"><strong>&#36171;&#20540;(&#21040;&#26410;&#21021;&#22987;&#21270;&#30340;&#23545;&#35937;)&#65306;</strong></span>&#20197;&#21478;&#19968;&#20010;&#21253;&#35013;&#23545;&#35937;&#30340;&#20540;&#21021;&#22987;&#21270;&#21253;&#35013;&#23545;&#35937;&#12290;
         </li>
-
-  <li>
- <b>深比较操作(仅当被类型T支持时):</b>比较两个包装对象的值,包括未初始 化状态的情形。
+<li>
+<span class="bold"><strong>Deep Relational Operations (when supported by the + type T):</strong></span> To compare wrapped object values taking into account + the presence of uninitialized states.<br><span class="bold"><strong>&#28145;&#27604;&#36739;&#25805;&#20316;(&#20165;&#24403;&#34987;&#31867;&#22411;T&#25903;&#25345;&#26102;)&#65306;</strong></span>&#27604;&#36739;&#20004;&#20010;&#21253;&#35013;&#23545;&#35937;&#30340;&#20540;&#65292;&#21253;&#25324;&#26410;&#21021;&#22987;&#21270;&#29366;&#24577;&#30340;&#24773;&#24418;&#12290;
         </li>
-
-  <li>
-    <b>值访问:</b>对包装对象去包装。
+<li>
+<span class="bold"><strong>Value access:</strong></span> To unwrap the wrapped object.<br><span class="bold"><strong>&#20540;&#35775;&#38382;&#65306;</strong></span>&#23545;&#21253;&#35013;&#23545;&#35937;&#21435;&#21253;&#35013;&#12290;
         </li>
-
-  <li>
-    <b>初始化状态查询:</b>判断该对象是否已正式初始化。
+<li>
+<span class="bold"><strong>Initialization state query:</strong></span> To determine + if the object is formally initialized or not.<br><span class="bold"><strong>&#21021;&#22987;&#21270;&#29366;&#24577;&#26597;&#35810;&#65306;</strong></span>&#21028;&#26029;&#35813;&#23545;&#35937;&#26159;&#21542;&#24050;&#27491;&#24335;&#21021;&#22987;&#21270;&#12290;
         </li>
-
-  <li>
- <b>交换:</b>交换包装的对象。(无论 T 的交换操作提供何种异常安全性保证 )。
+<li>
+<span class="bold"><strong>Swap:</strong></span> To exchange wrapped objects. (with + whatever exception safety guarantees are provided by <code class="computeroutput"><span class="identifier">T</span></code>'s + swap).<br><span class="bold"><strong>&#20132;&#25442;&#65306;</strong></span>&#20132;&#25442;&#21253;&#35013;&#30340;&#23545;&#35937;&#12290;(&#26080;&#35770; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#20132;&#25442;&#25805;&#20316;&#25552;&#20379;&#20309;&#31181;&#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;)&#12290;
         </li>
-
-  <li>
-    <b>去初始化:</b>释放包装的对象(如果有),并使包装器保留未初始化状态。
+<li>
+<span class="bold"><strong>De-initialization:</strong></span> To release the wrapped + object (if any) and leave the wrapper in the uninitialized state.<br><span class="bold"><strong>&#21435;&#21021;&#22987;&#21270;&#65306;</strong></span>&#37322;&#25918;&#21253;&#35013;&#30340;&#23545;&#35937;(&#22914;&#26524;&#26377;)&#65292;&#24182;&#20351;&#21253;&#35013;&#22120;&#20445;&#30041;&#26410;&#21021;&#22987;&#21270;&#29366;&#24577;&#12290;
         </li>
-
-</ul>
-</div>
-
-<p>其它操作也是有用的,如转换构造函数和转换赋值,就地构造和赋值,以及通过包 装对象的一个指针或空指针进行安全的值访问。&nbsp;
+</ul></div>
+<p>
+ Additional operations are useful, such as converting constructors and converting + assignments, in-place construction and assignment, and safe value access + via a pointer to the wrapped object or null.<br> &#20854;&#23427;&#25805;&#20316;&#20063;&#26159;&#26377;&#29992;&#30340;&#65292;&#22914;&#36716;&#25442;&#26500;&#36896;&#20989;&#25968;&#21644;&#36716;&#25442;&#36171;&#20540;&#65292;&#23601;&#22320;&#26500;&#36896;&#21644;&#36171;&#20540;&#65292;&#20197;&#21450;&#36890;&#36807;&#21253;&#35013;&#23545;&#35937;&#30340;&#19968;&#20010;&#25351;&#38024;&#25110;&#31354;&#25351;&#38024;&#36827;&#34892;&#23433;&#20840;&#30340;&#20540;&#35775;&#38382;&#12290;
       </p>
-
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h3 class="title">
-<a name="boost_optional.development.the_interface"></a><a class="link" href="development.html#boost_optional.development.the_interface" title="The Interface">接口</a>
-</h3>
-</div>
-</div>
-</div>
-
-<p>由于 optional 的目的是允许我们使用增加了正式的未初始化状态的对象,所以它 的接口应该尽可能跟随底层的类型 <code class="computeroutput"><span class="identifier">T</span></code>. 为了选择适当的原本的 T -接口,应该留意以下几点:即使被类型 <code class="computeroutput"><span class="identifier">T</span></code> 的实例所支持的所有操作是为该类的整个值域 所定义的,但是 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
-将该值域扩充了一个新值,所以多数操作对此没有定义。</p>
-<p>此外,由于 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> 本身只不 过是一个 <code class="computeroutput"><span class="identifier">T</span></code> 的包装(类似于 T -的一个超类),任何针对未初始化的 optional 的操作定义都应完全与 <code class="computeroutput"><span class="identifier">T</span></code> 相关。</p> -<p>本库所选择的接口是,沿用 <code class="computeroutput"><span class="identifier">T</span></code> -的接口,只要那些操作是有良好定义的(与类型 <code class="computeroutput"><span class="identifier">T</span></code> -有关),即使某些操作数未初始化。这样的操作包括有:构造,复制构造,赋值,交换 和比较操作。</p> -<p>对于值访问操作,如果操作数是未初始化的,则是未定义的(与类型 <code class="computeroutput"><span class="identifier">T</span></code>
-有关),所以选用了不同的接口(稍后将会解释)。</p>
-<p>还有,未初始化状态的可能出现需要有更多的操作,这些操作是 <code class="computeroutput"><span class="identifier">T</span></code>
-本身所不具备的,它们将以特定的接口提供。</p>
-<a name="boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_"></a>
-<h5>
-<a name="id2636515"></a> <a class="link" href="development.html#boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_">对 可能未初始化的 optional 对象的带提示的值访问:操作符 * 和 -&gt;</a>
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_optional.development.the_interface"></a><a class="link" href="development.html#boost_optional.development.the_interface" title="The Interface &#25509;&#21475;"> The Interface
+      &#25509;&#21475;</a>
+</h3></div></div></div>
+<p>
+ Since the purpose of optional is to allow us to use objects with a formal + uninitialized additional state, the interface could try to follow the interface + of the underlying <code class="computeroutput"><span class="identifier">T</span></code> type + as much as possible. In order to choose the proper degree of adoption of + the native <code class="computeroutput"><span class="identifier">T</span></code> interface, the + following must be noted: Even if all the operations supported by an instance + of type <code class="computeroutput"><span class="identifier">T</span></code> are defined for + the entire range of values for such a type, an <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + extends such a set of values with a new value for which most (otherwise valid) + operations are not defined in terms of <code class="computeroutput"><span class="identifier">T</span></code>.<br> + &#30001;&#20110; optional &#30340;&#30446;&#30340;&#26159;&#20801;&#35768;&#25105;&#20204;&#20351;&#29992;&#22686;&#21152;&#20102;&#27491;&#24335;&#30340;&#26410;&#21021;&#22987;&#21270;&#29366;&#24577;&#30340;&#23545;&#35937;&#65292;&#25152;&#20197;&#23427;&#30340;&#25509;&#21475;&#24212;&#35813;&#23613;&#21487;&#33021;&#36319;&#38543;&#24213;&#23618;&#30340;&#31867;&#22411; + <code class="computeroutput"><span class="identifier">T</span></code>. &#20026;&#20102;&#36873;&#25321;&#36866;&#24403;&#30340;&#21407;&#26412;&#30340; + <code class="computeroutput"><span class="identifier">T</span></code> &#25509;&#21475;&#65292;&#24212;&#35813;&#30041;&#24847;&#20197;&#19979;&#20960;&#28857;&#65306;&#21363;&#20351;&#34987;&#31867;&#22411; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#23454;&#20363;&#25152;&#25903;&#25345;&#30340;&#25152;&#26377;&#25805;&#20316;&#26159;&#20026;&#35813;&#31867;&#30340;&#25972;&#20010;&#20540;&#22495;&#25152;&#23450;&#20041;&#30340;&#65292; + &#20294;&#26159; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#23558;&#35813;&#20540;&#22495;&#25193;&#20805;&#20102;&#19968;&#20010;&#26032;&#20540;&#65292;&#25152;&#20197;&#24456;&#22810;(&#23545;&#20854;&#23427;&#20540;&#26377;&#25928;&#30340;)&#25805;&#20316;&#23545;&#35813;&#20540;&#27809;&#26377;&#23450;&#20041;&#12290;
+      </p>
+<p>
+ Furthermore, since <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + itself is merely a <code class="computeroutput"><span class="identifier">T</span></code> wrapper + (modeling a <code class="computeroutput"><span class="identifier">T</span></code> supertype), + any attempt to define such operations upon uninitialized optionals will be + totally artificial w.r.t. <code class="computeroutput"><span class="identifier">T</span></code>.<br> + &#27492;&#22806;&#65292;&#30001;&#20110; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + &#26412;&#36523;&#21482;&#19981;&#36807;&#26159;&#19968;&#20010; <code class="computeroutput"><span class="identifier">T</span></code> + &#30340;&#21253;&#35013;(&#31867;&#20284;&#20110; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#19968;&#20010;&#36229;&#31867;)&#65292;&#20219;&#20309;&#38024;&#23545;&#26410;&#21021;&#22987;&#21270;&#30340; + optional &#30340;&#25805;&#20316;&#23450;&#20041;&#37117;&#24212;&#23436;&#20840;&#19982; <code class="computeroutput"><span class="identifier">T</span></code>
+        &#30456;&#20851;&#12290;
+      </p>
+<p>
+ This library chooses an interface which follows from <code class="computeroutput"><span class="identifier">T</span></code>'s + interface only for those operations which are well defined (w.r.t the type + <code class="computeroutput"><span class="identifier">T</span></code>) even if any of the operands + are uninitialized. These operations include: construction, copy-construction, + assignment, swap and relational operations.<br> &#26412;&#24211;&#25152;&#36873;&#25321;&#30340;&#25509;&#21475;&#26159;&#65292;&#27839;&#29992; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#25509;&#21475;&#65292;&#21482;&#35201;&#37027;&#20123;&#25805;&#20316;&#26159;&#26377;&#33391;&#22909;&#23450;&#20041;&#30340;(&#19982;&#31867;&#22411; + <code class="computeroutput"><span class="identifier">T</span></code> &#26377;&#20851;)&#65292;&#21363;&#20351;&#26576;&#20123;&#25805;&#20316;&#25968;&#26410;&#21021;&#22987;&#21270;&#12290; + &#36825;&#26679;&#30340;&#25805;&#20316;&#21253;&#25324;&#26377;&#65306;&#26500;&#36896;&#65292;&#22797;&#21046;&#26500;&#36896;&#65292;&#36171;&#20540;&#65292;&#20132;&#25442;&#21644;&#27604;&#36739;&#25805;&#20316;&#12290;
+      </p>
+<p>
+ For the value access operations, which are undefined (w.r.t the type <code class="computeroutput"><span class="identifier">T</span></code>) when the operand is uninitialized, a + different interface is chosen (which will be explained next).<br> &#23545;&#20110;&#20540;&#35775;&#38382;&#25805;&#20316;&#65292;&#22914;&#26524;&#25805;&#20316;&#25968;&#26159;&#26410;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017;&#26159;&#26410;&#23450;&#20041;&#30340;(&#19982;&#31867;&#22411; + <code class="computeroutput"><span class="identifier">T</span></code> &#26377;&#20851;)&#65292;&#25152;&#20197;&#36873;&#29992;&#20102;&#19981;&#21516;&#30340;&#25509;&#21475;(&#31245;&#21518;&#23558;&#20250;&#35299;&#37322;)&#12290;
+      </p>
+<p>
+ Also, the presence of the possibly uninitialized state requires additional + operations not provided by <code class="computeroutput"><span class="identifier">T</span></code> + itself which are supported by a special interface.<br> &#36824;&#26377;&#65292;&#26410;&#21021;&#22987;&#21270;&#29366;&#24577;&#30340;&#21487;&#33021;&#20986;&#29616;&#38656;&#35201;&#26377;&#26356;&#22810;&#30340;&#25805;&#20316;&#65292;&#36825;&#20123;&#25805;&#20316;&#26159; + <code class="computeroutput"><span class="identifier">T</span></code> &#26412;&#36523;&#25152;&#19981;&#20855;&#22791;&#30340;&#65292;&#23427;&#20204;&#23558;&#20197;&#29305;&#23450;&#30340;&#25509;&#21475;&#25552;&#20379;&#12290;
+      </p>
+<a name="boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt__sbr_____________________________optional____________________________________________________gt_"></a><h5>
+<a name="id4860008"></a>
+ <a class="link" href="development.html#boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt__sbr_____________________________optional____________________________________________________gt_">Lexically-hinted + Value Access in the presence of possibly untitialized optional objects: The + operators * and -&gt;<br> &#23545;&#21487;&#33021;&#26410;&#21021;&#22987;&#21270;&#30340; optional &#23545;&#35937;&#30340;&#24102;&#25552;&#31034;&#30340;&#20540;&#35775;&#38382;&#65306;&#25805;&#20316;&#31526;
+        * &#21644; -&gt;</a>
       </h5>
-
-<p>指针的一个特点是它可以具有 <b>空指针值</b>。这是一个特殊值,用于表示该指 针没有指向任何对象。换句话说,空指针值表达的意思是不存在的对象。</p>
-
-<p>空指针值的这个意义使得指针成为了处理 optional
-对象的事实标准,因为当你要引向一个实际上不存在的值时,你要做的只是使用适当 类型的空指针值。指针已经被使用了几十年 -- 从 C APIs 一直到现代的 C++ 库 --- 用来表示 optional (即可能不存在的)对象;尤其是用作函数的可选参数,但也常 被用作可选数据成员。</p>
-
-<p>空指针值的可能出现使得访问被指物值的操作可能是无定义的,所以,使用提领和 访问操作符的表达式,如 <code>( *p = 2 )</code> 和 -<code>( p-&gt;foo())</code>, 暗含了可选性的概念,此类信息被表达式的语法所依 赖。即,操作符 <code class="computeroutput"><span class="special">*</span></code> 和 <code class="computeroutput"><span class="special">-&gt;</span></code> 本身 -- -无需任何额外的上下文 --就说明了该表达式可以是无定义的,除非被指物确实存在。 </p>
-
-<p>这个表示 optional 对象的事实上的惯用法可以用一个概念来规范化:<a href="../../../../utility/OptionalPointee.html">OptionalPointee</a> 概念。该 概念包含了操作符 <code class="computeroutput"><span class="special">*</span></code>, <code class="computeroutput"><span class="special">-&gt;</span></code> 以及转换到 <code class="computeroutput"><span class="keyword">bool</span></code> 的语法,以表 达可选性的概念。</p>
-
-<p>虽然指针适合于表示 optional 对象,但是并不特别适合处理 optional
-对象的其它方面,如初始化或移动/复制。问题主要在于指针语义的浅复制:如果你需 要高效地移动或复制对象,那么仅有指针是不够的。问题是指针的拷贝并不代表被指物 的拷贝。例如,象在"动机"一节中所讨论的,仅用指针并不能从一个函数返回
-optional
-对象,因为该对象必须从函数中移至外部,进入调用者的上下文。</p>
-<p>解决浅复制问题的一个常用方法是,采用动态分配并使用智能指针来自动处理其细 节。例如,如果一个函数可选性地返回一个对象 -X, 则可以使用 <code class="computeroutput"><span class="identifier">shared_ptr</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;</span></code> - 作为返回值。不过,这要求对 <code class="computeroutput"><span class="identifier">X</span></code> 进行动态分配。如果 <code class="computeroutput"><span class="identifier">X</span></code> 是内建的或是 小的 POD, -该技术在资源方面很不划算。Optional 对象本质上是值对象,所以,如果可以象我们 处理普通的值对象那样,使用自动存储和深复制语义来维护 optional -值,才是最方便的。指针不具有这种语义,所以不适于初始化和转移 optional 值,但还是非常适合于访问有可能无定义的值,因为该用法已存在于以指针为代表的 <a href="../../../../utility/OptionalPointee.html" target="_top">OptionalPointee</a> 概念中。</p> -<a name="boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee"></a>
-<h5>
-<a name="id2636825"></a>
- <a class="link" href="development.html#boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee">Optional&lt;T&gt; 作为 OptionalPointee 的模型</a>
+<p>
+ A relevant feature of a pointer is that it can have a <span class="bold"><strong>null + pointer value</strong></span>. This is a <span class="emphasis"><em>special</em></span> value which + is used to indicate that the pointer is not referring to any object at all. + In other words, null pointer values convey the notion of inexistent objects.<br> + &#25351;&#38024;&#30340;&#19968;&#20010;&#29305;&#28857;&#26159;&#23427;&#21487;&#20197;&#20855;&#26377; <span class="bold"><strong>&#31354;&#25351;&#38024;&#20540;</strong></span>&#12290;&#36825;&#26159;&#19968;&#20010;<span class="emphasis"><em>&#29305;&#27530;</em></span>&#20540;&#65292;&#29992;&#20110;&#34920;&#31034;&#35813;&#25351;&#38024;&#27809;&#26377;&#25351;&#21521;&#20219;&#20309;&#23545;&#35937;&#12290; + &#25442;&#21477;&#35805;&#35828;&#65292;&#31354;&#25351;&#38024;&#20540;&#34920;&#36798;&#30340;&#24847;&#24605;&#26159;&#19981;&#23384;&#22312;&#30340;&#23545;&#35937;&#12290;
+      </p>
+<p>
+ This meaning of the null pointer value allowed pointers to became a <span class="emphasis"><em>de + facto</em></span> standard for handling optional objects because all you have + to do to refer to a value which you don't really have is to use a null pointer + value of the appropriate type. Pointers have been used for decades&#8212;from + the days of C APIs to modern C++ libraries&#8212;to <span class="emphasis"><em>refer</em></span> + to optional (that is, possibly inexistent) objects; particularly as optional + arguments to a function, but also quite often as optional data members.<br> + &#31354;&#25351;&#38024;&#20540;&#30340;&#36825;&#20010;&#24847;&#20041;&#20351;&#24471;&#25351;&#38024;&#25104;&#20026;&#20102;&#22788;&#29702; optional &#23545;&#35937;&#30340;<span class="emphasis"><em>&#20107;&#23454;</em></span>&#26631;&#20934;&#65292;&#22240;&#20026;&#24403;&#20320;&#35201;&#24341;&#21521;&#19968;&#20010;&#23454;&#38469;&#19978;&#19981;&#23384;&#22312;&#30340;&#20540;&#26102;&#65292; + &#20320;&#35201;&#20570;&#30340;&#21482;&#26159;&#20351;&#29992;&#36866;&#24403;&#31867;&#22411;&#30340;&#31354;&#25351;&#38024;&#20540;&#12290;&#25351;&#38024;&#24050;&#32463;&#34987;&#20351;&#29992;&#20102;&#20960;&#21313;&#24180; + &#8212; &#20174; C APIs &#19968;&#30452;&#21040;&#29616;&#20195;&#30340; C++ &#24211; &#8212; &#29992;&#26469;<span class="emphasis"><em>&#34920;&#31034;</em></span> + optional (&#21363;&#21487;&#33021;&#19981;&#23384;&#22312;&#30340;)&#23545;&#35937;&#65307;&#23588;&#20854;&#26159;&#29992;&#20316;&#20989;&#25968;&#30340;&#21487;&#36873;&#21442;&#25968;&#65292;&#20294;&#20063;&#24120;&#34987;&#29992;&#20316;&#21487;&#36873;&#25968;&#25454;&#25104;&#21592;&#12290;
+      </p>
+<p>
+ The possible presence of a null pointer value makes the operations that access + the pointee's value possibly undefined, therefore, expressions which use + dereference and access operators, such as: <code class="computeroutput"><span class="special">(</span> + <span class="special">*</span><span class="identifier">p</span> <span class="special">=</span> <span class="number">2</span> <span class="special">)</span></code> + and <code class="computeroutput"><span class="special">(</span> <span class="identifier">p</span><span class="special">-&gt;</span><span class="identifier">foo</span><span class="special">()</span> <span class="special">)</span></code>, implicitly + convey the notion of optionality, and this information is tied to the <span class="emphasis"><em>syntax</em></span> + of the expressions. That is, the presence of operators <code class="computeroutput"><span class="special">*</span></code> + and <code class="computeroutput"><span class="special">-&gt;</span></code> tell by themselves + &#8212;without any additional context&#8212; that the expression will be undefined + unless the implied pointee actually exist.<br> &#31354;&#25351;&#38024;&#20540;&#30340;&#21487;&#33021;&#20986;&#29616;&#20351;&#24471;&#35775;&#38382;&#34987;&#25351;&#29289;&#20540;&#30340;&#25805;&#20316;&#21487;&#33021;&#26159;&#26080;&#23450;&#20041;&#30340;&#65292;&#25152;&#20197;&#65292;&#20351;&#29992;&#25552;&#39046;&#21644;&#35775;&#38382;&#25805;&#20316;&#31526;&#30340;&#34920;&#36798;&#24335;&#65292; + &#22914; <code class="computeroutput"><span class="special">(</span> <span class="special">*</span><span class="identifier">p</span> <span class="special">=</span> <span class="number">2</span> + <span class="special">)</span></code> &#21644; <code class="computeroutput"><span class="special">(</span> + <span class="identifier">p</span><span class="special">-&gt;</span><span class="identifier">foo</span><span class="special">()</span> <span class="special">)</span></code>, &#26263;&#21547;&#20102;&#21487;&#36873;&#24615;&#30340;&#27010;&#24565;&#65292;&#27492;&#31867;&#20449;&#24687;&#34987;&#34920;&#36798;&#24335;&#30340;<span class="emphasis"><em>&#35821;&#27861;</em></span>&#25152;&#20381;&#36182;&#12290; + &#21363;&#65292;&#25805;&#20316;&#31526; <code class="computeroutput"><span class="special">*</span></code> &#21644; <code class="computeroutput"><span class="special">-&gt;</span></code> &#26412;&#36523; &#8212; &#26080;&#38656;&#20219;&#20309;&#39069;&#22806;&#30340;&#19978;&#19979;&#25991; + &#8212; &#23601;&#35828;&#26126;&#20102;&#35813;&#34920;&#36798;&#24335;&#21487;&#20197;&#26159;&#26080;&#23450;&#20041;&#30340;&#65292;&#38500;&#38750;&#34987;&#25351;&#29289;&#30830;&#23454;&#23384;&#22312;&#12290;
+      </p>
+<p>
+ Such a <span class="emphasis"><em>de facto</em></span> idiom for referring to optional objects + can be formalized in the form of a concept: the <a href="../../../../utility/OptionalPointee.html" target="_top">OptionalPointee</a> + concept. This concept captures the syntactic usage of operators <code class="computeroutput"><span class="special">*</span></code>, <code class="computeroutput"><span class="special">-&gt;</span></code> + and conversion to <code class="computeroutput"><span class="keyword">bool</span></code> to convey + the notion of optionality.<br> &#36825;&#20010;&#34920;&#31034; optional &#23545;&#35937;&#30340;<span class="emphasis"><em>&#20107;&#23454;&#19978;</em></span>&#30340;&#24815;&#29992;&#27861;&#21487;&#20197;&#29992;&#19968;&#20010;&#27010;&#24565;&#26469;&#35268;&#33539;&#21270;&#65306;<a href="../../../../utility/OptionalPointee.html" target="_top">OptionalPointee</a> &#27010;&#24565;&#12290; + &#35813;&#27010;&#24565;&#21253;&#21547;&#20102;&#25805;&#20316;&#31526; <code class="computeroutput"><span class="special">*</span></code>, + <code class="computeroutput"><span class="special">-&gt;</span></code> &#20197;&#21450;&#36716;&#25442;&#21040; <code class="computeroutput"><span class="keyword">bool</span></code> &#30340;&#35821;&#27861;&#65292;&#20197;&#34920;&#36798;&#21487;&#36873;&#24615;&#30340;&#27010;&#24565;&#12290;
+      </p>
+<p>
+        However, pointers are good to <span class="underline">refer</span>
+ to optional objects, but not particularly good to handle the optional objects + in all other respects, such as initializing or moving/copying them. The problem + resides in the shallow-copy of pointer semantics: if you need to effectively + move or copy the object, pointers alone are not enough. The problem is that + copies of pointers do not imply copies of pointees. For example, as was discussed + in the motivation, pointers alone cannot be used to return optional objects + from a function because the object must move outside from the function and + into the caller's context.<br> &#34429;&#28982;&#25351;&#38024;&#36866;&#21512;&#20110;<span class="underline">&#34920;&#31034;</span> + optional &#23545;&#35937;&#65292;&#20294;&#26159;&#24182;&#19981;&#29305;&#21035;&#36866;&#21512;&#22788;&#29702; optional &#23545;&#35937;&#30340;&#20854;&#23427;&#26041;&#38754;&#65292;&#22914;&#21021;&#22987;&#21270;&#25110;&#31227;&#21160;/&#22797;&#21046;&#12290; + &#38382;&#39064;&#20027;&#35201;&#22312;&#20110;&#25351;&#38024;&#35821;&#20041;&#30340;&#27973;&#22797;&#21046;&#65306;&#22914;&#26524;&#20320;&#38656;&#35201;&#39640;&#25928;&#22320;&#31227;&#21160;&#25110;&#22797;&#21046;&#23545;&#35937;&#65292;&#37027;&#20040;&#20165;&#26377;&#25351;&#38024;&#26159;&#19981;&#22815;&#30340;&#12290;&#38382;&#39064;&#26159;&#25351;&#38024;&#30340;&#25335;&#36125;&#24182;&#19981;&#20195;&#34920;&#34987;&#25351;&#29289;&#30340;&#25335;&#36125;&#12290; + &#20363;&#22914;&#65292;&#35937;&#22312;"&#21160;&#26426;"&#19968;&#33410;&#20013;&#25152;&#35752;&#35770;&#30340;&#65292;&#20165;&#29992;&#25351;&#38024;&#24182;&#19981;&#33021;&#20174;&#19968;&#20010;&#20989;&#25968;&#36820;&#22238; + optional &#23545;&#35937;&#65292;&#22240;&#20026;&#35813;&#23545;&#35937;&#24517;&#39035;&#20174;&#20989;&#25968;&#20013;&#31227;&#33267;&#22806;&#37096;&#65292;&#36827;&#20837;&#35843;&#29992;&#32773;&#30340;&#19978;&#19979;&#25991;&#12290;
+      </p>
+<p>
+ A solution to the shallow-copy problem that is often used is to resort to + dynamic allocation and use a smart pointer to automatically handle the details + of this. For example, if a function is to optionally return an object <code class="computeroutput"><span class="identifier">X</span></code>, it can use <code class="computeroutput"><span class="identifier">shared_ptr</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;</span></code> + as the return value. However, this requires dynamic allocation of <code class="computeroutput"><span class="identifier">X</span></code>. If <code class="computeroutput"><span class="identifier">X</span></code> + is a built-in or small POD, this technique is very poor in terms of required + resources. Optional objects are essentially values so it is very convenient + to be able to use automatic storage and deep-copy semantics to manipulate + optional values just as we do with ordinary values. Pointers do not have + this semantics, so are inappropriate for the initialization and transport + of optional values, yet are quite convenient for handling the access to the + possible undefined value because of the idiomatic aid present in the <a href="../../../../utility/OptionalPointee.html" target="_top">OptionalPointee</a> concept + incarnated by pointers.<br> &#35299;&#20915;&#27973;&#22797;&#21046;&#38382;&#39064;&#30340;&#19968;&#20010;&#24120;&#29992;&#26041;&#27861;&#26159;&#65292;&#37319;&#29992;&#21160;&#24577;&#20998;&#37197;&#24182;&#20351;&#29992;&#26234;&#33021;&#25351;&#38024;&#26469;&#33258;&#21160;&#22788;&#29702;&#20854;&#32454;&#33410;&#12290; + &#20363;&#22914;&#65292;&#22914;&#26524;&#19968;&#20010;&#20989;&#25968;&#21487;&#36873;&#24615;&#22320;&#36820;&#22238;&#19968;&#20010;&#23545;&#35937; <code class="computeroutput"><span class="identifier">X</span></code>, + &#21017;&#21487;&#20197;&#20351;&#29992; <code class="computeroutput"><span class="identifier">shared_ptr</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;</span></code> + &#20316;&#20026;&#36820;&#22238;&#20540;&#12290; &#19981;&#36807;&#65292;&#36825;&#35201;&#27714;&#23545; <code class="computeroutput"><span class="identifier">X</span></code> + &#36827;&#34892;&#21160;&#24577;&#20998;&#37197;&#12290;&#22914;&#26524; <code class="computeroutput"><span class="identifier">X</span></code> + &#26159;&#20869;&#24314;&#30340;&#25110;&#26159;&#23567;&#30340; POD, &#35813;&#25216;&#26415;&#22312;&#36164;&#28304;&#26041;&#38754;&#24456;&#19981;&#21010;&#31639;&#12290; Optional + &#23545;&#35937;&#26412;&#36136;&#19978;&#26159;&#20540;&#23545;&#35937;&#65292;&#25152;&#20197;&#65292;&#22914;&#26524;&#21487;&#20197;&#35937;&#25105;&#20204;&#22788;&#29702;&#26222;&#36890;&#30340;&#20540;&#23545;&#35937;&#37027;&#26679;&#65292;&#20351;&#29992;&#33258;&#21160;&#23384;&#20648;&#21644;&#28145;&#22797;&#21046;&#35821;&#20041;&#26469;&#32500;&#25252; + optional &#20540;&#65292;&#25165;&#26159;&#26368;&#26041;&#20415;&#30340;&#12290; &#25351;&#38024;&#19981;&#20855;&#26377;&#36825;&#31181;&#35821;&#20041;&#65292;&#25152;&#20197;&#19981;&#36866;&#20110;&#21021;&#22987;&#21270;&#21644;&#36716;&#31227; + optional &#20540;&#65292;&#20294;&#36824;&#26159;&#38750;&#24120;&#36866;&#21512;&#20110;&#35775;&#38382;&#26377;&#21487;&#33021;&#26080;&#23450;&#20041;&#30340;&#20540;&#65292; + &#22240;&#20026;&#35813;&#29992;&#27861;&#24050;&#23384;&#22312;&#20110;&#20197;&#25351;&#38024;&#20026;&#20195;&#34920;&#30340; <a href="../../../../utility/OptionalPointee.html" target="_top">OptionalPointee</a>
+        &#27010;&#24565;&#20013;&#12290;
+      </p>
+<a name="boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee__optional_lt_t_gt_______optionalpointee_________"></a><h5>
+<a name="id4860604"></a>
+ <a class="link" href="development.html#boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee__optional_lt_t_gt_______optionalpointee_________">Optional&lt;T&gt; + as a model of OptionalPointee Optional&lt;T&gt;&#20316;&#20026;OptionalPointee&#30340;&#27169;&#22411;</a>
       </h5>
-
-<p>对于值访问操作,<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> 使用操作符 <code class="computeroutput"><span class="special">*</span></code> 和 <code class="computeroutput"><span class="special">-&gt;</span></code>
-来提醒有可能出现的未初始化状态,这类似于指针语义中的空指针用法。<br>
-</p>
-<div class="warning">
-<table summary="Warning" border="0">
-
-  <tbody>
-    <tr>
-
- <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/html/images/warning.png"></td>
-
-      <th align="left">警告</th>
-
-    </tr>
-
-    <tr>
-      <td align="left" valign="top">
- <p>但是,要重点留意的是,<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> 对象不是指针。<span class="underline"><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> 不是也不符合指针的概念</span>。
-        </p>
-      </td>
-    </tr>
-
-  </tbody>
-</table>
+<p>
+ For value access operations <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> uses operators <code class="computeroutput"><span class="special">*</span></code> + and <code class="computeroutput"><span class="special">-&gt;</span></code> to lexically warn + about the possibly uninitialized state appealing to the familiar pointer + semantics w.r.t. to null pointers.<br> &#23545;&#20110;&#20540;&#35775;&#38382;&#25805;&#20316;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> + &#20351;&#29992;&#25805;&#20316;&#31526; <code class="computeroutput"><span class="special">*</span></code> &#21644; <code class="computeroutput"><span class="special">-&gt;</span></code> &#26469;&#25552;&#37266;&#26377;&#21487;&#33021;&#20986;&#29616;&#30340;&#26410;&#21021;&#22987;&#21270;&#29366;&#24577;&#65292;&#36825;&#31867;&#20284;&#20110;&#25351;&#38024;&#35821;&#20041;&#20013;&#30340;&#31354;&#25351;&#38024;&#29992;&#27861;&#12290;
+      </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/html/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ However, it is particularly important to note that <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> objects are not pointers. <span class="underline"><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> is not, and does not model, a pointer</span>.<br> + &#20294;&#26159;&#65292;&#35201;&#37325;&#28857;&#30041;&#24847;&#30340;&#26159;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> &#23545;&#35937;&#19981;&#26159;&#25351;&#38024;&#12290;<span class="underline"><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> &#19981;&#26159;&#20063;&#19981;&#31526;&#21512;&#25351;&#38024;&#30340;&#27010;&#24565;</span>&#12290;
+        </p></td></tr>
+</table></div>
+<p>
+ For instance, <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> + does not have shallow-copy so does not alias: two different optionals never + refer to the <span class="emphasis"><em>same</em></span> value unless <code class="computeroutput"><span class="identifier">T</span></code> + itself is a reference (but may have <span class="emphasis"><em>equivalent</em></span> values). + The difference between an <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + and a pointer must be kept in mind, particularly because the semantics of + relational operators are different: since <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + is a value-wrapper, relational operators are deep: they compare optional + values; but relational operators for pointers are shallow: they do not compare + pointee values. As a result, you might be able to replace <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> + by <code class="computeroutput"><span class="identifier">T</span><span class="special">*</span></code> + on some situations but not always. Specifically, on generic code written + for both, you cannot use relational operators directly, and must use the + template functions <a href="../../../../utility/OptionalPointee.html#equal" target="_top"><code class="computeroutput"><span class="identifier">equal_pointees</span><span class="special">()</span></code></a> + and <a href="../../../../utility/OptionalPointee.html#less" target="_top"><code class="computeroutput"><span class="identifier">less_pointees</span><span class="special">()</span></code></a> + instead.<br> &#20363;&#22914;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> &#27809;&#26377;&#27973;&#22797;&#21046;&#65292;&#25152;&#20197;&#20063;&#27809;&#26377;&#21035;&#21517;&#65306;&#20004;&#20010;&#19981;&#21516;&#30340; + optional &#27704;&#36828;&#19981;&#20250;&#24341;&#21521;<span class="emphasis"><em>&#21516;&#19968;&#20010;</em></span>&#20540;&#65292; &#38500;&#38750; <code class="computeroutput"><span class="identifier">T</span></code> &#26412;&#36523;&#26159;&#19968;&#20010;&#24341;&#29992;(&#20294;&#21487;&#20197;&#26377;<span class="emphasis"><em>&#30456;&#31561;&#30340;</em></span>&#20540;)&#12290;&#24517;&#39035;&#27880;&#24847; + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#21644;&#25351;&#38024;&#38388;&#30340;&#21306;&#21035;&#65292;&#29305;&#21035;&#26159;&#22240;&#20026;&#23427;&#20204;&#30340;&#27604;&#36739;&#25805;&#20316;&#31526;&#30340;&#35821;&#20041;&#26159;&#19981;&#21516;&#30340;&#65306; + &#22240;&#20026; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#26159;&#19968;&#20010;&#20540;&#21253;&#35013;&#22120;&#65292;&#27604;&#36739;&#25805;&#20316;&#31526;&#26159;"&#28145;"&#30340;&#65306;&#23427;&#20204;&#27604;&#36739; + optional &#30340;&#20540;&#65307;&#32780;&#25351;&#38024;&#30340;&#27604;&#36739;&#25805;&#20316;&#31526;&#21017;&#26159;"&#27973;"&#30340;&#65306; + &#23427;&#20204;&#19981;&#27604;&#36739;&#34987;&#25351;&#29289;&#30340;&#20540;&#12290;&#25152;&#20197;&#65292;&#20320;&#20063;&#35768;&#21487;&#20197;&#22312;&#26576;&#20123;&#24773;&#24418;&#19979;&#29992; + <code class="computeroutput"><span class="identifier">T</span><span class="special">*</span></code> + &#26367;&#25442; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>&#65292;&#20294;&#24182;&#19981;&#26159;&#24635;&#21487;&#20197;&#36825;&#26679;&#20570;&#12290; + &#29305;&#21035;&#26159;&#65292;&#22312;&#20026;&#20004;&#32773;&#25152;&#20889;&#30340;&#27867;&#22411;&#20195;&#30721;&#20013;&#65292;&#20320;&#19981;&#33021;&#30452;&#25509;&#20351;&#29992;&#27604;&#36739;&#25805;&#20316;&#31526;&#65292;&#32780;&#24517;&#39035;&#20351;&#29992;&#27169;&#26495;&#20989;&#25968; + <a href="../../../../utility/OptionalPointee.html#equal" target="_top"><code class="computeroutput"><span class="identifier">equal_pointees</span><span class="special">()</span></code></a> &#21644; <a href="../../../../utility/OptionalPointee.html#less" target="_top"><code class="computeroutput"><span class="identifier">less_pointees</span><span class="special">()</span></code></a>
+        &#26469;&#20195;&#26367;&#12290;
+      </p>
 </div>
-
-<p>例如,<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> - 没有浅复制,所以也没有别名:两个不同的 optional 永远不会引向同一个值,除 非 <code class="computeroutput"><span class="identifier">T</span></code> 本 身是一个引用(但可以有相等的值)。必须注意 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> 和指针间 的区别,特别是因为它们的比较操作符的语义是不同的:因为 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> 是一个值包装器,比较操作符是"深"的:它们 比较 optional -的值;而指针的比较操作符则是"浅"的:它们不比较被指物的值。所以,你也许可以 在某些情形下用 <code class="computeroutput"><span class="identifier">T</span><span class="special">*</span></code> -替换 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>,但并不 是总可以这样做。特别是,在为两者所写的泛型代码中,你不能直接使用比较操作 符,而必须使用模板函数 <a href="../../../../utility/OptionalPointee.html#equal" target="_top"><code class="computeroutput"><span class="identifier">equal_pointees</span><span class="special">()</span></code></a> 和 <a href="../../../../utility/OptionalPointee.html#less" target="_top"><code class="computeroutput"><span class="identifier">less_pointees</span><span class="special">()</span></code></a> 来代替。<br>
-</p>
 </div>
-
-</div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright (c) 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="../index.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="synopsis.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
-</body></html>
+</body>
+</html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/examples.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/examples.html Wed Mar 24 00:54:49 2010
@@ -1,119 +1,68 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Examples</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="detailed_semantics.html" title="Detailed Semantics">
-
- <link rel="next" href="optional_references.html" title="Optional references">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Examples &#20363;&#23376;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="detailed_semantics.html" title="Detailed Semantics &#35814;&#32454;&#35821;&#20041;"> +<link rel="next" href="optional_references.html" title="Optional references Optional&#24341;&#29992;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="detailed_semantics.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.examples"></a><a class="link" href="examples.html" title="Examples">例子</a>
-</h2>
-</div>
-</div>
-</div>
-
-<div class="toc">
-<dl>
-
- <dt><span class="section"><a href="examples.html#boost_optional.examples.optional_return_values">Optional
-      返回值</a></span></dt>
-
- <dt><span class="section"><a href="examples.html#boost_optional.examples.optional_local_variables">Optional
-      局部变量</a></span></dt>
-
- <dt><span class="section"><a href="examples.html#boost_optional.examples.optional_data_members">Optional
-      数据成员</a></span></dt>
-
- <dt><span class="section"><a href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction">避 免不必要的昂贵的缺省构造</a></span></dt>
-
-</dl>
-</div>
-
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.examples"></a><a class="link" href="examples.html" title="Examples &#20363;&#23376;"> Examples &#20363;&#23376;</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="examples.html#boost_optional.examples.optional_return_values"> Optional
+      return values Optional&#36820;&#22238;&#20540;</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_optional.examples.optional_local_variables"> Optional + local variables Optional&#23616;&#37096;&#21464;&#37327;</a></span></dt> +<dt><span class="section"><a href="examples.html#boost_optional.examples.optional_data_members"> Optional
+      data members Optional&#25968;&#25454;&#25104;&#21592;</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction"> + Bypassing expensive unnecessary default construction &#36991;&#20813;&#19981;&#24517;&#35201;&#30340;&#26114;&#36149;&#30340;&#32570;&#30465;&#26500;&#36896;</a></span></dt>
+</dl></div>
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h3 class="title">
-<a name="boost_optional.examples.optional_return_values"></a><a class="link" href="examples.html#boost_optional.examples.optional_return_values" title="Optional return values">Optional
-      返回值</a>
-</h3>
-</div>
-</div>
-</div>
-
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_optional.examples.optional_return_values"></a><a class="link" href="examples.html#boost_optional.examples.optional_return_values" title="Optional return values Optional&#36820;&#22238;&#20540;"> Optional
+      return values Optional&#36820;&#22238;&#20540;</a>
+</h3></div></div></div>
<pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;</span> <span class="identifier">get_async_input</span><span class="special">()</span>
 <span class="special">{</span>
<span class="keyword">if</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">queue</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">)</span> <span class="keyword">return</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;(</span><span class="identifier">queue</span><span class="special">.</span><span class="identifier">top</span><span class="special">());</span> - <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;();</span> <span class="comment">// 未初始化 <br></span><span class="special">}</span> + <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;();</span> <span class="comment">// uninitialized &#26410;&#21021;&#22987;&#21270;
+</span><span class="special">}</span>

<span class="keyword">void</span> <span class="identifier">receive_async_message</span><span class="special">()</span>
 <span class="special">{</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">&gt;</span> <span class="identifier">rcv</span> <span class="special">;</span> - <span class="comment">// 此处使用了从 'rcv' 到布尔值的安全转换。 <br></span> <span class="keyword">while</span> <span class="special">(</span> <span class="special">(</span><span class="identifier">rcv</span> <span class="special">=</span> <span class="identifier">get_async_input</span><span class="special">())</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">timeout</span><span class="special">()</span> <span class="special">)</span> + <span class="comment">// The safe boolean conversion from 'rcv' is used here. +</span> <span class="comment">// &#27492;&#22788;&#20351;&#29992;&#20102;&#20174; 'rcv' &#21040;&#24067;&#23572;&#20540;&#30340;&#23433;&#20840;&#36716;&#25442;&#12290; +</span> <span class="keyword">while</span> <span class="special">(</span> <span class="special">(</span><span class="identifier">rcv</span> <span class="special">=</span> <span class="identifier">get_async_input</span><span class="special">())</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">timeout</span><span class="special">()</span> <span class="special">)</span> <span class="identifier">output</span><span class="special">(*</span><span class="identifier">rcv</span><span class="special">);</span>
 <span class="special">}</span>
 </pre>
-
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h3 class="title">
-<a name="boost_optional.examples.optional_local_variables"></a><a class="link" href="examples.html#boost_optional.examples.optional_local_variables" title="Optional local variables">Optional
-      局部变量</a>
-</h3>
-</div>
-</div>
-</div>
-
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_optional.examples.optional_local_variables"></a><a class="link" href="examples.html#boost_optional.examples.optional_local_variables" title="Optional local variables Optional&#23616;&#37096;&#21464;&#37327;"> Optional
+      local variables Optional&#23616;&#37096;&#21464;&#37327;</a>
+</h3></div></div></div>
<pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="identifier">name</span> <span class="special">;</span> <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">database</span><span class="special">.</span><span class="identifier">open</span><span class="special">()</span> <span class="special">)</span>
 <span class="special">{</span>
@@ -129,33 +78,27 @@
<span class="identifier">print</span><span class="special">(*</span><span class="identifier">name</span><span class="special">);</span> <span class="keyword">else</span> <span class="identifier">print</span><span class="special">(</span><span class="string">"employer's name not found!"</span><span class="special">);</span>
 </pre>
-
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h3 class="title">
-<a name="boost_optional.examples.optional_data_members"></a><a class="link" href="examples.html#boost_optional.examples.optional_data_members" title="Optional data members">Optional
-      数据成员</a>
-</h3>
-</div>
-</div>
-</div>
-
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_optional.examples.optional_data_members"></a><a class="link" href="examples.html#boost_optional.examples.optional_data_members" title="Optional data members Optional&#25968;&#25454;&#25104;&#21592;"> Optional
+      data members Optional&#25968;&#25454;&#25104;&#21592;</a>
+</h3></div></div></div>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">figure</span>
 <span class="special">{</span>
     <span class="keyword">public</span><span class="special">:</span>

     <span class="identifier">figure</span><span class="special">()</span>
     <span class="special">{</span>
- <span class="comment">// 此处数据成员 'm_clipping_rect' 未初始化。 <br></span> <span class="special">}</span> + <span class="comment">// data member 'm_clipping_rect' is uninitialized at this point. +</span> <span class="comment">// &#27492;&#22788;&#25968;&#25454;&#25104;&#21592; 'm_clipping_rect' &#26410;&#21021;&#22987;&#21270;&#12290;
+</span>    <span class="special">}</span>

<span class="keyword">void</span> <span class="identifier">clip_in_rect</span> <span class="special">(</span> <span class="identifier">rect</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rect</span> <span class="special">)</span>
     <span class="special">{</span>
         <span class="special">....</span>
- <span class="identifier">m_clipping_rect</span><span class="special">.</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">rect</span> <span class="special">)</span> <span class="special">;</span> <span class="comment">// 此处初始化。<br></span> <span class="special">}</span> + <span class="identifier">m_clipping_rect</span><span class="special">.</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">rect</span> <span class="special">)</span> <span class="special">;</span> <span class="comment">// initialized here. &#27492;&#22788;&#21021;&#22987;&#21270;&#12290;
+</span>    <span class="special">}</span>

<span class="keyword">void</span> <span class="identifier">draw</span> <span class="special">(</span> <span class="identifier">canvas</span><span class="special">&amp;</span> <span class="identifier">cvs</span> <span class="special">)</span>
     <span class="special">{</span>
@@ -165,7 +108,8 @@
<span class="identifier">cvs</span><span class="special">.</span><span class="identifier">drawXXX</span><span class="special">(..);</span>
     <span class="special">}</span>

- <span class="comment">// 可以返回 NULL.<br></span> <span class="identifier">rect</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_clipping_rect</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">m_clipping_rect</span><span class="special">);</span> <span class="special">}</span> + <span class="comment">// this can return NULL. &#21487;&#20197;&#36820;&#22238; NULL. +</span> <span class="identifier">rect</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_clipping_rect</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">get_pointer</span><span class="special">(</span><span class="identifier">m_clipping_rect</span><span class="special">);</span> <span class="special">}</span>

     <span class="keyword">private</span> <span class="special">:</span>

@@ -173,20 +117,12 @@

 <span class="special">};</span>
 </pre>
-
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h3 class="title">
-<a name="boost_optional.examples.bypassing_expensive_unnecessary_default_construction"></a><a class="link" href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction" title="Bypassing expensive unnecessary default construction">避免不必要的昂 贵的缺省构造</a>
-</h3>
-</div>
-</div>
-</div>
-
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_optional.examples.bypassing_expensive_unnecessary_default_construction"></a><a class="link" href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction" title="Bypassing expensive unnecessary default construction &#36991;&#20813;&#19981;&#24517;&#35201;&#30340;&#26114;&#36149;&#30340;&#32570;&#30465;&#26500;&#36896;"> + Bypassing expensive unnecessary default construction &#36991;&#20813;&#19981;&#24517;&#35201;&#30340;&#26114;&#36149;&#30340;&#32570;&#30465;&#26500;&#36896;</a>
+</h3></div></div></div>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">ExpensiveCtor</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span> <span class="special">;</span>
 <span class="keyword">class</span> <span class="identifier">Fred</span>
 <span class="special">{</span>
@@ -195,35 +131,19 @@
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">ExpensiveCtor</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">mLargeVector</span> <span class="special">;</span>
 <span class="special">}</span> <span class="special">;</span>
 </pre>
-
 </div>
-
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="detailed_semantics.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/exception_safety_guarantees.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/exception_safety_guarantees.html Wed Mar 24 00:54:49 2010
@@ -1,119 +1,93 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Exception Safety Guarantees</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="a_note_about_optional_bool_.html" title="A note about optional&lt;bool&gt;">
-
-  <link rel="next" href="type_requirements.html" title="Type requirements">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Exception Safety Guarantees &#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="a_note_about_optional_bool_.html" title="A note about optional&lt;bool&gt; &#20851;&#20110;optional&lt;bool&gt;&#30340;&#35828;&#26126;"> +<link rel="next" href="type_requirements.html" title="Type requirements &#31867;&#22411;&#35201;&#27714;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="type_requirements.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.exception_safety_guarantees"></a><a class="link" href="exception_safety_guarantees.html" title="Exception Safety Guarantees">异常安全性保证</a>
-</h2>
-</div>
-</div>
-</div>
-
-<p>由于当前的实现(请见 <a href="../index.html#optional_implementation_notes">实现说明</a>),所有赋值方 法:
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.exception_safety_guarantees"></a><a class="link" href="exception_safety_guarantees.html" title="Exception Safety Guarantees &#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;"> Exception + Safety Guarantees &#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;</a>
+</h2></div></div></div>
+<p>
+ Because of the current implementation (see <a class="link" href="implementation_notes.html" title="Implementation Notes &#23454;&#29616;&#35828;&#26126;">Implementation + Notes</a>), all of the assignment methods:<br> &#30001;&#20110;&#24403;&#21069;&#30340;&#23454;&#29616;(&#35831;&#35265; + <a class="link" href="implementation_notes.html" title="Implementation Notes &#23454;&#29616;&#35828;&#26126;">&#23454;&#29616;&#35828;&#26126;</a>)&#65292;&#25152;&#26377;&#36171;&#20540;&#26041;&#27861;&#65306;
     </p>
-
-<div class="itemizedlist">
-<ul type="disc">
-
- <li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span>
+<div class="itemizedlist"><ul type="disc">
+<li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span>
         <span class="special">)</span></code></li>
-
- <li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code></li>
-
- <li><code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span> +<li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code></li> +<li><code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span>
         <span class="special">)</span></code></li>
-
- <li><code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> +<li><code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span>
         <span class="special">)</span></code></li>
-
- <li><code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> +<li><code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span>
         <span class="special">)</span> </code></li>
-
- <li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;:::</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;)</span></code></li>
-
-</ul>
-</div>
-
-<p>不提供任何超过 <code>T::operator=( T const&amp; )</code> 所提供的<span style="text-decoration: underline;">异常安全性保证</span>。<code></code></p>
-
-<p>只能保证<span class="underline">基本的异常安全性</span>:如果有异常被抛 出,则左值 optional 将保持为 <span class="underline">未初始化</span> - (原来的值会<span style="font-style: italic;">首先</span>用 <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code> 销毁)。 +<li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;:::</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;)</span></code></li>
+</ul></div>
+<p>
+ Can only <span class="emphasis"><em>guarantee</em></span> the <span class="underline">basic + exception safety</span>: The lvalue optional is left <span class="underline">uninitialized</span> + if an exception is thrown (any previous value is <span class="emphasis"><em>first</em></span> + destroyed using <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>)<br> + &#21482;&#33021;<span class="emphasis"><em>&#20445;&#35777;</em></span><span class="underline">&#22522;&#26412;&#30340;&#24322;&#24120;&#23433;&#20840;&#24615;</span>&#65306;&#22914;&#26524;&#26377;&#24322;&#24120;&#34987;&#25243;&#20986;&#65292;&#21017;&#24038;&#20540; + optional &#23558;&#20445;&#25345;&#20026; <span class="underline">&#26410;&#21021;&#22987;&#21270;</span> (&#21407;&#26469;&#30340;&#20540;&#20250;<span class="emphasis"><em>&#39318;&#20808;</em></span>&#29992; + <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code> &#38144;&#27585;)&#12290;
     </p>
-
-<p>另一方面,<span style="font-style: italic;">去初始化</span>方法:
+<p>
+ On the other hand, the <span class="emphasis"><em>uninitializing</em></span> methods:<br> &#21478;&#19968;&#26041;&#38754;&#65292;<span class="emphasis"><em>&#21435;&#21021;&#22987;&#21270;</em></span>&#26041;&#27861;&#65306;
     </p>
-
-<div class="itemizedlist">
-<ul type="disc">
-
- <li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">none_t</span> <span class="special">)</span></code></li>
-
- <li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">()</span></code></li>
-
-</ul>
-</div>
-
-<p>提供了无抛出保证(假定&nbsp;<code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code> 是无抛出的 )。
+<div class="itemizedlist"><ul type="disc">
+<li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">none_t</span> <span class="special">)</span></code></li> +<li><code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">()</span></code></li>
+</ul></div>
+<p>
+ Provide the no-throw guarantee (assuming a no-throw <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>)<br> + &#25552;&#20379;&#20102;&#26080;&#25243;&#20986;&#20445;&#35777;(&#20551;&#23450; <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>
+      &#26159;&#26080;&#25243;&#20986;&#30340;)&#12290;
     </p>
-
-<p>不过,由于 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> - 本身不抛出任何异常,所以在这里异常的唯一来源是 <code class="computeroutput"><span class="identifier">T</span></code> 的构造函 数,如果你知道 <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span> <span class="special">(</span> - <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> 的异常安全性保证,那么你就可以知道 <code class="computeroutput"><span class="identifier">optional</span></code> 的赋 值和重置都具有相同的保证。
+<p>
+ However, since <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> + itself doesn't throw any exceptions, the only source for exceptions here are + <code class="computeroutput"><span class="identifier">T</span></code>'s constructor, so if you + know the exception guarantees for <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span> <span class="special">(</span> + <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code>, you + know that <code class="computeroutput"><span class="identifier">optional</span></code>'s assignment + and reset has the same guarantees.<br> &#19981;&#36807;&#65292;&#30001;&#20110; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> &#26412;&#36523;&#19981;&#25243;&#20986;&#20219;&#20309;&#24322;&#24120;&#65292;&#25152;&#20197;&#22312;&#36825;&#37324;&#24322;&#24120;&#30340;&#21807;&#19968;&#26469;&#28304;&#26159; + <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#26500;&#36896;&#20989;&#25968;&#65292; &#22914;&#26524;&#20320;&#30693;&#36947; + <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span> <span class="special">(</span> <span class="identifier">T</span>
+      <span class="keyword">const</span><span class="special">&amp;</span>
+ <span class="special">)</span></code> &#30340;&#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;&#65292;&#37027;&#20040;&#20320;&#23601;&#21487;&#20197;&#30693;&#36947; + <code class="computeroutput"><span class="identifier">optional</span></code> &#30340;&#36171;&#20540;&#21644;&#37325;&#32622;&#37117;&#20855;&#26377;&#30456;&#21516;&#30340;&#20445;&#35777;&#12290;
     </p>
-
-<pre class="programlisting"><span class="comment">//<br></span><span class="comment">// Case 1: 在赋值时抛出异常。<br></span><span class="comment">//<br></span><span class="identifier">T</span> <span class="identifier">v0</span><span class="special">(</span><span class="number">123</span><span class="special">);</span>
+<pre class="programlisting"><span class="comment">//
+</span><span class="comment">// Case 1: Exception thrown during assignment.
+</span><span class="comment">// Case 1: &#22312;&#36171;&#20540;&#26102;&#25243;&#20986;&#24322;&#24120;&#12290;
+</span><span class="comment">//
+</span><span class="identifier">T</span> <span class="identifier">v0</span><span class="special">(</span><span class="number">123</span><span class="special">);</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">opt0</span><span class="special">(</span><span class="identifier">v0</span><span class="special">);</span>
 <span class="keyword">try</span>
 <span class="special">{</span>
@@ -121,67 +95,72 @@
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">opt1</span><span class="special">(</span><span class="identifier">v1</span><span class="special">);</span> <span class="identifier">opt0</span> <span class="special">=</span> <span class="identifier">opt1</span> <span class="special">;</span>

- <span class="comment">// 如果没有异常抛出,则赋值成功。<br></span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">*</span><span class="identifier">opt0</span> <span class="special">==</span> <span class="identifier">v1</span> <span class="special">)</span> <span class="special">;</span> + <span class="comment">// If no exception was thrown, assignment succeeded. +</span> <span class="comment">// &#22914;&#26524;&#27809;&#26377;&#24322;&#24120;&#25243;&#20986;&#65292;&#21017;&#36171;&#20540;&#25104;&#21151;&#12290; +</span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">*</span><span class="identifier">opt0</span> <span class="special">==</span> <span class="identifier">v1</span> <span class="special">)</span> <span class="special">;</span>
 <span class="special">}</span>
 <span class="keyword">catch</span><span class="special">(...)</span>
 <span class="special">{</span>
- <span class="comment">// 如果有任何异常抛出,则 'opt0' 被重置为未初始 化。<br></span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">!</span><span class="identifier">opt0</span> <span class="special">)</span> <span class="special">;</span> + <span class="comment">// If any exception was thrown, 'opt0' is reset to uninitialized. +</span> <span class="comment">// &#22914;&#26524;&#26377;&#20219;&#20309;&#24322;&#24120;&#25243;&#20986;&#65292;&#21017; 'opt0' &#34987;&#37325;&#32622;&#20026;&#26410;&#21021;&#22987;&#21270;&#12290; +</span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">!</span><span class="identifier">opt0</span> <span class="special">)</span> <span class="special">;</span>
 <span class="special">}</span>

-<span class="comment">//<br></span><span class="comment">// Case 2: 在 reset(v) 时抛出异常<br></span><span class="comment">//<br></span><span class="identifier">T</span> <span class="identifier">v0</span><span class="special">(</span><span class="number">123</span><span class="special">);</span>
+<span class="comment">//
+</span><span class="comment">// Case 2: Exception thrown during reset(v)
+</span><span class="comment">// Case 2: &#22312; reset(v) &#26102;&#25243;&#20986;&#24322;&#24120;
+</span><span class="comment">//
+</span><span class="identifier">T</span> <span class="identifier">v0</span><span class="special">(</span><span class="number">123</span><span class="special">);</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">opt</span><span class="special">(</span><span class="identifier">v0</span><span class="special">);</span>
 <span class="keyword">try</span>
 <span class="special">{</span>
<span class="identifier">T</span> <span class="identifier">v1</span><span class="special">(</span><span class="number">456</span><span class="special">);</span> <span class="identifier">opt</span><span class="special">.</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">v1</span> <span class="special">)</span> <span class="special">;</span>

- <span class="comment">// 如果没有异常抛出,则重置成功。<br></span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">v1</span> <span class="special">)</span> <span class="special">;</span>
+    <span class="comment">// If no exception was thrown, reset succeeded.
+</span> <span class="comment">// &#22914;&#26524;&#27809;&#26377;&#24322;&#24120;&#25243;&#20986;&#65292;&#21017;&#37325;&#32622;&#25104;&#21151;&#12290; +</span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">v1</span> <span class="special">)</span> <span class="special">;</span>
 <span class="special">}</span>
 <span class="keyword">catch</span><span class="special">(...)</span>
 <span class="special">{</span>
- <span class="comment">// 如果有任何异常抛出,则 'opt' 被重置为未初始 化。<br></span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">!</span><span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> + <span class="comment">// If any exception was thrown, 'opt' is reset to uninitialized. +</span> <span class="comment">// &#22914;&#26524;&#26377;&#20219;&#20309;&#24322;&#24120;&#25243;&#20986;&#65292;&#21017; 'opt' &#34987;&#37325;&#32622;&#20026;&#26410;&#21021;&#22987;&#21270;&#12290; +</span> <span class="identifier">assert</span><span class="special">(</span> <span class="special">!</span><span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span>
 <span class="special">}</span>
 </pre>
-
-<a name="boost_optional.exception_safety_guarantees.swap"></a>
-<h4>
-<a name="id2664646"></a>
- <a class="link" href="exception_safety_guarantees.html#boost_optional.exception_safety_guarantees.swap">交 换</a>
+<a name="boost_optional.exception_safety_guarantees.swap_______"></a><h4>
+<a name="id4894853"></a>
+ <a class="link" href="exception_safety_guarantees.html#boost_optional.exception_safety_guarantees.swap_______">Swap
+      &#20132;&#25442;</a>
     </h4>
-
 <p>
<code class="computeroutput"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;,</span> - <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="special">)</span></code> 在两 个 optional 均已初始化时,具有与 <code>swap(T&amp;,T&amp;)</code> 相同的异常 保证。如果只有一个 -optional 是已初始化的,则它提供与&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> 一样的 <span style="font-style: italic;">基本</span>异常保证(因为&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> 不会抛出)。如果两个 optional
-均未初始化,则它具有无抛出保证,因为这是一个空操作。
+ <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="special">)</span></code> has the same exception guarantee as <code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&amp;,</span><span class="identifier">T</span><span class="special">&amp;)</span></code> + when both optionals are initialized. If only one of the optionals is initialized, + it gives the same <span class="emphasis"><em>basic</em></span> exception guarantee as <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> (since + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">()</span></code> doesn't throw). If none of the optionals + is initialized, it has no-throw guarantee since it is a no-op.<br> <code class="computeroutput"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;,</span> + <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="special">)</span></code> &#22312;&#20004;&#20010; <code class="computeroutput"><span class="identifier">optional</span></code> + &#22343;&#24050;&#21021;&#22987;&#21270;&#26102;&#65292;&#20855;&#26377;&#19982; <code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&amp;,</span><span class="identifier">T</span><span class="special">&amp;)</span></code> &#30456;&#21516;&#30340;&#24322;&#24120;&#20445;&#35777;&#12290; + &#22914;&#26524;&#21482;&#26377;&#19968;&#20010; <code class="computeroutput"><span class="identifier">optional</span></code> + &#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#65292;&#21017;&#23427;&#25552;&#20379;&#19982; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">(</span> <span class="identifier">T</span>
+      <span class="keyword">const</span><span class="special">&amp;</span>
+ <span class="special">)</span></code> &#19968;&#26679;&#30340;<span class="emphasis"><em>&#22522;&#26412;</em></span>&#24322;&#24120;&#20445;&#35777; + (&#22240;&#20026; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">reset</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code> &#19981;&#20250;&#25243;&#20986;)&#12290;&#22914;&#26524;&#20004;&#20010; + <code class="computeroutput"><span class="identifier">optional</span></code> &#22343;&#26410;&#21021;&#22987;&#21270;&#65292;&#21017;&#23427;&#20855;&#26377;&#26080;&#25243;&#20986;&#20445;&#35777;&#65292;&#22240;&#20026;&#36825;&#26159;&#19968;&#20010;&#31354;&#25805;&#20316;&#12290;
     </p>
-
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="type_requirements.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/implementation_notes.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/implementation_notes.html Wed Mar 24 00:54:49 2010
@@ -1,96 +1,63 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Implementation Notes</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-  <link rel="prev" href="type_requirements.html" title="Type requirements">
-
- <link rel="next" href="dependencies_and_portability.html" title="Dependencies and Portability">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Implementation Notes &#23454;&#29616;&#35828;&#26126;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="type_requirements.html" title="Type requirements &#31867;&#22411;&#35201;&#27714;"> +<link rel="next" href="dependencies_and_portability.html" title="Dependencies and Portability &#20381;&#36182;&#24615;&#21644;&#21487;&#31227;&#26893;&#24615;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="type_requirements.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.implementation_notes"></a><a class="link" href="implementation_notes.html" title="Implementation Notes">实现说明</a>
-</h2>
-</div>
-</div>
-</div>
-
-
-
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.implementation_notes"></a><a class="link" href="implementation_notes.html" title="Implementation Notes &#23454;&#29616;&#35828;&#26126;"> Implementation Notes
+    &#23454;&#29616;&#35828;&#26126;</a>
+</h2></div></div></div>
 <p>
- <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt; </span></code>当前的实 现使用了一个由 <code>alignment_of</code> 和 <code>type_with_alignment</code> (均来自 -Type Traits)构建的定制对齐存储工具。它使用一个独立的布尔标志来标识初始化状 态。带有&nbsp;<code class="computeroutput"><span class="identifier">T</span></code> 的复制构造函数的 Placement new 以及 &nbsp;<code class="computeroutput"><span class="identifier">T</span></code> 的析构函数被显式用于初始化、复制和销毁 optional 的值。这样可以有效地绕过 &nbsp;<code class="computeroutput"><span class="identifier">T</span></code> -的缺省构造函数,但是异常保证只能是基本的。有计划用其它具有更强异常安全性的 方法来替代当前的实现,如未来的 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">variant</span></code>. + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> is + currently implemented using a custom aligned storage facility built from <code class="computeroutput"><span class="identifier">alignment_of</span></code> and <code class="computeroutput"><span class="identifier">type_with_alignment</span></code> + (both from Type Traits). It uses a separate boolean flag to indicate the initialization + state. Placement new with <code class="computeroutput"><span class="identifier">T</span></code>'s + copy constructor and <code class="computeroutput"><span class="identifier">T</span></code>'s destructor + are explicitly used to initialize,copy and destroy optional values. As a result, + <code class="computeroutput"><span class="identifier">T</span></code>'s default constructor is + effectively by-passed, but the exception guarantees are basic. It is planned + to replace the current implementation with another with stronger exception + safety, such as a future <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">variant</span></code>.<br> + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> &#24403;&#21069;&#30340;&#23454;&#29616;&#20351;&#29992;&#20102;&#19968;&#20010;&#30001; + <code class="computeroutput"><span class="identifier">alignment_of</span></code> &#21644; <code class="computeroutput"><span class="identifier">type_with_alignment</span></code> (&#22343;&#26469;&#33258; Type Traits)&#26500;&#24314;&#30340;&#23450;&#21046;&#23545;&#40784;&#23384;&#20648;&#24037;&#20855;&#12290; + &#23427;&#20351;&#29992;&#19968;&#20010;&#29420;&#31435;&#30340;&#24067;&#23572;&#26631;&#24535;&#26469;&#26631;&#35782;&#21021;&#22987;&#21270;&#29366;&#24577;&#12290;&#24102;&#26377; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#22797;&#21046;&#26500;&#36896;&#20989;&#25968;&#30340; Placement new + &#20197;&#21450; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#26512;&#26500;&#20989;&#25968;&#34987;&#26174;&#24335;&#29992;&#20110;&#21021;&#22987;&#21270;&#12289; + &#22797;&#21046;&#21644;&#38144;&#27585; optional &#30340;&#20540;&#12290;&#36825;&#26679;&#21487;&#20197;&#26377;&#25928;&#22320;&#32469;&#36807; <code class="computeroutput"><span class="identifier">T</span></code> &#30340;&#32570;&#30465;&#26500;&#36896;&#20989;&#25968;&#65292;&#20294;&#26159;&#24322;&#24120;&#20445;&#35777;&#21482;&#33021;&#26159;&#22522;&#26412;&#30340;&#12290; + &#26377;&#35745;&#21010;&#29992;&#20854;&#23427;&#20855;&#26377;&#26356;&#24378;&#24322;&#24120;&#23433;&#20840;&#24615;&#30340;&#26041;&#27861;&#26469;&#26367;&#20195;&#24403;&#21069;&#30340;&#23454;&#29616;&#65292;&#22914;&#26410;&#26469;&#30340; + <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">variant</span></code>.
     </p>
-
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="type_requirements.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/in_place_factories.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/in_place_factories.html Wed Mar 24 00:54:49 2010
@@ -1,65 +1,42 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>In-Place Factories</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">
-
- <link rel="next" href="a_note_about_optional_bool_.html" title="A note about optional&lt;bool&gt;">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>In-Place Factories &#23601;&#22320;&#21019;&#24314;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;"> +<link rel="next" href="a_note_about_optional_bool_.html" title="A note about optional&lt;bool&gt; &#20851;&#20110;optional&lt;bool&gt;&#30340;&#35828;&#26126;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.in_place_factories"></a><a class="link" href="in_place_factories.html" title="In-Place Factories">就地创建</a>
-</h2>
-</div>
-</div>
-</div>
-
-<p>使用包装器和容器的一个常见问题是,它们通常会有一个接口提供一个操作,将所 含对象初始化或赋值为另一个对象的拷贝。这不仅要求底层的类型是 <a href="../../../../utility/CopyConstructible.html">可复制构造的</a>,而且还要 求一个完全构造的对象,该对象通常是临时的,仅用作复制的来源:&nbsp;
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.in_place_factories"></a><a class="link" href="in_place_factories.html" title="In-Place Factories &#23601;&#22320;&#21019;&#24314;"> In-Place Factories
+    &#23601;&#22320;&#21019;&#24314;</a>
+</h2></div></div></div>
+<p>
+ One of the typical problems with wrappers and containers is that their interfaces + usually provide an operation to initialize or assign the contained object as + a copy of some other object. This not only requires the underlying type to + be <a href="../../../../utility/CopyConstructible.html" target="_top">Copy Constructible</a>, + but also requires the existence of a fully constructed object, often temporary, + just to follow the copy from:<br> &#20351;&#29992;&#21253;&#35013;&#22120;&#21644;&#23481;&#22120;&#30340;&#19968;&#20010;&#24120;&#35265;&#38382;&#39064;&#26159;&#65292;&#23427;&#20204;&#36890;&#24120;&#20250;&#26377;&#19968;&#20010;&#25509;&#21475;&#25552;&#20379;&#19968;&#20010;&#25805;&#20316;&#65292;&#23558;&#25152;&#21547;&#23545;&#35937;&#21021;&#22987;&#21270;&#25110;&#36171;&#20540;&#20026;&#21478;&#19968;&#20010;&#23545;&#35937;&#30340;&#25335;&#36125;&#12290; + &#36825;&#19981;&#20165;&#35201;&#27714;&#24213;&#23618;&#30340;&#31867;&#22411;&#26159; <a href="../../../../utility/CopyConstructible.html" target="_top">Copy + Constructible</a>&#65292;&#32780;&#19988;&#36824;&#35201;&#27714;&#19968;&#20010;&#23436;&#20840;&#26500;&#36896;&#30340;&#23545;&#35937;&#65292;&#35813;&#23545;&#35937;&#36890;&#24120;&#26159;&#20020;&#26102;&#30340;&#65292;&#20165;&#29992;&#20316;&#22797;&#21046;&#30340;&#26469;&#28304;&#65306;
     </p>
-
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span>
 <span class="special">{</span>
<span class="identifier">X</span> <span class="special">(</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">:::</span><span class="identifier">string</span> <span class="special">)</span> <span class="special">;</span>
@@ -76,14 +53,17 @@

<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">()</span>
 <span class="special">{</span>
- <span class="comment">// 创建临时对象<br></span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">X</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span> + <span class="comment">// Temporary object created. &#21019;&#24314;&#20020;&#26102;&#23545;&#35937; +</span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">X</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
 <span class="special">}</span>
 </pre>
-
 <p>
- 解决这一问题的一种方法是,提供在容器的存储中直接构造所含对象的支持。 这样一来,用户只需要将相关参数提供给构造函数,用于所含对象的构造。 + A solution to this problem is to support direct construction of the contained + object right in the container's storage. In this scheme, the user only needs + to supply the arguments to the constructor to use in the wrapped object construction.<br> + &#35299;&#20915;&#36825;&#19968;&#38382;&#39064;&#30340;&#19968;&#31181;&#26041;&#27861;&#26159;&#65292;&#25552;&#20379;&#22312;&#23481;&#22120;&#30340;&#23384;&#20648;&#20013;&#30452;&#25509;&#26500;&#36896;&#25152;&#21547;&#23545;&#35937;&#30340;&#25903;&#25345;&#12290; + &#36825;&#26679;&#19968;&#26469;&#65292;&#29992;&#25143;&#21482;&#38656;&#35201;&#23558;&#30456;&#20851;&#21442;&#25968;&#25552;&#20379;&#32473;&#26500;&#36896;&#20989;&#25968;&#65292;&#29992;&#20110;&#25152;&#21547;&#23545;&#35937;&#30340;&#26500;&#36896;&#12290;
     </p>
-
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">W</span>
 <span class="special">{</span>
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
@@ -96,18 +76,30 @@

<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">()</span>
 <span class="special">{</span>
- <span class="comment">// 就地创建所含对象,不再需要创建临时对象 </span><span class="comment">。<br></span> <span class="identifier">W</span> <span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">)</span> <span class="special">;</span>
+    <span class="comment">// Wrapped object constructed in-place
+</span>    <span class="comment">// No temporary created.
+</span> <span class="comment">// &#23601;&#22320;&#21019;&#24314;&#25152;&#21547;&#23545;&#35937;&#65292;&#19981;&#20877;&#38656;&#35201;&#21019;&#24314;&#20020;&#26102;&#23545;&#35937;&#12290; +</span> <span class="identifier">W</span> <span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">)</span> <span class="special">;</span>
 <span class="special">}</span>
 </pre>
-
-<p>这种方法的限制在于,它不适用于带有多个构造函数的被包装对象,也不适用于对 构造函数重载不知情的泛型代码。</p>
-
-<p>在本库中,解决的方法是 <b>InPlaceFactories</b> 和 <b>TypedInPlaceFactories</b> -家族。这些工厂是一族类,这些类封装了不同参数数量的构造函数参数,提供一个方 法来构造给定类型的一个对象,构造时使用这些被封装的参数,并通过
-placement new 在用户指定的地址进行构造。</p>
-
-<p>例如,这个类族中的其中一个类如下:<br>
-</p>
+<p>
+ A limitation of this method is that it doesn't scale well to wrapped objects + with multiple constructors nor to generic code were the constructor overloads + are unknown.<br> &#36825;&#31181;&#26041;&#27861;&#30340;&#38480;&#21046;&#22312;&#20110;&#65292;&#23427;&#19981;&#36866;&#29992;&#20110;&#24102;&#26377;&#22810;&#20010;&#26500;&#36896;&#20989;&#25968;&#30340;&#34987;&#21253;&#35013;&#23545;&#35937;&#65292;&#20063;&#19981;&#36866;&#29992;&#20110;&#23545;&#26500;&#36896;&#20989;&#25968;&#37325;&#36733;&#19981;&#30693;&#24773;&#30340;&#27867;&#22411;&#20195;&#30721;&#12290;
+    </p>
+<p>
+ The solution presented in this library is the family of <span class="bold"><strong>InPlaceFactories</strong></span> + and <span class="bold"><strong>TypedInPlaceFactories</strong></span>. These factories + are a family of classes which encapsulate an increasing number of arbitrary + constructor parameters and supply a method to construct an object of a given + type using those parameters at an address specified by the user via placement + new.<br> &#22312;&#26412;&#24211;&#20013;&#65292;&#35299;&#20915;&#30340;&#26041;&#27861;&#26159; <span class="bold"><strong>InPlaceFactories</strong></span> + &#21644; <span class="bold"><strong>TypedInPlaceFactories</strong></span> &#23478;&#26063;&#12290; &#36825;&#20123;&#24037;&#21378;&#26159;&#19968;&#26063;&#31867;&#65292;&#36825;&#20123;&#31867;&#23553;&#35013;&#20102;&#19981;&#21516;&#21442;&#25968;&#25968;&#37327;&#30340;&#26500;&#36896;&#20989;&#25968;&#21442;&#25968;&#65292;&#25552;&#20379;&#19968;&#20010;&#26041;&#27861;&#26469;&#26500;&#36896;&#32473;&#23450;&#31867;&#22411;&#30340;&#19968;&#20010;&#23545;&#35937;&#65292; + &#26500;&#36896;&#26102;&#20351;&#29992;&#36825;&#20123;&#34987;&#23553;&#35013;&#30340;&#21442;&#25968;&#65292;&#24182;&#36890;&#36807; placement new &#22312;&#29992;&#25143;&#25351;&#23450;&#30340;&#22320;&#22336;&#36827;&#34892;&#26500;&#36896;&#12290;
+    </p>
+<p>
+ For example, one member of this family looks like:<br> &#20363;&#22914;&#65292;&#36825;&#20010;&#31867;&#26063;&#20013;&#30340;&#20854;&#20013;&#19968;&#20010;&#31867;&#22914;&#19979;&#65306;
+    </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">&gt;</span> <span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory2</span>
 <span class="special">{</span>
@@ -120,10 +112,9 @@
<span class="keyword">void</span> <span class="identifier">construct</span> <span class="special">(</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">p</span> <span class="special">)</span> <span class="special">{</span> <span class="keyword">new</span> <span class="special">(</span><span class="identifier">p</span><span class="special">)</span> <span class="identifier">T</span><span class="special">(</span><span class="identifier">m_a0</span><span class="special">,</span><span class="identifier">m_a1</span><span class="special">)</span> <span class="special">;</span> <span class="special">}</span>
  <span class="special">}</span> <span class="special">;</span>
 </pre>
-
-<p>一个包装类可以这样来使用它:
+<p>
+ A wrapper class aware of this can use it as:<br> &#19968;&#20010;&#21253;&#35013;&#31867;&#21487;&#20197;&#36825;&#26679;&#26469;&#20351;&#29992;&#23427;&#65306;
     </p>
-
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">W</span>
 <span class="special">{</span>
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
@@ -136,33 +127,47 @@

<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">()</span>
 <span class="special">{</span>
- <span class="comment">// 通过 TypedInPlaceFactory 就地构造被包装对象。 无需创建临时对象。</span><span class="comment"><br></span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory2</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">,</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span><span class="identifier">rt</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">))</span> <span class="special">;</span> + <span class="comment">// Wrapped object constructed in-place via a TypedInPlaceFactory.
+</span>    <span class="comment">// No temporary created.
+</span> <span class="comment">// &#36890;&#36807; TypedInPlaceFactory &#23601;&#22320;&#26500;&#36896;&#34987;&#21253;&#35013;&#23545;&#35937;&#12290;&#26080;&#38656;&#21019;&#24314;&#20020;&#26102;&#23545;&#35937;&#12290; +</span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory2</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">,</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&gt;(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">))</span> <span class="special">;</span>
 <span class="special">}</span>
 </pre>
-
-<p>这些工厂类被分为两组:</p>
-
-<ul>
-  <li><u>TypedInPlaceFactories</u>: 它们以目标类型作为主模板参数。
-  </li>
- <li><u>InPlaceFactories</u>: 它们以模板化的 <code>construct(void*)</code> 成员函数来接受目标类型。
-  </li>
-</ul>
-
-<p>在每一组中,所有类族成员仅在可接受的参数数量上有所不同。</p>
-
-<p>本库还提供了一组重载的模板函数来构造这些工厂类,从而无需给定模板参 数:<br>
-</p>
+<p>
+ The factories are divided in two groups:<br> &#36825;&#20123;&#24037;&#21378;&#31867;&#34987;&#20998;&#20026;&#20004;&#32452;&#65306;
+    </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+<span class="underline">TypedInPlaceFactories</span>: those which
+ take the target type as a primary template parameter.<br><span class="underline">TypedInPlaceFactories</span>: + &#23427;&#20204;&#20197;&#30446;&#26631;&#31867;&#22411;&#20316;&#20026;&#20027;&#27169;&#26495;&#21442;&#25968;&#12290;
+      </li>
+<li>
+<span class="underline">InPlaceFactories</span>: those with a template
+ <code class="computeroutput"><span class="identifier">construct</span><span class="special">(</span><span class="keyword">void</span><span class="special">*)</span></code> member + function taking the target type.<br><span class="underline">InPlaceFactories</span>: + &#23427;&#20204;&#20197;&#27169;&#26495;&#21270;&#30340; <code class="computeroutput"><span class="identifier">construct</span><span class="special">(</span><span class="keyword">void</span><span class="special">*)</span></code> + &#25104;&#21592;&#20989;&#25968;&#26469;&#25509;&#21463;&#30446;&#26631;&#31867;&#22411;&#12290;
+      </li>
+</ul></div>
+<p>
+ Within each group, all the family members differ only in the number of parameters + allowed.<br> &#22312;&#27599;&#19968;&#32452;&#20013;&#65292;&#25152;&#26377;&#31867;&#26063;&#25104;&#21592;&#20165;&#22312;&#21487;&#25509;&#21463;&#30340;&#21442;&#25968;&#25968;&#37327;&#19978;&#26377;&#25152;&#19981;&#21516;&#12290;
+    </p>
+<p>
+ This library provides an overloaded set of helper template functions to construct + these factories without requiring unnecessary template parameters:<br> &#26412;&#24211;&#36824;&#25552;&#20379;&#20102;&#19968;&#32452;&#37325;&#36733;&#30340;&#27169;&#26495;&#20989;&#25968;&#26469;&#26500;&#36896;&#36825;&#20123;&#24037;&#21378;&#31867;&#65292;&#20174;&#32780;&#26080;&#38656;&#32473;&#23450;&#27169;&#26495;&#21442;&#25968;&#65306;
+    </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,...,</span><span class="keyword">class</span> <span class="identifier">AN</span><span class="special">&gt;</span> <span class="identifier">InPlaceFactoryN</span> <span class="special">&lt;</span><span class="identifier">A0</span><span class="special">,...,</span><span class="identifier">AN</span><span class="special">&gt;</span> <span class="identifier">in_place</span> <span class="special">(</span> <span class="identifier">A0</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">AN</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">aN</span><span class="special">)</span> <span class="special">;</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,...,</span><span class="keyword">class</span> <span class="identifier">AN</span><span class="special">&gt;</span> <span class="identifier">TypedInPlaceFactoryN</span> <span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">A0</span><span class="special">,...,</span><span class="identifier">AN</span><span class="special">&gt;</span> <span class="identifier">in_place</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A0</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a0</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">AN</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">aN</span><span class="special">)</span> <span class="special">;</span>
 </pre>
-
-<p>就地创建可以被包装器和用户泛型地使用,如下:
+<p>
+ In-place factories can be used generically by the wrapper and user as follows:<br> + &#23601;&#22320;&#21019;&#24314;&#21487;&#20197;&#34987;&#21253;&#35013;&#22120;&#21644;&#29992;&#25143;&#27867;&#22411;&#22320;&#20351;&#29992;&#65292;&#22914;&#19979;&#65306;
     </p>
-
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">W</span>
 <span class="special">{</span>
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
@@ -178,40 +183,31 @@

<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">()</span>
 <span class="special">{</span>
- <span class="comment">// 通过 InPlaceFactory 就地构造被包装的对象。无需 创建临时对象。</span><span class="comment"><br></span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">in_place</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span> + <span class="comment">// Wrapped object constructed in-place via a InPlaceFactory.
+</span>    <span class="comment">// No temporary created.
+</span> <span class="comment">// &#36890;&#36807; InPlaceFactory &#23601;&#22320;&#26500;&#36896;&#34987;&#21253;&#35013;&#30340;&#23545;&#35937;&#12290;&#26080;&#38656;&#21019;&#24314;&#20020;&#26102;&#23545;&#35937;&#12290; +</span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">in_place</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
 <span class="special">}</span>
 </pre>
-
-<p>这些工厂类在头文件&nbsp;<a href="../../../../../boost/utility/in_place_factory.hpp" target="_top">in_place_factory.hpp</a> 和 <a href="../../../../../boost/utility/typed_in_place_factory.hpp" target="_top">typed_in_place_factory.hpp</a><a href="../../../boost/utility/typed_in_place_factory.hpp"></a>
-中实现。
+<p>
+ The factories are implemented in the headers: <a href="../../../../../boost/utility/in_place_factory.hpp" target="_top">in_place_factory.hpp</a> + and <a href="../../../../../boost/utility/typed_in_place_factory.hpp" target="_top">typed_in_place_factory.hpp</a><br> + &#36825;&#20123;&#24037;&#21378;&#31867;&#22312;&#22836;&#25991;&#20214; <a href="../../../../../boost/utility/in_place_factory.hpp" target="_top">in_place_factory.hpp</a> + &#21644; <a href="../../../../../boost/utility/typed_in_place_factory.hpp" target="_top">typed_in_place_factory.hpp</a>
+      &#20013;&#23454;&#29616;&#12290;
     </p>
-
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/optional_references.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/optional_references.html Wed Mar 24 00:54:49 2010
@@ -1,161 +1,91 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-
-
-
-  <title>Optional references</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
-
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-
-
-  <link rel="prev" href="examples.html" title="Examples">
-
-
-
- <link rel="next" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Optional references Optional&#24341;&#29992;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional">
+<link rel="prev" href="examples.html" title="Examples &#20363;&#23376;">
+<link rel="next" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;">
 </head>
-
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-
-<table cellpadding="2" width="100%">
-
-  <tbody>
-
-    <tr>
-
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-
-    </tr>
-
-
-  </tbody>
-</table>
-
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="examples.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.optional_references"></a><a class="link" href="optional_references.html" title="Optional references">Optional 引用 </a>
-</h2>
-
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.optional_references"></a><a class="link" href="optional_references.html" title="Optional references Optional&#24341;&#29992;"> Optional references
+    Optional&#24341;&#29992;</a>
+</h2></div></div></div>
+<p>
+ This library allows the template parameter <code class="computeroutput"><span class="identifier">T</span></code> + to be of reference type: <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>, and to some extent, <code class="computeroutput"><span class="identifier">T</span> + <span class="keyword">const</span><span class="special">&amp;</span></code>.<br> + &#26412;&#24211;&#20801;&#35768;&#27169;&#26495;&#21442;&#25968; <code class="computeroutput"><span class="identifier">T</span></code> + &#21487;&#20197;&#26159;&#24341;&#29992;&#31867;&#22411;&#65306;<code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>, + &#21450;&#20854;&#25193;&#23637; <code class="computeroutput"><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span></code>.
+    </p>
+<p>
+ However, since references are not real objects some restrictions apply and + some operations are not available in this case:<br> &#19981;&#36807;&#65292;&#30001;&#20110;&#24341;&#29992;&#19981;&#26159;&#30495;&#27491;&#30340;&#23545;&#35937;&#65292;&#25152;&#20197;&#26377;&#19968;&#20123;&#38480;&#21046;&#65292;&#26377;&#20123;&#25805;&#20316;&#19981;&#21487;&#20351;&#29992;&#65306;
+    </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ Converting constructors<br> &#36716;&#25442;&#26500;&#36896;&#20989;&#25968;
+      </li>
+<li>
+        Converting assignment<br> &#36716;&#25442;&#36171;&#20540;
+      </li>
+<li>
+        InPlace construction<br> &#23601;&#22320;&#26500;&#36896;
+      </li>
+<li>
+        InPlace assignment<br> &#23601;&#22320;&#36171;&#20540;
+      </li>
+<li>
+ Value-access via pointer<br> &#36890;&#36807;&#25351;&#38024;&#30340;&#20540;&#35775;&#38382;
+      </li>
+</ul></div>
+<p>
+ Also, even though <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + treats it wrapped pseudo-object much as a real value, a true real reference + is stored so aliasing will ocurr:<br> &#32780;&#19988;&#65292;&#34429;&#28982; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + &#22312;&#22788;&#29702;&#20854;&#21253;&#35013;&#30340;&#20266;&#23545;&#35937;&#26102;&#19982;&#30495;&#27491;&#30340;&#20540;&#23545;&#35937;&#38750;&#24120;&#30456;&#20284;&#65292; &#20294;&#23454;&#38469;&#19978;&#23427;&#20445;&#23384;&#30340;&#26159;&#19968;&#20010;&#30495;&#27491;&#30340;&#24341;&#29992;&#65292;&#25152;&#20197;&#21487;&#33021;&#21457;&#29983;&#20197;&#19979;&#23481;&#26131;&#28151;&#28102;&#30340;&#24773;&#20917;&#65306;
+    </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ Copies of <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + will copy the references but all these references will nonetheless reefer + to the same object.<br> &#22797;&#21046; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + &#23558;&#23545;&#24341;&#29992;&#36827;&#34892;&#22797;&#21046;&#65292;&#20294;&#25152;&#26377;&#34987;&#22797;&#21046;&#30340;&#24341;&#29992;&#37117;&#23558;&#24341;&#21521;&#21516;&#19968;&#20010;&#23545;&#35937;&#12290;
+      </li>
+<li>
+ Value-access will actually provide access to the referenced object rather + than the reference itself.<br> &#20540;&#35775;&#38382;&#25805;&#20316;&#25552;&#20379;&#23545;&#34987;&#24341;&#29992;&#30340;&#23545;&#35937;&#32780;&#19981;&#26159;&#24341;&#29992;&#26412;&#36523;&#30340;&#35775;&#38382;&#12290;
+      </li>
+</ul></div>
 </div>
-
-</div>
-
-</div>
-
-
-<p>本库允许模板参数 T 可以是引用类型:<code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>, 及其扩 展 <code class="computeroutput"><span class="identifier">T</span> - <span class="keyword">const</span><span class="special">&amp;</span></code>.</p>
-
-<p>不过,由于引用不是真正的对象,所以有一些限制,有些操作不可使用:</p>
-
-<ul>
-  <li>转换构造函数
-  </li>
-  <li>转换赋值
-  </li>
-  <li>就地构造
-  </li>
-  <li>就地赋值</li>
-  <li>通过指针的值访问</li>
-</ul>
-
-<p>而且,虽然&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> -在处理其包装的伪对象时与真正的值对象非常相似,但实际上它保存的是一个真正的 引用,所以可能发生以下容易混淆的情况: </p>
-
-<ul>
- <li>复制&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> 将 对引用进行复制,但所有被复制的引用都将引向同一个对象。
-  </li>
-  <li>值访问操作提供对被引用的对象而不是引用本身的访问。<br>
-  </li>
-</ul>
-</div>
-
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-
-  <tbody>
-
-    <tr>
-
-
-      <td align="left"></td>
-
-
-      <td align="right">
-
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-
-      </div>
-
-      </td>
-
-
-    </tr>
-
-
-  </tbody>
-</table>
-
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="examples.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/rebinding_semantics_for_assignment_of_optional_references.html Wed Mar 24 00:54:49 2010
@@ -1,155 +1,170 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Rebinding semantics for assignment of optional references</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="optional_references.html" title="Optional references">
-
- <link rel="next" href="in_place_factories.html" title="In-Place Factories">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="optional_references.html" title="Optional references Optional&#24341;&#29992;"> +<link rel="next" href="in_place_factories.html" title="In-Place Factories &#23601;&#22320;&#21019;&#24314;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="in_place_factories.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references"></a><a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">optional 引用赋值操作的重绑定语义</a>
-</h2>
-</div>
-</div>
-</div>
-
-<p>如果你对一个<span style="font-style: italic;">未初始化</span>的 &nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> -进行赋值,效果将是将它绑定(对于第一次赋值)到某个对象。显然,这里没有其它的 选择。
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references"></a><a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;"> + Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;</a>
+</h2></div></div></div>
+<p>
+ If you assign to an <span class="emphasis"><em>uninitialized </em></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + the effect is to bind (for the first time) to the object. Clearly, there is + no other choice.<br> &#22914;&#26524;&#20320;&#23545;&#19968;&#20010;<span class="emphasis"><em>&#26410;&#21021;&#22987;&#21270;&#30340;</em></span> + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + &#36827;&#34892;&#36171;&#20540;&#65292;&#25928;&#26524;&#23558;&#26159;&#23558;&#23427;&#32465;&#23450;(&#23545;&#20110;&#31532;&#19968;&#27425;&#36171;&#20540;)&#21040;&#26576;&#20010;&#23545;&#35937;&#12290;&#26174;&#28982;&#65292;&#36825;&#37324;&#27809;&#26377;&#20854;&#23427;&#30340;&#36873;&#25321;&#12290;
     </p>
-
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">rx</span> <span class="special">=</span> <span class="identifier">x</span> <span class="special">;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">ora</span> <span class="special">;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">orb</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">;</span> -<span class="identifier">ora</span> <span class="special">=</span> <span class="identifier">orb</span> <span class="special">;</span> <span class="comment">// 现在 'ora' 通过 'rx' 被绑定到 'x'<br></span><span class="special">*</span><span class="identifier">ora</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span> <span class="comment">// 通过 'ora' 修改 'x' 的值 <br></span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">x</span><span class="special">==</span><span class="number">2</span><span class="special">);</span> <br></pre>
-
-<p>如果你对一个C++裸引用进行赋值,赋值的操作将被前转至被引用的对象;结果是 被引用对象的值被改变而引用本身不会被重绑定。 +<span class="identifier">ora</span> <span class="special">=</span> <span class="identifier">orb</span> <span class="special">;</span> <span class="comment">// now 'ora' is bound to 'x' through 'rx' &#29616;&#22312;'ora'&#36890;&#36807;'rx'&#34987;&#32465;&#23450;&#21040;'x' +</span><span class="special">*</span><span class="identifier">ora</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span> <span class="comment">// Changes value of 'x' through 'ora' &#36890;&#36807;'ora'&#20462;&#25913;'x'&#30340;&#20540; +</span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">x</span><span class="special">==</span><span class="number">2</span><span class="special">);</span>
+</pre>
+<p>
+ If you assign to a bare C++ reference, the assignment is forwarded to the referenced + object; it's value changes but the reference is never rebound.<br> &#22914;&#26524;&#20320;&#23545;&#19968;&#20010;C++&#35064;&#24341;&#29992;&#36827;&#34892;&#36171;&#20540;&#65292;&#36171;&#20540;&#30340;&#25805;&#20316;&#23558;&#34987;&#21069;&#36716;&#33267;&#34987;&#24341;&#29992;&#30340;&#23545;&#35937;&#65307;&#32467;&#26524;&#26159;&#34987;&#24341;&#29992;&#23545;&#35937;&#30340;&#20540;&#34987;&#25913;&#21464;&#32780;&#24341;&#29992;&#26412;&#36523;&#19981;&#20250;&#34987;&#37325;&#32465;&#23450;&#12290;
     </p>
-
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span> <span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span> -<span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">rb</span> <span class="special">;</span> <span class="comment">// 修改 'a' 的值为 'b'<br></span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">a</span><span class="special">==</span><span class="identifier">b</span><span class="special">);</span> +<span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">rb</span> <span class="special">;</span> <span class="comment">// Changes the value of 'a' to 'b' &#20462;&#25913;'a'&#30340;&#20540;&#20026;'b' +</span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">a</span><span class="special">==</span><span class="identifier">b</span><span class="special">);</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">3</span> <span class="special">;</span> -<span class="identifier">assert</span><span class="special">(</span><span class="identifier">ra</span><span class="special">!=</span><span class="identifier">b</span><span class="special">);</span> <span class="comment">// 'ra' 不会重绑定到 'b'<br></span></pre>
-
-<p>现在,如果你对一个<span style="font-style: italic;">已初始化</span>的 &nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> -进行赋值,结果将是<span style="font-weight: bold;">重绑定</span>到新的对 象,而不是对引用物进行赋值。这和C++裸引用是不一样的。 +<span class="identifier">assert</span><span class="special">(</span><span class="identifier">ra</span><span class="special">!=</span><span class="identifier">b</span><span class="special">);</span> <span class="comment">// 'ra' is not rebound to 'b' 'ra'&#19981;&#20250;&#37325;&#32465;&#23450;&#21040;'b'
+</span></pre>
+<p>
+ Now, if you assign to an <span class="emphasis"><em>initialized </em></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code>, + the effect is to <span class="bold"><strong>rebind</strong></span> to the new object + instead of assigning the referee. This is unlike bare C++ references.<br> + &#29616;&#22312;&#65292;&#22914;&#26524;&#20320;&#23545;&#19968;&#20010;<span class="emphasis"><em>&#24050;&#21021;&#22987;&#21270;&#30340;</em></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + &#36827;&#34892;&#36171;&#20540;&#65292;&#32467;&#26524;&#23558;&#26159;<span class="bold"><strong>&#37325;&#32465;&#23450;</strong></span>&#21040;&#26032;&#30340;&#23545;&#35937;&#65292;&#32780;&#19981;&#26159;&#23545;&#24341;&#29992;&#29289;&#36827;&#34892;&#36171;&#20540;&#12290;&#36825;&#21644;C++&#35064;&#24341;&#29992;&#26159;&#19981;&#19968;&#26679;&#30340;&#12290;
     </p>
-
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span> <span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">ora</span><span class="special">(</span><span class="identifier">ra</span><span class="special">)</span> <span class="special">;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">orb</span><span class="special">(</span><span class="identifier">rb</span><span class="special">)</span> <span class="special">;</span> -<span class="identifier">ora</span> <span class="special">=</span> <span class="identifier">orb</span> <span class="special">;</span> <span class="comment">// 'ora' is rebound to 'b'<br></span><span class="special">*</span><span class="identifier">ora</span> <span class="special">=</span> <span class="number">3</span> <span class="special">;</span> <span class="comment">// Changes value of 'b' (not 'a')<br></span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">a</span><span class="special">==</span><span class="number">1</span><span class="special">);</span> <br><span class="identifier">assert</span><span class="special">(</span><span class="identifier">b</span><span class="special">==</span><span class="number">3</span><span class="special">);</span> <br></pre>
-
-<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references.rationale"></a>
-<h4>
-<a name="id2660242"></a>
- <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html#boost_optional.rebinding_semantics_for_assignment_of_optional_references.rationale">原 理</a> +<span class="identifier">ora</span> <span class="special">=</span> <span class="identifier">orb</span> <span class="special">;</span> <span class="comment">// 'ora' is rebound to 'b' 'ora'&#34987;&#37325;&#32465;&#23450;&#33267;'a' +</span><span class="special">*</span><span class="identifier">ora</span> <span class="special">=</span> <span class="number">3</span> <span class="special">;</span> <span class="comment">// Changes value of 'b' (not 'a') &#20462;&#25913;'b'(&#32780;&#19981;&#26159;'a')&#30340;&#20540; +</span><span class="identifier">assert</span><span class="special">(</span><span class="identifier">a</span><span class="special">==</span><span class="number">1</span><span class="special">);</span> +<span class="identifier">assert</span><span class="special">(</span><span class="identifier">b</span><span class="special">==</span><span class="number">3</span><span class="special">);</span>
+</pre>
+<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references._rationale_rationale_______"></a><h4>
+<a name="id4889521"></a>
+ <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html#boost_optional.rebinding_semantics_for_assignment_of_optional_references._rationale_rationale_______">:rationale
+      Rationale &#21407;&#29702;</a>
     </h4>
-
-<p>对<span style="font-style: italic;">已初始化</span>的&nbsp;<code class="computeroutput"><span class="identifier">optional</span></code> 引用 的赋值操作的重绑定语义提供了<span style="font-weight: bold;">对初始化状态的 一致性</span>,这是以违反C++裸引用语义为代价的。确实,<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>&nbsp;尽可能表现得和 <code class="computeroutput"><span class="identifier">U</span></code> 一样,不论它 是否已初始化;但是如果&nbsp;<code class="computeroutput"><span class="identifier">U</span></code> 是 <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>, 这样做 就会导致和左值初始化状态相关的不一致行为。<br>
-</p>
-<p>设想 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> - 将赋值操作前转至被引用的对象(修改被引用的对象而不是重绑定),考虑一下 以下代码:
+<p>
+ Rebinding semantics for the assignment of <span class="emphasis"><em>initialized </em></span> + <code class="computeroutput"><span class="identifier">optional</span></code> references has been + chosen to provide <span class="bold"><strong>consistency among initialization states</strong></span> + even at the expense of lack of consistency with the semantics of bare C++ references. + It is true that <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code> strives + to behave as much as possible as <code class="computeroutput"><span class="identifier">U</span></code> + does whenever it is initialized; but in the case when <code class="computeroutput"><span class="identifier">U</span></code> + is <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>, + doing so would result in inconsistent behavior w.r.t to the lvalue initialization + state.<br> &#23545;<span class="emphasis"><em>&#24050;&#21021;&#22987;&#21270;&#30340;</em></span> <code class="computeroutput"><span class="identifier">optional</span></code> + &#24341;&#29992;&#30340;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;&#25552;&#20379;&#20102;<span class="bold"><strong>&#23545;&#21021;&#22987;&#21270;&#29366;&#24577;&#30340;&#19968;&#33268;&#24615;</strong></span>&#65292;&#36825;&#26159;&#20197;&#36829;&#21453;C++&#35064;&#24341;&#29992;&#35821;&#20041;&#20026;&#20195;&#20215;&#30340;&#12290; + &#30830;&#23454;&#65292;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code> &#23613;&#21487;&#33021;&#34920;&#29616;&#24471;&#21644; + <code class="computeroutput"><span class="identifier">U</span></code> &#19968;&#26679;&#65292;&#19981;&#35770;&#23427;&#26159;&#21542;&#24050;&#21021;&#22987;&#21270;&#65307;&#20294;&#26159;&#22914;&#26524; + <code class="computeroutput"><span class="identifier">U</span></code> &#26159; <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>, &#36825;&#26679;&#20570;&#23601;&#20250;&#23548;&#33268;&#21644;&#24038;&#20540;&#21021;&#22987;&#21270;&#29366;&#24577;&#30456;&#20851;&#30340;&#19981;&#19968;&#33268;&#34892;&#20026;&#12290;
     </p>
-
+<p>
+ Imagine <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + forwarding assignment to the referenced object (thus changing the referenced + object value but not rebinding), and consider the following code:<br> &#35774;&#24819; + <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + &#23558;&#36171;&#20540;&#25805;&#20316;&#21069;&#36716;&#33267;&#34987;&#24341;&#29992;&#30340;&#23545;&#35937;(&#20462;&#25913;&#34987;&#24341;&#29992;&#30340;&#23545;&#35937;&#32780;&#19981;&#26159;&#37325;&#32465;&#23450;)&#65292;&#32771;&#34385;&#19968;&#19979;&#20197;&#19979;&#20195;&#30721;&#65306;
+    </p>
<pre class="programlisting"><span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">a</span> <span class="special">=</span> <span class="identifier">get</span><span class="special">();</span> <span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">rx</span> <span class="special">=</span> <span class="identifier">x</span> <span class="special">;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&amp;&gt;</span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">rx</span><span class="special">);</span> <span class="identifier">a</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span>
 </pre>
-
-<p>这个赋值操作会做什么?
+<p>
+ What does the assignment do?<br> &#36825;&#20010;&#36171;&#20540;&#25805;&#20316;&#20250;&#20570;&#20160;&#20040;&#65311;
     </p>
-
-<p>如果 <code class="computeroutput"><span class="identifier">a</span></code> 是<span style="font-style: italic;">未初 始化</span>的,那么答案非常清楚:它将被绑定到 <code class="computeroutput"><span class="identifier">x</span></code> (这样我们就 有了第二个到 <code class="computeroutput"><span class="identifier">x</span></code> 的引用)。但是如果 <code class="computeroutput"><span class="identifier">a</span></code> 已经<span style="font-style: italic;">初始化</span>了呢?那么这个赋值操作可能会修改被 引用对象(无论它是什么)的值,但是这样做就会和在未初始化情形下的行为不一致。 </p> -<p>如果 <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> - 的赋值只是象&nbsp;<code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code> 那样 做,你就永远不能在没有显式处理过原先的已初始化状态的时候使用 Optional 的赋 值,除非你的代码能够判断在这个赋值之后,<code class="computeroutput"><span class="identifier">a</span></code> 是 <code class="computeroutput"><span class="identifier">b</span></code>
-      的别名抑或不是。</p>
-<p>即,你不得不为了一致性而进行分别处理。</p>
-
-<p>如果将引用绑定到另一个对象对于你的代码来说是错误的,那么在第一次的时候通 过赋值操作来绑定而不是初始化很可能也是错误的。在这种情况下,赋值到一个未初始 化的&nbsp;<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> 应 该被禁止。很可能这种情况下前提条件是,左值必须是已初始化的。如果重绑定是错误 的而第一次的绑定(通过赋值操作)不是,则你可以用一个辨别操作来避免重绑定语 义:<br>
-</p>
+<p>
+ If <code class="computeroutput"><span class="identifier">a</span></code> is <span class="emphasis"><em>uninitialized</em></span>, + the answer is clear: it binds to <code class="computeroutput"><span class="identifier">x</span></code> + (we now have another reference to <code class="computeroutput"><span class="identifier">x</span></code>). + But what if <code class="computeroutput"><span class="identifier">a</span></code> is already <span class="emphasis"><em>initialized</em></span>? + it would change the value of the referenced object (whatever that is); which + is inconsistent with the other possible case.<br> &#22914;&#26524; <code class="computeroutput"><span class="identifier">a</span></code> + &#26159;<span class="emphasis"><em>&#26410;&#21021;&#22987;&#21270;&#30340;</em></span>&#65292;&#37027;&#20040;&#31572;&#26696;&#38750;&#24120;&#28165;&#26970;&#65306;&#23427;&#23558;&#34987;&#32465;&#23450;&#21040; + <code class="computeroutput"><span class="identifier">x</span></code> (&#36825;&#26679;&#25105;&#20204;&#23601;&#26377;&#20102;&#31532;&#20108;&#20010;&#21040; + <code class="computeroutput"><span class="identifier">x</span></code> &#30340;&#24341;&#29992;)&#12290; &#20294;&#26159;&#22914;&#26524; + <code class="computeroutput"><span class="identifier">a</span></code> &#24050;&#32463;<span class="emphasis"><em>&#21021;&#22987;&#21270;</em></span>&#20102;&#21602;&#65311;&#37027;&#20040;&#36825;&#20010;&#36171;&#20540;&#25805;&#20316;&#21487;&#33021;&#20250;&#20462;&#25913;&#34987;&#24341;&#29992;&#23545;&#35937;(&#26080;&#35770;&#23427;&#26159;&#20160;&#20040;)&#30340;&#20540;&#65292;&#20294;&#26159;&#36825;&#26679;&#20570;&#23601;&#20250;&#21644;&#22312;&#26410;&#21021;&#22987;&#21270;&#24773;&#24418;&#19979;&#30340;&#34892;&#20026;&#19981;&#19968;&#33268;&#12290;
+    </p>
+<p>
+ If <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + would assign just like <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code> + does, you would never be able to use Optional's assignment without explicitly + handling the previous initialization state unless your code is capable of functioning + whether after the assignment, <code class="computeroutput"><span class="identifier">a</span></code> + aliases the same object as <code class="computeroutput"><span class="identifier">b</span></code> + or not.<br> &#22914;&#26524; <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + &#30340;&#36171;&#20540;&#21482;&#26159;&#35937; <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code> + &#37027;&#26679;&#20570;&#65292;&#20320;&#23601;&#27704;&#36828;&#19981;&#33021;&#22312;&#27809;&#26377;&#26174;&#24335;&#22788;&#29702;&#36807;&#21407;&#20808;&#30340;&#24050;&#21021;&#22987;&#21270;&#29366;&#24577;&#30340;&#26102;&#20505;&#20351;&#29992; + Optional &#30340;&#36171;&#20540;&#65292; &#38500;&#38750;&#20320;&#30340;&#20195;&#30721;&#33021;&#22815;&#21028;&#26029;&#22312;&#36825;&#20010;&#36171;&#20540;&#20043;&#21518;&#65292;<code class="computeroutput"><span class="identifier">a</span></code> &#26159; <code class="computeroutput"><span class="identifier">b</span></code>
+      &#30340;&#21035;&#21517;&#25233;&#25110;&#19981;&#26159;&#12290;
+    </p>
+<p>
+ That is, you would have to discriminate in order to be consistency.<br> &#21363;&#65292;&#20320;&#19981;&#24471;&#19981;&#20026;&#20102;&#19968;&#33268;&#24615;&#32780;&#36827;&#34892;&#20998;&#21035;&#22788;&#29702;&#12290;
+    </p>
+<p>
+ If in your code rebinding to another object is not an option, then is very + likely that binding for the fist time isn't either. In such case, assignment + to an <span class="emphasis"><em>uninitialized </em></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + shall be prohibited. It is quite possible that in such scenario the precondition + that the lvalue must be already initialized exist. If it doesn't, then binding + for the first time is OK while rebinding is not which is IMO very unlikely. + In such scenario, you can assign the value itself directly, as in:<br> &#22914;&#26524;&#23558;&#24341;&#29992;&#32465;&#23450;&#21040;&#21478;&#19968;&#20010;&#23545;&#35937;&#23545;&#20110;&#20320;&#30340;&#20195;&#30721;&#26469;&#35828;&#26159;&#38169;&#35823;&#30340;&#65292;&#37027;&#20040;&#22312;&#31532;&#19968;&#27425;&#30340;&#26102;&#20505;&#36890;&#36807;&#36171;&#20540;&#25805;&#20316;&#26469;&#32465;&#23450;&#32780;&#19981;&#26159;&#21021;&#22987;&#21270;&#24456;&#21487;&#33021;&#20063;&#26159;&#38169;&#35823;&#30340;&#12290; + &#22312;&#36825;&#31181;&#24773;&#20917;&#19979;&#65292;&#36171;&#20540;&#21040;&#19968;&#20010;<span class="emphasis"><em>&#26410;&#21021;&#22987;&#21270;&#30340;</em></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> + &#24212;&#35813;&#34987;&#31105;&#27490;&#12290;&#24456;&#21487;&#33021;&#36825;&#31181;&#24773;&#20917;&#19979;&#21069;&#25552;&#26465;&#20214;&#26159;&#65292;&#24038;&#20540;&#24517;&#39035;&#26159;&#24050;&#21021;&#22987;&#21270;&#30340;&#12290; + &#33509;&#38750;&#22914;&#27492;&#65292;&#21017;&#31532;&#19968;&#27425;&#30340;&#32465;&#23450;&#26159;&#23545;&#30340;&#65292;&#32780;&#37325;&#32465;&#23450;&#26159;&#38169;&#35823;&#30340;&#65292;&#36825;&#36890;&#24120;&#19981;&#22823;&#21487;&#33021;&#12290;&#36825;&#31181;&#24773;&#20917;&#19979;&#20320;&#21487;&#20197;&#30452;&#25509;&#21521;&#23427;&#36171;&#20540;&#65292;&#22914;&#65306;
+    </p>
<pre class="programlisting"><span class="identifier">assert</span><span class="special">(!!</span><span class="identifier">opt</span><span class="special">);</span> <span class="special">*</span><span class="identifier">opt</span><span class="special">=</span><span class="identifier">value</span><span class="special">;</span>
 </pre>
-
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="in_place_factories.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/synopsis.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/synopsis.html Wed Mar 24 00:54:49 2010
@@ -1,62 +1,31 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Synopsis</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-  <link rel="prev" href="development.html" title="Development">
-
- <link rel="next" href="detailed_semantics.html" title="Detailed Semantics">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Synopsis &#25688;&#35201;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="development.html" title="Development &#21457;&#23637;"> +<link rel="next" href="detailed_semantics.html" title="Detailed Semantics &#35814;&#32454;&#35821;&#20041;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="development.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="detailed_semantics.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.synopsis"></a><a class="link" href="synopsis.html" title="Synopsis">概要</a>
-</h2>
-</div>
-</div>
-</div>
-
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.synopsis"></a><a class="link" href="synopsis.html" title="Synopsis &#25688;&#35201;"> Synopsis &#25688;&#35201;</a>
+</h2></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
@@ -64,14 +33,20 @@
 <span class="special">{</span>
     <span class="keyword">public</span> <span class="special">:</span>

- <span class="comment">// (如果 T 是引用类型,则以引用传递的参数和结果变 为以值传递)<br></span> + <span class="comment">// (If T is of reference type, the parameters and results by reference are by value) +</span> <span class="comment">// (&#22914;&#26524; T &#26159;&#24341;&#29992;&#31867;&#22411;&#65292;&#21017;&#20197;&#24341;&#29992;&#20256;&#36882;&#30340;&#21442;&#25968;&#21644;&#32467;&#26524;&#21464;&#20026;&#20197;&#20540;&#20256;&#36882;)
+</span>
<span class="identifier">optional</span> <span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_none_t"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

- <span class="comment">// [1.34版本中新增]<br></span> <span class="identifier">optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <br><br> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+    <span class="comment">// [new in 1.34]
+</span> <span class="comment">// [1.34&#29256;&#26412;&#20013;&#26032;&#22686;] +</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+
+ <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_other_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

@@ -79,16 +54,26 @@

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">&gt;</span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_factory"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

- <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="special">;</span> <br><br> <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> + <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="special">;</span>
+
+ <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

<span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_other_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

- <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <br><br> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <br><br> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> + <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span>
+
+ <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">&gt;</span> <span class="identifier">optional</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span>
+
+ <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">get</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

- <span class="comment">// [1.34版本中新增]<br></span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get_value_or</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="keyword">default</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <br><br> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">-&gt;()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+    <span class="comment">// [new in 1.34]
+</span> <span class="comment">// [1.34&#29256;&#26412;&#20013;&#26032;&#22686;] +</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get_value_or</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="keyword">default</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+
+ <span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">-&gt;()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">-&gt;()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
@@ -101,12 +86,17 @@

<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_not"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

-    <span class="comment">// 被反对的方法<br></span>
- <span class="comment">// (被反对的)<br></span> <span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_reset"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
-
- <span class="comment">// (</span><span class="comment">被反对的 </span><span class="comment">)<br></span> <span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_reset_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
-
- <span class="comment">// (</span><span class="comment">被反对的 </span><span class="comment">)<br></span> <span class="keyword">bool</span> <span class="identifier">is_initialized</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_is_initialized"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+    <span class="comment">// deprecated methods
+</span> <span class="comment">// &#20572;&#29992;&#30340;&#26041;&#27861;
+</span>
+    <span class="comment">// (deprecated)
+</span> <span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_reset"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+
+    <span class="comment">// (deprecated)
+</span> <span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_reset_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+
+    <span class="comment">// (deprecated)
+</span> <span class="keyword">bool</span> <span class="identifier">is_initialized</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_is_initialized"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

 <span class="special">};</span>

@@ -122,11 +112,19 @@

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">&gt;=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_operator_compare_greater_or_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

-<span class="comment">// [</span><span class="comment">1.34版本中新增 </span><span class="comment">]<br></span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_make_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
-
-<span class="comment">// [</span><span class="comment">1.34版本中新增 </span><span class="comment">]<br></span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_make_optional_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
-
-<span class="comment">// [</span><span class="comment">1.34版本中新增 </span><span class="comment">]<br></span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">opt</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="keyword">default</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <br><br><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+<span class="comment">// [new in 1.34]
+</span><span class="comment">// [1.34&#29256;&#26412;&#20013;&#26032;&#22686;] +</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_make_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+
+<span class="comment">// [new in 1.34]
+</span><span class="comment">// [1.34&#29256;&#26412;&#20013;&#26032;&#22686;] +</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_make_optional_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+
+<span class="comment">// [new in 1.34]
+</span><span class="comment">// [1.34&#29256;&#26412;&#20013;&#26032;&#22686;] +</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">opt</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="keyword">default</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
+
+<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&amp;</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

@@ -140,34 +138,20 @@

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">inline</span> <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;&amp;</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_swap_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

-<span class="special">}</span> <span class="comment">// namespace boost<br></span></pre>
-
+<span class="special">}</span> <span class="comment">// namespace boost
+</span></pre>
 </div>
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-
-      <td align="left"></td>
-
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="development.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="detailed_semantics.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/boost_optional/type_requirements.html Thu Sep 4 19:32:19 2008 +++ /trunk/libs/optional/doc/html/boost_optional/type_requirements.html Wed Mar 24 00:54:49 2010
@@ -1,88 +1,56 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-  <title>Type requirements</title>
-  <link rel="stylesheet" href="../boostbook.css" type="text/css">
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
- <link rel="start" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="up" href="../index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
- <link rel="prev" href="exception_safety_guarantees.html" title="Exception Safety Guarantees">
-
- <link rel="next" href="implementation_notes.html" title="Implementation Notes">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Type requirements &#31867;&#22411;&#35201;&#27714;</title>
+<link rel="stylesheet" href="../boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="prev" href="exception_safety_guarantees.html" title="Exception Safety Guarantees &#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;"> +<link rel="next" href="implementation_notes.html" title="Implementation Notes &#23454;&#29616;&#35828;&#26126;">
 </head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-<table cellpadding="2" width="100%">
-  <tbody>
-    <tr>
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../../boost.png" height="86" width="277"></td>
-
-      <td align="center"><a href="../../../../../index.html">Home</a></td>
-
- <td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
- <td align="center"><a href="../../../../../more/index.htm">More</a></td>
-
-    </tr>
-  </tbody>
-</table>
-
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="implementation_notes.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="boost_optional.type_requirements"></a><a class="link" href="type_requirements.html" title="Type requirements">类型要求</a>
-</h2>
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_optional.type_requirements"></a><a class="link" href="type_requirements.html" title="Type requirements &#31867;&#22411;&#35201;&#27714;"> Type requirements &#31867;&#22411;&#35201;&#27714;</a>
+</h2></div></div></div>
+<p>
+ In general, <code class="computeroutput"><span class="identifier">T</span></code> must be <a href="../../../../utility/CopyConstructible.html" target="_top">Copy Constructible</a> and + have a no-throw destructor. The copy-constructible requirement is not needed + if <span class="bold"><strong>InPlaceFactories</strong></span> are used.<br> &#36890;&#24120;&#65292;<code class="computeroutput"><span class="identifier">T</span></code> &#24517;&#39035;&#26159; <a href="../../../../utility/CopyConstructible.html" target="_top">Copy + Constructible</a> &#19988;&#20855;&#26377;&#26080;&#25243;&#20986;&#30340;&#26512;&#26500;&#20989;&#25968;&#12290;&#22914;&#26524;&#20351;&#29992; <span class="bold"><strong>InPlaceFactories</strong></span>&#65292;&#21017;&#26080;&#39035;&#35201;&#27714;&#21487;&#22797;&#21046;&#26500;&#36896;&#12290;
+    </p>
+<p>
+ <code class="computeroutput"><span class="identifier">T</span></code> <span class="underline">is + not</span> required to be <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"; target="_top">Default + Constructible</a>.<br> <code class="computeroutput"><span class="identifier">T</span></code> + <span class="underline">&#24182;&#19981;</span>&#35201;&#27714;&#26159; <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html"; target="_top">Default
+      Constructible</a>&#12290;
+    </p>
 </div>
-</div>
-</div>
-
-<p>通常,<code class="computeroutput"><span class="identifier">T</span></code> 必须是 <a href="../../../../utility/CopyConstructible.html">可复制构造的</a> -且具有无抛出的析构函数。如果使用 <span style="font-weight: bold;">InPlaceFactories</span>,则无须要求可复制构造。</p> -<p><code class="computeroutput"><span class="identifier">T</span></code>&nbsp;<span style="text-decoration: underline;">并不</span>要求是 <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html";>可缺省构造的 </a>。</p>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-  <tbody>
-    <tr>
-      <td align="left"></td>
-      <td align="right">
- <div class="copyright-footer">Copyright &copy; 2003 -2007 Fernando Luis Cacciola Carballal
-      <p>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal<p> Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-      </div>
-      </td>
-
-    </tr>
-  </tbody>
-</table>
-
+</div></td>
+</tr></table>
 <hr>
 <div class="spirit-nav">
<a accesskey="p" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="implementation_notes.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
 </div>
-
 </body>
 </html>
=======================================
--- /trunk/libs/optional/doc/html/index.html    Tue Nov 11 23:43:49 2008
+++ /trunk/libs/optional/doc/html/index.html    Wed Mar 24 00:54:49 2010
@@ -1,357 +1,196 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html><head>
-
-
-
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
-
-
-
-
-
- <title>Chapter&nbsp;1.&nbsp;Boost.Optional</title><link rel="stylesheet" href="boostbook.css" type="text/css">
-
-
-
-  <meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
-
-
-
- <link rel="start" href="index.html" title="Chapter&nbsp;1.&nbsp;Boost.Optional">
-
-
-
- <link rel="next" href="boost_optional/development.html" title="Development"></head>
-
-<body alink="#0000ff" bgcolor="white" link="#0000ff" text="black" vlink="#840084">
-
-
-<table cellpadding="2" width="100%">
-
-  <tbody>
-
-    <tr>
-
-
- <td valign="top"><img alt="Boost C++ Libraries" src="../../../../boost.png" height="86" width="277"></td>
-
-
-      <td align="center"><a href="../../../../index.html">Home</a></td>
-
-
- <td align="center"><a href="../../../libraries.htm">Libraries</a></td>
-
-
- <td align="center"><a href="http://www.boost.org/people/people.htm";>People</a></td>
-
-
- <td align="center"><a href="http://www.boost.org/more/faq.htm";>FAQ</a></td>
-
-
-      <td align="center"><a href="../../../../more/index.htm">More</a></td>
-
-
-    </tr>
-
-
-  </tbody>
-</table>
-
-
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Chapter&#160;1.&#160;Boost.Optional</title>
+<link rel="stylesheet" href="boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
+<link rel="start" href="index.html" title="Chapter&#160;1.&#160;Boost.Optional"> +<link rel="next" href="boost_optional/development.html" title="Development &#21457;&#23637;">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html";>People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html";>FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
 <hr>
<div class="spirit-nav"><a accesskey="n" href="boost_optional/development.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
-
-
 <div class="chapter" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title">
-<a name="optional"></a>Chapter&nbsp;1.&nbsp;Boost.Optional</h2>
-
-</div>
-
-
-<div>
-<div class="author">
-<h3 class="author">
+<div class="titlepage"><div>
+<div><h2 class="title">
+<a name="optional"></a>Chapter&#160;1.&#160;Boost.Optional</h2></div>
+<div><div class="author"><h3 class="author">
<span class="firstname">Fernando Luis</span> <span class="surname">Cacciola Carballal</span>
-</h3>
-
-</div>
-
-</div>
-
-
-<div>
-<p class="copyright">Copyright (c) 2003 -2007 Fernando Luis Cacciola Carballal</p>
-
-</div>
-
-
-<div>
-<div class="legalnotice">
-<a name="id2625900"></a>
-<p>
+</h3></div></div>
+<div><p class="copyright">Copyright &#169; 2003 -2007 Fernando Luis Cacciola Carballal</p></div>
+<div><div class="legalnotice">
+<a name="id4850104"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying 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>)
       </p>
-
-
-</div>
-
-</div>
-
-
-</div>
-
-</div>
-
-
+</div></div>
+</div></div>
 <div class="toc">
-<p><b>目录</b></p>
-
-
+<p><b>Table of Contents</b></p>
 <dl>
-
-
- <dt><span class="section"><a href="index.html#optional.motivation">动机 </a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/development.html">发展 </a></span></dt>
-
-
-  <dd>
-
-    <dl>
-
-
- <dt><span class="section"><a href="boost_optional/development.html#boost_optional.development.the_models">模 型</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/development.html#boost_optional.development.the_semantics">语 义</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/development.html#boost_optional.development.the_interface">接 口</a></span></dt>
-
-
-
-    </dl>
-
-  </dd>
-
-
- <dt><span class="section"><a href="boost_optional/synopsis.html">概要 </a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/detailed_semantics.html">详细语义</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/examples.html">例子 </a></span></dt>
-
-
-  <dd>
-
-    <dl>
-
-
- <dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.optional_return_values">可 选返回值</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.optional_local_variables">可 选局部变量</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.optional_data_members">可 选数据成员</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction">避 免不必要的昂贵的缺省构造</a></span></dt>
-
-
-
-    </dl>
-
-  </dd>
-
-
- <dt><span class="section"><a href="boost_optional/optional_references.html">Optional 引用</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/rebinding_semantics_for_assignment_of_optional_references.html">optional 引用的赋值操作的重绑定语义</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/in_place_factories.html">就地创建</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/a_note_about_optional_bool_.html">关于 &nbsp;</a></span><a href="boost_optional/a_note_about_optional_bool_.html"><span class="section"></span></a><a href="boost_optional/a_note_about_optional_bool_.html">optional&lt;bool&gt;</a><span class="section"><a href="boost_optional/a_note_about_optional_bool_.html"> 的说明</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/exception_safety_guarantees.html">异常安全性保证 </a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/type_requirements.html">类型要求</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/implementation_notes.html">实现说明</a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/dependencies_and_portability.html">依赖性和可移植性 </a></span></dt>
-
-
- <dt><span class="section"><a href="boost_optional/acknowledgments.html">鸣谢</a></span></dt>
-
-
+<dt><span class="section"><a href="index.html#optional.motivation"> Motivation &#21160;&#26426;</a></span></dt> +<dt><span class="section"><a href="boost_optional/development.html"> Development &#21457;&#23637;</a></span></dt>
+<dd><dl>
+<dt><span class="section"><a href="boost_optional/development.html#boost_optional.development.the_models"> The models &#27169;&#22411;</a></span></dt> +<dt><span class="section"><a href="boost_optional/development.html#boost_optional.development.the_semantics"> The semantics
+      &#35821;&#20041;</a></span></dt>
+<dt><span class="section"><a href="boost_optional/development.html#boost_optional.development.the_interface"> The Interface
+      &#25509;&#21475;</a></span></dt>
+</dl></dd>
+<dt><span class="section"><a href="boost_optional/synopsis.html"> Synopsis &#25688;&#35201;</a></span></dt> +<dt><span class="section"><a href="boost_optional/detailed_semantics.html"> Detailed Semantics
+    &#35814;&#32454;&#35821;&#20041;</a></span></dt>
+<dt><span class="section"><a href="boost_optional/examples.html"> Examples &#20363;&#23376;</a></span></dt>
+<dd><dl>
+<dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.optional_return_values"> Optional
+      return values Optional&#36820;&#22238;&#20540;</a></span></dt>
+<dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.optional_local_variables"> Optional + local variables Optional&#23616;&#37096;&#21464;&#37327;</a></span></dt> +<dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.optional_data_members"> Optional
+      data members Optional&#25968;&#25454;&#25104;&#21592;</a></span></dt>
+<dt><span class="section"><a href="boost_optional/examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction"> + Bypassing expensive unnecessary default construction &#36991;&#20813;&#19981;&#24517;&#35201;&#30340;&#26114;&#36149;&#30340;&#32570;&#30465;&#26500;&#36896;</a></span></dt>
+</dl></dd>
+<dt><span class="section"><a href="boost_optional/optional_references.html"> Optional references
+    Optional&#24341;&#29992;</a></span></dt>
+<dt><span class="section"><a href="boost_optional/rebinding_semantics_for_assignment_of_optional_references.html"> + Rebinding semantics for assignment of optional references optional&#24341;&#29992;&#36171;&#20540;&#25805;&#20316;&#30340;&#37325;&#32465;&#23450;&#35821;&#20041;</a></span></dt> +<dt><span class="section"><a href="boost_optional/in_place_factories.html"> In-Place Factories
+    &#23601;&#22320;&#21019;&#24314;</a></span></dt>
+<dt><span class="section"><a href="boost_optional/a_note_about_optional_bool_.html"> A note about + optional&lt;bool&gt; &#20851;&#20110;optional&lt;bool&gt;&#30340;&#35828;&#26126;</a></span></dt> +<dt><span class="section"><a href="boost_optional/exception_safety_guarantees.html"> Exception + Safety Guarantees &#24322;&#24120;&#23433;&#20840;&#24615;&#20445;&#35777;</a></span></dt> +<dt><span class="section"><a href="boost_optional/type_requirements.html"> Type requirements &#31867;&#22411;&#35201;&#27714;</a></span></dt> +<dt><span class="section"><a href="boost_optional/implementation_notes.html"> Implementation Notes
+    &#23454;&#29616;&#35828;&#26126;</a></span></dt>
+<dt><span class="section"><a href="boost_optional/dependencies_and_portability.html"> Dependencies + and Portability &#20381;&#36182;&#24615;&#21644;&#21487;&#31227;&#26893;&#24615;</a></span></dt> +<dt><span class="section"><a href="boost_optional/acknowledgments.html"> Acknowledgments &#40483;&#35874;</a></span></dt>
 </dl>
-
-
 </div>
-
-
 <div class="section" lang="en">
-<div class="titlepage">
-<div>
-<div>
-<h2 class="title" style="clear: both;">
-<a name="optional.motivation"></a><a class="link" href="index.html#optional.motivation" title="Motivation">动机</a>
-</h2>
-
-</div>
-
-</div>
-
-</div>
-
-
-<p>请看一下以下几个返回一个值的函数,它们也可能没有值可以返回:
-
-</p>
-
-<div class="itemizedlist">
-<ul type="disc">
-
-  <li>
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="optional.motivation"></a><a class="link" href="index.html#optional.motivation" title="Motivation &#21160;&#26426;"> Motivation &#21160;&#26426;</a>
+</h2></div></div></div>
+<p>
+ Consider these functions which should return a value but which might not have + a value to return:<br> &#35831;&#30475;&#19968;&#19979;&#20197;&#19979;&#20960;&#20010;&#36820;&#22238;&#19968;&#20010;&#20540;&#30340;&#20989;&#25968;&#65292;&#23427;&#20204;&#20063;&#21487;&#33021;&#27809;&#26377;&#20540;&#21487;&#20197;&#36820;&#22238;&#65306;
+    </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
(A) <code class="computeroutput"><span class="keyword">double</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">n</span>
         <span class="special">);</span></code>
-  </li>
-
-  <li>
+</li>
+<li>
(B) <code class="computeroutput"><span class="keyword">char</span> <span class="identifier">get_async_input</span><span class="special">();</span></code>
-  </li>
-
-  <li>
- (C) <code class="computeroutput"><span class="identifier">point</span> <span class="identifier">polygon</span><span class="special">::</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span></code><br>
-
-  </li>
-
-</ul>
-
-</div>
-
-<p>通常有几种不同的方法来处理无值可以返回的情形。</p>
-
-
-<p>最典型的方法是将有效的返回值视为后续条件,则如果函数不能计算出要返回的 值,那么它要么具有未定义行为(也可以在调试的构建中使用断言),要么使 -用运行期检查并在违反后续条件时抛出一个异常。对于函数(A)这是一个合理的选 择,因为无法得到正确的返回值是直接由无效的参数(超出参数域)所引起的,
-所以要求调用者只能提供有效域内的参数是适合的。</p>
-
-
-<p>但是对于函数(B),由于它本身的异步性,不应该仅仅因为不能找到可返回的值就 认为是失败;所以将这种情况视为错误或抛出异常都是不正确的。该函数必须返回,并 且一定要通知调用者它没有返回一个有意义的值的。</p>
-
-
-<p>类似的情形也发生在函数(C)上:询问一个空的多边形并返回一个内部点在概念上 是错误的,但是在多数应用程序中,由于性能的原因,将它视为一个错误 -是不切实际的(因为在调用之前检测一个多边形是否为空可能代价很高),要么返回任 意一个点(通常是无限远),要么以高效的方法通知调用者没有这样的点。</p>
-
-
-<p>有多种机制来让函数通告返回值是无效的。其中最常用的一种机制没有或只有很小 的开销,就是用一个保留的特殊值来通告。这种特殊值的一个典型例子包括 <code class="computeroutput"><span class="identifier">EOF</span></code>, <code class="computeroutput"><span class="identifier">string</span><span class="special">::</span><span class="identifier">npos</span></code>, 位于无 限远的点,等等...</p>
-
-
-<p>如果存在这样的值,即返回类型可以持有所有有意义的值再<span style="font-style: italic;">加上</span>这个<span style="font-style: italic;">信号</span>值,那么这种机制就非常适合。不幸的是,有些情形下不存在这 样的值。这时,通常可用的方法是,要么使用一个更宽的类型,如用 -'int' 代替 'char'; 或者使用复合类型,如 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span></code>. </p>
-
-
-<p>返回一个 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span></code>, -要在结果之后添加一个布尔标志,用于表示该结果是否有效,该方法的好处是,无论 函数要返回什么类型,都可以用作 pair -的第一个元素,这可以成为一种通用的惯用法。例如,前例中的后两个函数可以具有 以下接口:<br>
-
-</p>
-
+</li>
+<li>
+ (C) <code class="computeroutput"><span class="identifier">point</span> <span class="identifier">polygon</span><span class="special">::</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span></code>
+</li>
+</ul></div>
+<p>
+ There are different approaches to the issue of not having a value to return.<br> + &#36890;&#24120;&#26377;&#20960;&#31181;&#19981;&#21516;&#30340;&#26041;&#27861;&#26469;&#22788;&#29702;&#26080;&#20540;&#21487;&#20197;&#36820;&#22238;&#30340;&#24773;&#24418;&#12290;
+    </p>
+<p>
+ A typical approach is to consider the existence of a valid return value as + a postcondition, so that if the function cannot compute the value to return, + it has either undefined behavior (and can use assert in a debug build) or uses + a runtime check and throws an exception if the postcondition is violated. This + is a reasonable choice for example, for function (A), because the lack of a + proper return value is directly related to an invalid parameter (out of domain + argument), so it is appropriate to require the callee to supply only parameters + in a valid domain for execution to continue normally.<br> &#26368;&#20856;&#22411;&#30340;&#26041;&#27861;&#26159;&#23558;&#26377;&#25928;&#30340;&#36820;&#22238;&#20540;&#35270;&#20026;&#21518;&#32493;&#26465;&#20214;&#65292;&#21017;&#22914;&#26524;&#20989;&#25968;&#19981;&#33021;&#35745;&#31639;&#20986;&#35201;&#36820;&#22238;&#30340;&#20540;&#65292;&#37027;&#20040;&#23427;&#35201;&#20040;&#20855;&#26377;&#26410;&#23450;&#20041;&#34892;&#20026; + (&#20063;&#21487;&#20197;&#22312;&#35843;&#35797;&#30340;&#26500;&#24314;&#20013;&#20351;&#29992;&#26029;&#35328;)&#65292;&#35201;&#20040;&#20351;&#29992;&#36816;&#34892;&#26399;&#26816;&#26597;&#24182;&#22312;&#36829;&#21453;&#21518;&#32493;&#26465;&#20214;&#26102;&#25243;&#20986;&#19968;&#20010;&#24322;&#24120;&#12290; + &#23545;&#20110;&#20989;&#25968;(A)&#36825;&#26159;&#19968;&#20010;&#21512;&#29702;&#30340;&#36873;&#25321;&#65292;&#22240;&#20026;&#26080;&#27861;&#24471;&#21040;&#27491;&#30830;&#30340;&#36820;&#22238;&#20540;&#26159;&#30452;&#25509;&#30001;&#26080;&#25928;&#30340;&#21442;&#25968;(&#36229;&#20986;&#21442;&#25968;&#22495;)&#25152;&#24341;&#36215;&#30340;&#65292; + &#25152;&#20197;&#35201;&#27714;&#35843;&#29992;&#32773;&#21482;&#33021;&#25552;&#20379;&#26377;&#25928;&#22495;&#20869;&#30340;&#21442;&#25968;&#26159;&#36866;&#21512;&#30340;&#12290;
+    </p>
+<p>
+ However, function (B), because of its asynchronous nature, does not fail just + because it can't find a value to return; so it is incorrect to consider such + a situation an error and assert or throw an exception. This function must return, + and somehow, must tell the callee that it is not returning a meaningful value.<br> + &#20294;&#26159;&#23545;&#20110;&#20989;&#25968;(B)&#65292;&#30001;&#20110;&#23427;&#26412;&#36523;&#30340;&#24322;&#27493;&#24615;&#65292;&#19981;&#24212;&#35813;&#20165;&#20165;&#22240;&#20026;&#19981;&#33021;&#25214;&#21040;&#21487;&#36820;&#22238;&#30340;&#20540;&#23601;&#35748;&#20026;&#26159;&#22833;&#36133;&#65307; + &#25152;&#20197;&#23558;&#36825;&#31181;&#24773;&#20917;&#35270;&#20026;&#38169;&#35823;&#25110;&#25243;&#20986;&#24322;&#24120;&#37117;&#26159;&#19981;&#27491;&#30830;&#30340;&#12290;&#35813;&#20989;&#25968;&#24517;&#39035;&#36820;&#22238;&#65292;&#24182;&#19988;&#19968;&#23450;&#35201;&#36890;&#30693;&#35843;&#29992;&#32773;&#23427;&#27809;&#26377;&#36820;&#22238;&#19968;&#20010;&#26377;&#24847;&#20041;&#30340;&#20540;&#30340;&#12290;
+    </p>
+<p>
+ A similar situation occurs with function (C): it is conceptually an error to + ask a <span class="emphasis"><em>null-area</em></span> polygon to return a point inside itself, + but in many applications, it is just impractical for performance reasons to + treat this as an error (because detecting that the polygon has no area might + be too expensive to be required to be tested previously), and either an arbitrary + point (typically at infinity) is returned, or some efficient way to tell the + callee that there is no such point is used.<br> &#31867;&#20284;&#30340;&#24773;&#24418;&#20063;&#21457;&#29983;&#22312;&#20989;&#25968;(C)&#19978;&#65306;&#35810;&#38382;&#19968;&#20010;&#31354;&#30340;&#22810;&#36793;&#24418;&#24182;&#36820;&#22238;&#19968;&#20010;&#20869;&#37096;&#28857;&#22312;&#27010;&#24565;&#19978;&#26159;&#38169;&#35823;&#30340;&#65292;&#20294;&#26159;&#22312;&#22810;&#25968;&#24212;&#29992;&#31243;&#24207;&#20013;&#65292; + &#30001;&#20110;&#24615;&#33021;&#30340;&#21407;&#22240;&#65292;&#23558;&#23427;&#35270;&#20026;&#19968;&#20010;&#38169;&#35823;&#26159;&#19981;&#20999;&#23454;&#38469;&#30340;(&#22240;&#20026;&#22312;&#35843;&#29992;&#20043;&#21069;&#26816;&#27979;&#19968;&#20010;&#22810;&#36793;&#24418;&#26159;&#21542;&#20026;&#31354;&#21487;&#33021;&#20195;&#20215;&#24456;&#39640;)&#65292; + &#35201;&#20040;&#36820;&#22238;&#20219;&#24847;&#19968;&#20010;&#28857;(&#36890;&#24120;&#26159;&#26080;&#38480;&#36828;)&#65292;&#35201;&#20040;&#20197;&#39640;&#25928;&#30340;&#26041;&#27861;&#36890;&#30693;&#35843;&#29992;&#32773;&#27809;&#26377;&#36825;&#26679;&#30340;&#28857;&#12290;
+    </p>
+<p>
+ There are various mechanisms to let functions communicate that the returned + value is not valid. One such mechanism, which is quite common since it has + zero or negligible overhead, is to use a special value which is reserved to + communicate this. Classical examples of such special values are <code class="computeroutput"><span class="identifier">EOF</span></code>, <code class="computeroutput"><span class="identifier">string</span><span class="special">::</span><span class="identifier">npos</span></code>, points + at infinity, etc...<br> &#26377;&#22810;&#31181;&#26426;&#21046;&#26469;&#35753;&#20989;&#25968;&#36890;&#21578;&#36820;&#22238;&#20540;&#26159;&#26080;&#25928;&#30340;&#12290;&#20854;&#20013;&#26368;&#24120;&#29992;&#30340;&#19968;&#31181;&#26426;&#21046;&#27809;&#26377;&#25110;&#21482;&#26377;&#24456;&#23567;&#30340;&#24320;&#38144;&#65292;&#23601;&#26159;&#29992;&#19968;&#20010;&#20445;&#30041;&#30340;&#29305;&#27530;&#20540;&#26469;&#36890;&#21578;&#12290; + &#36825;&#31181;&#29305;&#27530;&#20540;&#30340;&#19968;&#20010;&#20856;&#22411;&#20363;&#23376;&#21253;&#25324; <code class="computeroutput"><span class="identifier">EOF</span></code>, + <code class="computeroutput"><span class="identifier">string</span><span class="special">::</span><span class="identifier">npos</span></code>, &#20301;&#20110;&#26080;&#38480;&#36828;&#30340;&#28857;&#65292;&#31561;&#31561;...
+    </p>
+<p>
+ When those values exist, i.e. the return type can hold all meaningful values + <span class="emphasis"><em>plus</em></span> the <span class="emphasis"><em>signal</em></span> value, this mechanism + is quite appropriate and well known. Unfortunately, there are cases when such + values do not exist. In these cases, the usual alternative is either to use + a wider type, such as <code class="computeroutput"><span class="keyword">int</span></code> in place + of <code class="computeroutput"><span class="keyword">char</span></code>; or a compound type, such + as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span></code>.<br> &#22914;&#26524;&#23384;&#22312;&#36825;&#26679;&#30340;&#20540;&#65292;&#21363;&#36820;&#22238;&#31867;&#22411;&#21487;&#20197;&#25345;&#26377;&#25152;&#26377;&#26377;&#24847;&#20041;&#30340;&#20540;&#20877;<span class="emphasis"><em>&#21152;&#19978;</em></span>&#36825;&#20010;<span class="emphasis"><em>&#20449;&#21495;</em></span>&#20540;&#65292;&#37027;&#20040;&#36825;&#31181;&#26426;&#21046;&#23601;&#38750;&#24120;&#36866;&#21512;&#12290; + &#19981;&#24184;&#30340;&#26159;&#65292;&#26377;&#20123;&#24773;&#24418;&#19979;&#19981;&#23384;&#22312;&#36825;&#26679;&#30340;&#20540;&#12290;&#36825;&#26102;&#65292;&#36890;&#24120;&#21487;&#29992;&#30340;&#26041;&#27861;&#26159;&#65292;&#35201;&#20040;&#20351;&#29992;&#19968;&#20010;&#26356;&#23485;&#30340;&#31867;&#22411;&#65292;&#22914;&#29992; + <code class="computeroutput"><span class="keyword">int</span></code> &#20195;&#26367; <code class="computeroutput"><span class="keyword">char</span></code>; + &#25110;&#32773;&#20351;&#29992;&#22797;&#21512;&#31867;&#22411;&#65292;&#22914; <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span></code>.
+    </p>
+<p>
+ Returning a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span></code>, thus attaching a boolean flag to the result + which indicates if the result is meaningful, has the advantage that can be + turned into a consistent idiom since the first element of the pair can be whatever + the function would conceptually return. For example, the last two functions + could have the following interface:<br> &#36820;&#22238;&#19968;&#20010; <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span></code>, &#35201;&#22312;&#32467;&#26524;&#20043;&#21518;&#28155;&#21152;&#19968;&#20010;&#24067;&#23572;&#26631;&#24535;&#65292;&#29992;&#20110;&#34920;&#31034;&#35813;&#32467;&#26524;&#26159;&#21542;&#26377;&#25928;&#65292; + &#35813;&#26041;&#27861;&#30340;&#22909;&#22788;&#26159;&#65292;&#26080;&#35770;&#20989;&#25968;&#35201;&#36820;&#22238;&#20160;&#20040;&#31867;&#22411;&#65292;&#37117;&#21487;&#20197;&#29992;&#20316; + pair &#30340;&#31532;&#19968;&#20010;&#20803;&#32032;&#65292;&#36825;&#21487;&#20197;&#25104;&#20026;&#19968;&#31181;&#36890;&#29992;&#30340;&#24815;&#29992;&#27861;&#12290; &#20363;&#22914;&#65292;&#21069;&#20363;&#20013;&#30340;&#21518;&#20004;&#20010;&#20989;&#25968;&#21487;&#20197;&#20855;&#26377;&#20197;&#19979;&#25509;&#21475;&#65306;
+    </p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span> <span class="identifier">get_async_input</span><span class="special">();</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span> <span class="identifier">polygon</span><span class="special">::</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span>
 </pre>
-
-
-<p>这些函数使用了统一的接口来处理返回值不存在的可能性:<br>
-
-</p>
-
+<p>
+ These functions use a consistent interface for dealing with possibly inexistent + results:<br> &#36825;&#20123;&#20989;&#25968;&#20351;&#29992;&#20102;&#32479;&#19968;&#30340;&#25509;&#21475;&#26469;&#22788;&#29702;&#36820;&#22238;&#20540;&#19981;&#23384;&#22312;&#30340;&#21487;&#33021;&#24615;&#65306;
+    </p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">poly</span><span class="special">.</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span> <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span> <span class="special">)</span> <span class="identifier">flood_fill</span><span class="special">(</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span><span class="special">);</span>
 </pre>
-
-
-<p>不过,这不仅是语法上的负担,还会容易出错,因为用户很容易不检查函数结果 (pair的第一个元素)是否有效就直接使用它。</p>
-
-
-<p>显然,我们需要更好的方法。<br>
-
-</p>
-
-</div>
-
-
 <p>
-  </p>
-
-
-<a name="optional_refassign"></a>
+ However, not only is this quite a burden syntactically, it is also error prone + since the user can easily use the function result (first element of the pair) + without ever checking if it has a valid value.<br> &#19981;&#36807;&#65292;&#36825;&#19981;&#20165;&#26159;&#35821;&#27861;&#19978;&#30340;&#36127;&#25285;&#65292;&#36824;&#20250;&#23481;&#26131;&#20986;&#38169;&#65292;&#22240;&#20026;&#29992;&#25143;&#24456;&#23481;&#26131;&#19981;&#26816;&#26597;&#20989;&#25968;&#32467;&#26524;(pair&#30340;&#31532;&#19968;&#20010;&#20803;&#32032;)&#26159;&#21542;&#26377;&#25928;&#23601;&#30452;&#25509;&#20351;&#29992;&#23427;&#12290;
+    </p>
 <p>
-  </p>
-
-
-<a name="optional_in_place_factories"></a>
+ Clearly, we need a better idiom.<br> &#26174;&#28982;&#65292;&#25105;&#20204;&#38656;&#35201;&#26356;&#22909;&#30340;&#26041;&#27861;&#12290;
+    </p>
+</div>
 <p>
   </p>
-
-
-<a name="optional_implementation_notes"></a>
-<p>
-  </p>
-
-
 </div>
-
-
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%">
-
-  <tbody>
-
-    <tr>
-
-
-      <td align="left">
-
-      <p><small>Last revised: October 10, 2008 at 20:53:37 GMT</small></p>
-
-      </td>
-
-
-      <td align="right">
-
-      <div class="copyright-footer"></div>
-
-      </td>
-
-
-    </tr>
-
-
-  </tbody>
-</table>
-
-
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"; width="100%"><tr> +<td align="left"><p><small>Last revised: March 24, 2010 at 07:48:57 GMT</small></p></td>
+<td align="right"><div class="copyright-footer"></div></td>
+</tr></table>
 <hr>
<div class="spirit-nav"><a accesskey="n" href="boost_optional/development.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
-
-
-</body></html>
+</body>
+</html>
=======================================
--- /trunk/libs/optional/doc/implementation_notes.qbk Mon Feb 8 07:24:10 2010 +++ /trunk/libs/optional/doc/implementation_notes.qbk Wed Mar 24 00:54:49 2010
@@ -10,7 +10,7 @@



-[section Implementation Notes]
+[section:implementation_notes Implementation Notes 实现说明]

`optional<T>` is currently implemented using a custom aligned storage facility built from `alignment_of` and `type_with_alignment` (both from Type Traits). It
@@ -20,7 +20,13 @@
As a result, `T`'s default constructor is effectively by-passed, but the exception
 guarantees are basic.
It is planned to replace the current implementation with another with stronger
-exception safety, such as a future `boost::variant`.
+exception safety, such as a future `boost::variant`.\n
+`optional<T>` 当前的实现使用了一个由 `alignment_of` 和 `type_with_alignment` (均来自 Type Traits)构建的定制对齐存储工具。 +它使用一个独立的布尔标志来标识初始化状态。带有 `T` 的复制构造函数的 Placement new 以及 `T` 的析构函数被显式用于初始化、 +复制和销毁 optional 的值。这样可以有效地绕过 `T` 的缺省构造函数,但是异常保 证只能是基本的。 +有计划用其它具有更强异常安全性的方法来替代当前的实现,如未来的 `boost::variant`.
+
+

 [endsect]

=======================================
--- /trunk/libs/optional/doc/optional.qbk       Mon Feb  8 07:24:10 2010
+++ /trunk/libs/optional/doc/optional.qbk       Wed Mar 24 00:54:49 2010
@@ -44,16 +44,18 @@
 [def __GO_TO__ [$images/callouts/R.png]]


-[section Motivation]
+[section:motivation Motivation 动机]

Consider these functions which should return a value but which might not have
-a value to return:
+a value to return:\n
+请看一下以下几个返回一个值的函数,它们也可能没有值可以返回:

 * (A) `double sqrt(double n );`
 * (B) `char get_async_input();`
 * (C) `point polygon::get_any_point_effectively_inside();`

-There are different approaches to the issue of not having a value to return. +There are different approaches to the issue of not having a value to return.\n
+通常有几种不同的方法来处理无值可以返回的情形。

A typical approach is to consider the existence of a valid return value as a postcondition, so that if the function cannot compute the value to return, it
@@ -62,13 +64,19 @@
 is a reasonable choice for example, for function (A), because the lack of a
proper return value is directly related to an invalid parameter (out of domain argument), so it is appropriate to require the callee to supply only parameters
-in a valid domain for execution to continue normally.
+in a valid domain for execution to continue normally.\n
+最典型的方法是将有效的返回值视为后续条件,则如果函数不能计算出要返回的 值,那么它要么具有未定义行为 +(也可以在调试的构建中使用断言),要么使用运行期检查并在违反后续条件时抛出一 个异常。 +对于函数(A)这是一个合理的选择,因为无法得到正确的返回值是直接由无效的参数 (超出参数域)所引起的,
+所以要求调用者只能提供有效域内的参数是适合的。

However, function (B), because of its asynchronous nature, does not fail just because it can't find a value to return; so it is incorrect to consider such
 a situation an error and assert or throw an exception. This function must
return, and somehow, must tell the callee that it is not returning a meaningful
-value.
+value.\n
+但是对于函数(B),由于它本身的异步性,不应该仅仅因为不能找到可返回的值就认为 是失败; +所以将这种情况视为错误或抛出异常都是不正确的。该函数必须返回,并且一定要通 知调用者它没有返回一个有意义的值的。

A similar situation occurs with function (C): it is conceptually an error to
 ask a ['null-area] polygon to return a point inside itself, but in many
@@ -76,31 +84,43 @@
an error (because detecting that the polygon has no area might be too expensive
 to be required to be tested previously), and either an arbitrary point
(typically at infinity) is returned, or some efficient way to tell the callee
-that there is no such point is used.
+that there is no such point is used.\n
+类似的情形也发生在函数(C)上:询问一个空的多边形并返回一个内部点在概念上是错 误的,但是在多数应用程序中, +由于性能的原因,将它视为一个错误是不切实际的(因为在调用之前检测一个多边形是 否为空可能代价很高),
+要么返回任意一个点(通常是无限远),要么以高效的方法通知调用者没有这样的点。

 There are various mechanisms to let functions communicate that the returned
 value is not valid. One such mechanism, which is quite common since it has
 zero or negligible overhead, is to use a special value which is reserved to
 communicate this. Classical examples of such special values are `EOF`,
-`string::npos`, points at infinity, etc...
+`string::npos`, points at infinity, etc...\n
+有多种机制来让函数通告返回值是无效的。其中最常用的一种机制没有或只有很小的 开销,就是用一个保留的特殊值来通告。
+这种特殊值的一个典型例子包括 `EOF`, `string::npos`, 位于无限远的点,等等...

When those values exist, i.e. the return type can hold all meaningful values ['plus] the ['signal] value, this mechanism is quite appropriate and well known. Unfortunately, there are cases when such values do not exist. In these cases, the usual alternative is either to use a wider type, such as `int` in place of
-`char`; or a compound type, such as `std::pair<point,bool>`.
+`char`; or a compound type, such as `std::pair<point,bool>`.\n
+如果存在这样的值,即返回类型可以持有所有有意义的值再['加上]这个['信号 ]值,那么这种机制就非常适合。 +不幸的是,有些情形下不存在这样的值。这时,通常可用的方法是,要么使用一个更 宽的类型,如用 `int` 代替 `char`;
+或者使用复合类型,如 `std::pair<point,bool>`.

Returning a `std::pair<T,bool>`, thus attaching a boolean flag to the result
 which indicates if the result is meaningful, has the advantage that can be
 turned into a consistent idiom since the first element of the pair can be
 whatever the function would conceptually return. For example, the last two
-functions could have the following interface:
+functions could have the following interface:\n
+返回一个 `std::pair<point,bool>`, 要在结果之后添加一个布尔标志,用于表示该 结果是否有效, +该方法的好处是,无论函数要返回什么类型,都可以用作 pair 的第一个元素,这可 以成为一种通用的惯用法。
+例如,前例中的后两个函数可以具有以下接口:

     std::pair<char,bool> get_async_input();
     std::pair<point,bool> polygon::get_any_point_effectively_inside();

These functions use a consistent interface for dealing with possibly inexistent
-results:
+results:\n
+这些函数使用了统一的接口来处理返回值不存在的可能性:

     std::pair<point,bool> p = poly.get_any_point_effectively_inside();
     if ( p.second )
@@ -108,9 +128,11 @@

However, not only is this quite a burden syntactically, it is also error prone since the user can easily use the function result (first element of the pair)
-without ever checking if it has a valid value.
-
-Clearly, we need a better idiom.
+without ever checking if it has a valid value.\n
+不过,这不仅是语法上的负担,还会容易出错,因为用户很容易不检查函数结果 (pair的第一个元素)是否有效就直接使用它。
+
+Clearly, we need a better idiom.\n
+显然,我们需要更好的方法。

 [endsect]

=======================================
--- /trunk/libs/optional/doc/reference.qbk      Mon Feb  8 07:24:10 2010
+++ /trunk/libs/optional/doc/reference.qbk      Wed Mar 24 00:54:49 2010
@@ -9,7 +9,7 @@
 ]


-[section Synopsis]
+[section:synopsis Synopsis 摘要]

     namespace boost {

@@ -19,6 +19,7 @@
         public :

// (If T is of reference type, the parameters and results by reference are by value)
+        // (如果 T 是引用类型,则以引用传递的参数和结果变为以值传递)

         optional () ; ``[link reference_optional_constructor __GO_TO__]``

@@ -27,6 +28,7 @@
optional ( T const& v ) ; ``[link reference_optional_constructor_value __GO_TO__]``

         // [new in 1.34]
+        // [1.34版本中新增]
optional ( bool condition, T const& v ) ; ``[link reference_optional_constructor_bool_value __GO_TO__]``

optional ( optional const& rhs ) ; ``[link reference_optional_constructor_optional __GO_TO__]``
@@ -53,6 +55,7 @@
         T&       get() ; ``[link reference_optional_get __GO_TO__]``

         // [new in 1.34]
+        // [1.34版本中新增]
T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]``

T const* operator ->() const ; ``[link reference_optional_operator_arrow __GO_TO__]``
@@ -69,6 +72,7 @@
bool operator!() const ; ``[link reference_optional_operator_not __GO_TO__]``

         // deprecated methods
+        // 停用的方法

         // (deprecated)
         void reset() ; ``[link reference_optional_reset __GO_TO__]``
@@ -94,12 +98,15 @@
template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]``

     // [new in 1.34]
+    // [1.34版本中新增]
template<class T> inline optional<T> make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]``

     // [new in 1.34]
+    // [1.34版本中新增]
template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; ``[link reference_make_optional_bool_value __GO_TO__]``

     // [new in 1.34]
+    // [1.34版本中新增]
template<class T> inline T const& get_optional_value_or ( optional<T> const& opt, T const& default ) ; ``[link reference_optional_get_value_or_value __GO_TO__]``

template<class T> inline T const& get ( optional<T> const& opt ) ; ``[link reference_optional_get __GO_TO__]``
@@ -121,29 +128,35 @@

 [endsect]

-[section Detailed Semantics]
+[section:detailed_semantics Detailed Semantics 详细语义]

 Because `T` might be of reference type, in the sequel, those entries whose
semantic depends on `T` being of reference type or not will be distinguished
-using the following convention:
+using the following convention:\n
+因为 `T` 可能是引用类型,所以,那些语义与 `T` 的类型是否为引用相关的项,将 使用以下约定:

 * If the entry reads: `optional<T`['(not a ref)]`>`, the description
-corresponds only to the case where `T` is not of reference type.
+corresponds only to the case where `T` is not of reference type.\n
+ 如果该项为:`optional<T`['(非引用)]`>`, 则对应的描述仅适作于 `T` 不是引用 类型时的情况。
 * If the entry reads: `optional<T&>`, the description corresponds only to
-the case where `T` is of reference type.
+the case where `T` is of reference type.\n
+  如果该项为:`optional<T&>`, 则对应的描述仅适用于 `T` 是引用类型时的情况。
 * If the entry reads: `optional<T>`, the description is the same for both
-cases.
+cases.\n
+  如果该项为:`optional<T>`, 则对应的描述适用于两种情况。

 [note
The following section contains various `assert()` which are used only to show
 the postconditions as sample code. It is not implied that the type `T` must
 support each particular expression but that if the expression is supported,
-the implied condition holds.
+the implied condition holds.\n
+以下章节中包含多个 `assert()`,仅用于示范后续条件的例子代码。
+它并不意味着类型 `T` 必须支持每个单独的表达式,但是如果它支持某个表达式,则 满足相应的条件。
 ]

 __SPACE__

-[heading optional class member functions]
+[heading optional class member functions  optional类的成员函数]

 __SPACE__

@@ -151,11 +164,16 @@

 [: `optional<T>::optional();`]

-* [*Effect:] Default-Constructs an `optional`.
-* [*Postconditions:] `*this` is [_uninitialized].
-* [*Throws:] Nothing.
-* Notes: T's default constructor [_is not] called.
-* [*Example:]
+* [*Effect:] Default-Constructs an `optional`.\n
+  [*作用:]缺省构造一个 `optional`.
+* [*Postconditions:] `*this` is [_uninitialized].\n
+  [*后续条件:]`*this` 为 [_未初始化的]。
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* Notes: T's default constructor [_is not] called.\n
+  [*说明:]T 的缺省构造函数[_未被]调用。
+* [*Example:]\n
+  [*例子:]
 ``
 optional<T> def ;
 assert ( !def ) ;
@@ -167,13 +185,18 @@

 [: `optional<T>::optional( none_t );`]

-* [*Effect:] Constructs an `optional` uninitialized.
-* [*Postconditions:] `*this` is [_uninitialized].
-* [*Throws:] Nothing.
+* [*Effect:] Constructs an `optional` uninitialized.\n
+  [*作用:]构造一个未初始化的 `optional`.
+* [*Postconditions:] `*this` is [_uninitialized].\n
+  [*后续条件:]`*this` 为 [_未初始化的]。
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
 * [*Notes:] `T`'s default constructor [_is not] called. The expression
 `boost::none` denotes an instance of `boost::none_t` that can be used as
-the parameter.
-* [*Example:]
+the parameter.\n
+ [*说明:]`T` 的缺省构造函数[_未被]调用。表达式 `boost::none` 表示一个 `boost::none_t` 实例,可用作本构造函数的参数。
+* [*Example:]\n
+  [*例子:]
 ``
 #include <boost/none.hpp>
 optional<T> n(none) ;
@@ -186,14 +209,20 @@

 [: `optional<T `['(not a ref)]`>::optional( T const& v )`]

-* [*Effect:] Directly-Constructs an `optional`.
+* [*Effect:] Directly-Constructs an `optional`.\n
+  [*作用:]直接构造一个 `optional`.
 * [*Postconditions:] `*this` is [_initialized] and its value is a['copy]
-of `v`.
-* [*Throws:] Whatever `T::T( T const& )` throws.
-* [*Notes: ] `T::T( T const& )` is called.
+of `v`.\n
+  [*后续条件:]`*this` 为 [_已初始化的],它的值为 `v` 的['拷贝]。
+* [*Throws:] Whatever `T::T( T const& )` throws.\n
+  [*抛出:]`T::T( T const& )` 所抛出的任何异常。
+* [*Notes: ] `T::T( T const& )` is called.\n
+  [*说明:]调用 `T::T( T const& )`.
 * [*Exception Safety:] Exceptions can only be thrown during
-`T::T( T const& );` in that case, this constructor has no effect.
-* [*Example:]
+`T::T( T const& );` in that case, this constructor has no effect.\n
+  [*异常安全性:]仅会在 `T::T( T const& );` 中抛出异常,这时构造函数无效。
+* [*Example:]\n
+  [*例子:]
 ``
 T v;
 optional<T> opt(v);
@@ -204,11 +233,15 @@

 [: `optional<T&>::optional( T& ref )`]

-* [*Effect:] Directly-Constructs an `optional`.
+* [*Effect:] Directly-Constructs an `optional`.\n
+  [*作用:]直接构造一个 `optional`.
 * [*Postconditions:] `*this` is [_initialized] and its value is an instance
-of an internal type wrapping the reference `ref`.
-* [*Throws:] Nothing.
-* [*Example:]
+of an internal type wrapping the reference `ref`.\n
+ [*后续条件:]`*this` 为 [_已初始化的],它的值为某个内部类型的实例,包装了 引用 `ref`.
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* [*Example:]\n
+  [*例子:]
 ``
 T v;
 T& vref = v ;
@@ -225,12 +258,14 @@
[: `optional<T` ['(not a ref)]`>::optional( bool condition, T const& v ) ;` ]
 [: `optional<T&>           ::optional( bool condition, T&       v ) ;` ]

-* If condition is true, same as:
+* If condition is true, same as:\n
+  如果 condition 为 true, 则相当于:

 [: `optional<T` ['(not a ref)]`>::optional( T const& v )`]
 [: `optional<T&>           ::optional( T&       v )`]

-* otherwise, same as:
+* otherwise, same as:\n
+  否则相当于:

 [: `optional<T ['(not a ref)]>::optional()`]
 [: `optional<T&>           ::optional()`]
@@ -241,14 +276,20 @@

 [: `optional<T `['(not a ref)]`>::optional( optional const& rhs );`]

-* [*Effect:] Copy-Constructs an `optional`.
+* [*Effect:] Copy-Constructs an `optional`.\n
+  [*作用:]复制构造一个 `optional`.
 * [*Postconditions:] If rhs is initialized, `*this` is initialized and
-its value is a ['copy] of the value of `rhs`; else `*this` is uninitialized.
-* [*Throws:] Whatever `T::T( T const& )` throws.
-* [*Notes:] If rhs is initialized, `T::T(T const& )` is called.
+its value is a ['copy] of the value of `rhs`; else `*this` is uninitialized.\n + [*后续条件:]如果 `rhs` 是已初始化的,则 `*this` 为已初始化的,且值为 `rhs` 的值的['拷贝];否则 `*this` 为未初始化的。
+* [*Throws:] Whatever `T::T( T const& )` throws.\n
+  [*抛出:]`T::T( T const& )` 所抛出的任何异常。
+* [*Notes:] If rhs is initialized, `T::T(T const& )` is called.\n
+  [*说明:]如果 `rhs` 是已初始化的,则调用 `T::T(T const& )` .
 * [*Exception Safety:] Exceptions can only be thrown during
-`T::T( T const& );` in that case, this constructor has no effect.
-* [*Example:]
+`T::T( T const& );` in that case, this constructor has no effect.\n
+  [*异常安全性:]仅会在 `T::T( T const& );` 中抛出异常,这时构造函数无效。
+* [*Example:]\n
+  [*例子:]
 ``
 optional<T> uninit ;
 assert (!uninit);
@@ -267,14 +308,19 @@

 [: `optional<T&>::optional( optional const& rhs );`]

-* [*Effect:] Copy-Constructs an `optional`.
+* [*Effect:] Copy-Constructs an `optional`.\n
+  [*作用:]复制构造一个 `optional`.
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and its
 value is another reference to the same object referenced by `*rhs`; else
-`*this` is uninitialized.
-* [*Throws:] Nothing.
+`*this` is uninitialized.\n
+ [*后续条件:]如果 `rhs` 是已初始化的,则 `*this` 为已初始化的,且值为 `*rhs` 所引用的同一个对象的另一个引用;否则 `*this` 为未初始化的。
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
* [*Notes:] If `rhs` is initialized, both `*this` and `*rhs` will reefer to the
-same object (they alias).
-* [*Example:]
+same object (they alias).\n
+ [*说明:]如果 `rhs` 是已初始化的,则 `*this` 与 `*rhs` 均引向同一个对象 (它们互为别名)。
+* [*Example:]\n
+  [*例子:]
 ``
 optional<T&> uninit ;
 assert (!uninit);
@@ -301,16 +347,22 @@

[: `template<U> explicit optional<T` ['(not a ref)]`>::optional( optional<U> const& rhs );`]

-* [*Effect:] Copy-Constructs an `optional`.
+* [*Effect:] Copy-Constructs an `optional`.\n
+  [*作用:]复制构造一个 `optional`.
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and its value is a ['copy] of the value of rhs converted to type `T`; else `*this` is
-uninitialized.
-* [*Throws:] Whatever `T::T( U const& )` throws.
+uninitialized.\n
+ [*后续条件:]如果 `rhs` 是已初始化的,则 `*this` 为已初始化的,且值为 `rhs` 转换为类型T的值的拷贝;否则 `*this` 为未初始化的。
+* [*Throws:] Whatever `T::T( U const& )` throws.\n
+  [*抛出:]`T::T( U const& )` 所抛出的任何异常。
* [*Notes: ] `T::T( U const& )` is called if `rhs` is initialized, which requires a
-valid conversion from `U` to `T`.
+valid conversion from `U` to `T`.\n
+ [*说明:]如果 `rhs` 已初始化,则调用 `T::T( U const& )`, 要求有从 `U` 到 `T` 的有效转换。 * [*Exception Safety:] Exceptions can only be thrown during `T::T( U const& );`
-in that case, this constructor has no effect.
-* [*Example:]
+in that case, this constructor has no effect.\n
+  [*异常安全性:]仅会在 `T::T( U const& );` 中抛出异常,这时构造函数无效。
+* [*Example:]\n
+  [*例子:]
 ``
 optional<double> x(123.4);
 assert ( *x == 123.4 ) ;
@@ -327,15 +379,21 @@
[: `template<TypedInPlaceFactory> explicit optional<T` ['(not a ref)]`>::optional( TypedInPlaceFactory const& f );`]

 * [*Effect:] Constructs an `optional` with a value of `T` obtained from the
-factory.
+factory.\n
+  [*作用:]构造一个 `optional`,`T` 的值从工厂获得。
* [*Postconditions: ] `*this` is [_initialized] and its value is ['directly given]
-from the factory `f` (i.e., the value [_is not copied]).
-* [*Throws:] Whatever the `T` constructor called by the factory throws.
-* [*Notes:] See [link boost_optional.in_place_factories In-Place Factories]
+from the factory `f` (i.e., the value [_is not copied]).\n
+ [*后续条件:]`*this` [_已初始化] 且其值['直接]由工厂 `f` 取得(即该值[_不 是复制的])。
+* [*Throws:] Whatever the `T` constructor called by the factory throws.\n
+  [*抛出:]由工厂所调用的 `T` 构造函数所抛出的任何异常。
+* [*Notes:] See [link boost_optional.in_place_factories In-Place Factories]\n
+  [*说明:]请见 [link boost_optional.in_place_factories 就地创建]
 * [*Exception Safety:] Exceptions can only be thrown during the call to
 the `T` constructor used by the factory; in that case, this constructor has
-no effect.
-* [*Example:]
+no effect.\n
+ [*异常安全性:]仅会在工厂调用 `T` 的构造函数时抛出异常,这时构造函数无 效。
+* [*Example:]\n
+  [*例子:]
 ``
 class C { C ( char, double, std::string ) ; } ;

@@ -354,17 +412,24 @@

 [: `optional& optional<T` ['(not a ref)]`>::operator= ( T const& rhs ) ;`]

-* [*Effect:] Assigns the value `rhs` to an `optional`.
-* [*Postconditions: ] `*this` is initialized and its value is a ['copy] of `rhs`. -* [*Throws:] Whatever `T::operator=( T const& )` or `T::T(T const&)` throws.
+* [*Effect:] Assigns the value `rhs` to an `optional`.\n
+  [*作用:]将值 `rhs` 赋给一个 `optional`.
+* [*Postconditions: ] `*this` is initialized and its value is a ['copy] of `rhs`.\n
+  [*后续条件:]`*this` 为已初始化的,其值为 `rhs` 的['拷贝]。
+* [*Throws:] Whatever `T::operator=( T const& )` or `T::T(T const&)` throws.\n + [*抛出:]由 `T::operator=( T const& )` 或 `T::T(T const&)` 抛出的任何异 常。
 * [*Notes:] If `*this` was initialized, `T`'s assignment operator is used,
-otherwise, its copy-constructor is used.
+otherwise, its copy-constructor is used.\n
+ [*说明:]如果 `*this` 是已初始化的,则使用 `T` 的赋值操作符,否则使用它的 复制构造函数。
 * [*Exception Safety:] In the event of an exception, the initialization
state of `*this` is unchanged and its value unspecified as far as `optional`
 is concerned (it is up to `T`'s `operator=()`). If `*this` is initially
 uninitialized and `T`'s ['copy constructor] fails, `*this` is left properly
-uninitialized.
-* [*Example:]
+uninitialized.\n
+ [*异常安全性:]如果发生异常,`*this` 的初始化状态不会改变,它的值是不确定 的直至 `optional` 被关联(由 `T` 的 `operator=()` 进行)。 + 如 `*this` 原来是未初始化的,且 `T` 的['复制构造函数] 失败了,则 `*this` 仍为未初始化的。
+* [*Example:]\n
+  [*例子:]
 ``
 T x;
 optional<T> def ;
@@ -381,12 +446,17 @@

 [: `optional<T&>& optional<T&>::operator= ( T& const& rhs ) ;`]

-* [*Effect:] (Re)binds thee wrapped reference.
+* [*Effect:] (Re)binds thee wrapped reference.\n
+  [*作用:](重)绑定被包装的引用。
 * [*Postconditions: ] `*this` is initialized and it references the same
-object referenced by `rhs`.
+object referenced by `rhs`.\n
+  [*后续条件:]`*this` 已初始化且引向由 `rhs` 所引向的对象。
 * [*Notes:] If `*this` was initialized, is is ['rebound] to the new object.
-See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.
-* [*Example:]
+See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.\n
+  [*说明:]如果 `*this` 已初始化,则['重绑定]到新的对象。有关细节请见
+ [link boost_optional.rebinding_semantics_for_assignment_of_optional_references 这 里]。
+* [*Example:]\n
+  [*例子:]
 ``
 int a = 1 ;
 int b = 2 ;
@@ -412,19 +482,28 @@

[: `optional& optional<T` ['(not a ref)]`>::operator= ( optional const& rhs ) ;`]

-* [*Effect:] Assigns another `optional` to an `optional`.
+* [*Effect:] Assigns another `optional` to an `optional`.\n
+  [*作用:]将另一个 `optional` 赋值给一个 `optional`.
 * [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
-its value is a ['copy] of the value of `rhs`; else `*this` is uninitialized. -* [*Throws:] Whatever `T::operator( T const&)` or `T::T( T const& )` throws. +its value is a ['copy] of the value of `rhs`; else `*this` is uninitialized.\n + [*后续条件:]如果 `rhs` 已初始化,则 `*this` 为已初始化且其值为 `rhs` 值 的['拷贝];否则 `*this` 为未初始化。 +* [*Throws:] Whatever `T::operator( T const&)` or `T::T( T const& )` throws.\n + [*抛出:]由 `T::operator( T const&)` 或 `T::T( T const& )` 抛出的任何异 常。
 * [*Notes:] If both `*this` and `rhs` are initially initialized, `T`'s
['assignment operator] is used. If `*this` is initially initialized but `rhs` is uninitialized, `T`'s [destructor] is called. If `*this` is initially uninitialized
-but `rhs` is initialized, `T`'s ['copy constructor] is called.
+but `rhs` is initialized, `T`'s ['copy constructor] is called.\n
+  [*说明:]如果 `*this` 和 `rhs` 均已初始化,则使用 `T` 的 ['赋值操作符]。
+  如果 `*this` 已初始化而 `rhs` 未初始化,则调用 `T` 的 ['析构函数]。
+  如果 `*this` 未初始化而 `rhs` 已初始化,则调用 `T` 的 ['复制构造函数]。
* [*Exception Safety:] In the event of an exception, the initialization state of `*this` is unchanged and its value unspecified as far as optional is concerned (it is up to `T`'s `operator=()`). If `*this` is initially uninitialized and
-`T`'s ['copy constructor] fails, `*this` is left properly uninitialized.
-* [*Example:]
+`T`'s ['copy constructor] fails, `*this` is left properly uninitialized.\n
+ [*异常安全性:]发生异常时,`*this` 的初始化状态不改变,其值是不确定的直 至 `optional` 被关联(由 T 的 `operator=()` 进行)。 + 如果 `*this` 原来是未初始化的而且 `T` 的 ['复制构造函数] 失败,则 `*this` 保持为未初始化]
+* [*Example:]\n
+  [*例子:]
 ``
 T v;
 optional<T> opt(v);
@@ -433,19 +512,25 @@
 opt = def ;
 assert ( !def ) ;
 // previous value (copy of 'v') destroyed from within 'opt'.
+// 'opt'的原值('v'的拷贝)被销毁
 ``

 __SPACE__

 [: `optional<T&> & optional<T&>::operator= ( optional<T&> const& rhs ) ;`]

-* [*Effect:] (Re)binds thee wrapped reference.
+* [*Effect:] (Re)binds thee wrapped reference.\n
+  [*作用:](重)绑定被包装的引用。
* [*Postconditions:] If `*rhs` is initialized, `*this` is initialized and it
 references the same object referenced by `*rhs`; otherwise, `*this` is
-uninitialized (and references no object).
+uninitialized (and references no object).\n
+ [*后续条件:]如果 `*rhs` 已初始化,则 `*this` 为已初始化的且引向且引向由 `*rhs` 所引向的对象;否则 `*this` 为未初始化(不引向任何对象)。 * [*Notes:] If `*this` was initialized and so is *rhs, this is is ['rebound] to -the new object. See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.
-* [*Example:]
+the new object. See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.\n + [*说明:]如果 `*this` 已初始化且 `*rhs` 也是,则['重绑定]到新的对象。有关 细节请见 + [link boost_optional.rebinding_semantics_for_assignment_of_optional_references 这 里]。
+* [*Example:]\n
+  [*例子:]
 ``
 int a = 1 ;
 int b = 2 ;
@@ -473,22 +558,31 @@

[: `template<U> optional& optional<T` ['(not a ref)]`>::operator= ( optional<U> const& rhs ) ;`]

-* [*Effect:] Assigns another convertible optional to an optional.
+* [*Effect:] Assigns another convertible optional to an optional.\n
+  [*作用:]将另一个可转换的 `optional` 赋值给一个 `optional`.
 * [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
 its value is a ['copy] of the value of `rhs` ['converted] to type `T`; else
-`*this` is uninitialized.
-* [*Throws:] Whatever `T::operator=( U const& )` or `T::T( U const& )` throws.
+`*this` is uninitialized. \n
+ [*后续条件:]如果 `rhs` 已初始化,则 `*this` 也是已初始化的,且其值为 `rhs` ['转换]为类型 `T` 后的值的['拷贝];否则 `*this` 为未初始化。 +* [*Throws:] Whatever `T::operator=( U const& )` or `T::T( U const& )` throws.\n + [*抛出:]由 `T::operator=( U const& )` 或 `T::T( U const& )` 抛出的任何异 常。
 * [*Notes:] If both `*this` and rhs are initially initialized, `T`'s
['assignment operator] (from `U`) is used. If `*this` is initially initialized
 but `rhs` is uninitialized, `T`'s ['destructor] is called. If `*this` is
initially uninitialized but rhs is initialized, `T`'s ['converting constructor]
-(from `U`) is called.
+(from `U`) is called.\n
+ [*说明:]如果 `*this` 和 `rhs` 均已初始化,则使用 `T` 的 ['赋值操作符] (赋值自 `U`)。
+  如果 `*this` 已初始化而 `rhs` 未初始化,则调用 `T` 的 ['析构函数]。
+ 如果 `*this` 未初始化而 `rhs` 已初始化,则调用 `T` 的 ['转换构造函数] (转 换自 `U`)。 * [*Exception Safety:] In the event of an exception, the initialization state
 of `*this` is unchanged and its value unspecified as far as optional is
 concerned (it is up to `T`'s `operator=()`). If `*this` is initially
uninitialized and `T`'s converting constructor fails, `*this` is left properly
-uninitialized.
-* [*Example:]
+uninitialized.\n
+ [*异常安全性:]发生异常时,`*this` 的初始化状态不改变,其值是不确定的直 至 `optional` 被关联(由 T 的 `operator=()` 进行)。 + 如果 `*this` 原来是未初始化的而且 `T` 的 转换构造函数 失败,则 `*this` 保 持为未初始化。
+* [*Example:]\n
+  [*例子:]
 ``
 T v;
 optional<T> opt0(v);
@@ -503,14 +597,16 @@
 [#reference_optional_reset_value]

 [: `void optional<T` ['(not a ref)]`>::reset( T const& v ) ;`]
-* [*Deprecated:] same as `operator= ( T const& v) ;`
+* [*Deprecated:] same as `operator= ( T const& v) ;`\n
+  [*不建议使用:]相当于 `operator= ( T const& v) ;`

 __SPACE__

 [#reference_optional_reset]

 [: `void optional<T>::reset() ;`]
-* [*Deprecated:] Same as `operator=( detail::none_t );`
+* [*Deprecated:] Same as `operator=( detail::none_t );`\n
+  [*不建议使用:]相当于 `operator=( detail::none_t );`

 __SPACE__

@@ -524,11 +620,16 @@
 [: `inline T const& get ( optional<T` ['(not a ref)]`> const& ) ;`]
 [: `inline T&       get ( optional<T` ['(not a ref)]`> &) ;`]

-* [*Requirements:] `*this` is initialized
-* [*Returns:] A reference to the contained value
-* [*Throws:] Nothing.
-* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`.
-* [*Example:]
+* [*Requirements:] `*this` is initialized\n
+  [*要求:]`*this` 已初始化。
+* [*Returns:] A reference to the contained value\n
+  [*返回:]所含值的引用。
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`.\n
+  [*说明:]以 `BOOST_ASSERT()` 对前提条件进行断言。
+* [*Example:]\n
+  [*例子:]
 ``
 T v ;
 optional<T> opt ( v );
@@ -549,9 +650,12 @@
[: `inline T const& get_optional_value_or ( optional<T` ['(not a ref)]`> const& o, T const& default ) ;`] [: `inline T& get_optional_value_or ( optional<T` ['(not a ref)]`>& o, T& default ) ;`]

-* [*Returns:] A reference to the contained value, if any, or `default`.
-* [*Throws:] Nothing.
-* [*Example:]
+* [*Returns:] A reference to the contained value, if any, or `default`.\n
+  [*返回:]如果有,则返回所含值(本身可以是引用)的引用, 否则返回 `default`.
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* [*Example:]\n
+  [*例子:]
 ``
 T v, z ;
 optional<T> def;
@@ -574,11 +678,16 @@
 [: `inline T const& get ( optional<T&> const& ) ;`]
 [: `inline T&       get ( optional<T&> &) ;`]

-* [*Requirements: ] `*this` is initialized
-* [*Returns:] [_The] reference contained.
-* [*Throws:] Nothing.
-* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`.
-* [*Example:]
+* [*Requirements: ] `*this` is initialized\n
+  [*要求:]`*this` 已初始化。
+* [*Returns:] [_The] reference contained.\n
+  [*返回:]所包含的引用。
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`.\n
+  [*说明:]以 `BOOST_ASSERT()` 对前提条件进行断言。
+* [*Example:]\n
+  [*例子:]
 ``
 T v ;
 T& vref = v ;
@@ -600,11 +709,15 @@
 [: `inline T*       get_pointer ( optional<T` ['(not a ref)]`> &) ;`]

 * [*Returns:] If `*this` is initialized, a pointer to the contained value;
-else `0` (['null]).
-* [*Throws:] Nothing.
+else `0` (['null]).\n
+ [*返回:]如果 `*this` 已初始化,则返回所含值的指针;否则返回 `0` (['null]).
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
* [*Notes:] The contained value is permanently stored within `*this`, so you
-should not hold nor delete this pointer
-* [*Example:]
+should not hold nor delete this pointer\n
+  [*说明:]所含值被 `*this` 永久保留,所以你不能持有或删除该指针。
+* [*Example:]\n
+  [*例子:]
 ``
 T v;
 optional<T> opt(v);
@@ -622,11 +735,16 @@
 [: `T const* optional<T` ['(not a ref)]`>::operator ->() const ;`]
 [: `T*       optional<T` ['(not a ref)]`>::operator ->()       ;`]

-* [*Requirements: ] `*this` is initialized.
-* [*Returns:] A pointer to the contained value.
-* [*Throws:] Nothing.
-* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`.
-* [*Example:]
+* [*Requirements: ] `*this` is initialized.\n
+  [*要求:]`*this` 已初始化。
+* [*Returns:] A pointer to the contained value.\n
+  [*返回:]所含值的指针。
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`.\n
+  [*说明:]以 `BOOST_ASSERT()` 对前提条件进行断言。
+* [*Example:]\n
+  [*例子:]
 ``
 struct X { int mdata ; } ;
 X x ;
@@ -641,9 +759,12 @@
 [: `optional<T>::operator `['unspecified-bool-type]`() const ;`]

 * [*Returns:] An unspecified value which if used on a boolean context
-is equivalent to (`get() != 0`)
-* [*Throws:] Nothing.
-* [*Example:]
+is equivalent to (`get() != 0`)\n
+ [*返回:]一个未明确规定的值,该值可用于布尔上下文中,等同于 `(get() != 0)`
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* [*Example:]\n
+  [*例子:]
 ``
 optional<T> def ;
 assert ( def == 0 );
@@ -658,17 +779,22 @@

 [: `bool optional<T>::operator!() ;`]

-* [*Returns:] If `*this` is uninitialized, `true`; else `false`.
-* [*Throws:] Nothing.
+* [*Returns:] If `*this` is uninitialized, `true`; else `false`.\n
+  [*返回:]如果 `*this` 未初始化,则返回 `true`; 否则返回 `false`.
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
 * [*Notes:] This operator is provided for those compilers which can't
-use the ['unspecified-bool-type operator] in certain boolean contexts.
-* [*Example:]
+use the ['unspecified-bool-type operator] in certain boolean contexts.\n
+ [*说明:]该操作提供给那些不能在布尔上下文中使用 ['unspecified-bool-type 操作符] 的编译器使用。
+* [*Example:]\n
+  [*例子:]
 ``
 optional<T> opt ;
 assert ( !opt );
 *opt = some_T ;

 // Notice the "double-bang" idiom here.
+// 注意这里的 "double-bang" 用法。
 assert ( !!opt ) ;
 ``

@@ -678,9 +804,12 @@

 [: `bool optional<T>::is_initialized() const ;`]

-* [*Returns: ] `true` if the `optional` is initialized, `false` otherwise.
-* [*Throws:] Nothing.
-* [*Example:]
+* [*Returns: ] `true` if the `optional` is initialized, `false` otherwise.\n
+  [*返回:]`true` 如果 `optional` 已初始化,否则 `false`.
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
+* [*Example:]\n
+  [*例子:]
 ``
 optional<T> def ;
 assert ( !def.is_initialized() );
@@ -698,8 +827,10 @@

 [: `optional<T` ['(not a ref)]`> make_optional( T const& v )`]

-* [*Returns: ] `optional<T>(v)` for the ['deduced] type `T` of `v`.
-* [*Example:]
+* [*Returns: ] `optional<T>(v)` for the ['deduced] type `T` of `v`.\n
+  [*返回:]`optional<T>(v)`,从 `v` ['推断]类型 `T` .
+* [*Example:]\n
+  [*例子:]
 ``
 template<class T> void foo ( optional<T> const& opt ) ;

@@ -712,8 +843,10 @@

[: `optional<T` ['(not a ref)]`> make_optional( bool condition, T const& v )`]

-* [*Returns: ] `optional<T>(condition,v)` for the ['deduced] type `T` of `v`.
-* [*Example:]
+* [*Returns: ] `optional<T>(condition,v)` for the ['deduced] type `T` of `v`.\n
+  [*返回:]`optional<T>(condition,v)`,从 `v` ['推断]类型 `T`.
+* [*Example:]\n
+  [*例子:]
 ``
 optional<double> calculate_foo()
 {
@@ -733,13 +866,18 @@
 [: `bool operator == ( optional<T> const& x, optional<T> const& y );`]

 * [*Returns:] If both `x` and `y` are initialized, `(*x == *y)`. If only
-`x` or `y` is initialized, `false`. If both are uninitialized, `true`.
-* [*Throws:] Nothing.
+`x` or `y` is initialized, `false`. If both are uninitialized, `true`.\n
+ [*返回:]如果 `x` 和 `y` 均已初始化,则返回 `(*x == *y)`. 如果只有 `x` 或 `y` 已初始化,则返回 `false`. 如果均未初始化,则返回 `true`.
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
 * [*Notes:] Pointers have shallow relational operators while `optional` has
 deep relational operators. Do not use `operator ==` directly in generic
 code which expect to be given either an `optional<T>` or a pointer; use
-__FUNCTION_EQUAL_POINTEES__ instead
-* [*Example:]
+__FUNCTION_EQUAL_POINTEES__ instead\n
+  [*说明:]指针的比较操作符是"浅比较"的,而 `optional` 是"深比较"的。
+ 不要在使用 `optional<T>` 或指针的泛型代码中直接使用 `operator ==`;应使 用 __FUNCTION_EQUAL_POINTEES__ 来替代。
+* [*Example:]\n
+  [*例子:]
 ``
 T x(12);
 T y(12);
@@ -750,17 +888,17 @@
 optional<T> optY(y);
 optional<T> optZ(z);

-// Identity always hold
+// Identity always hold 总是保持同一性
 assert ( def0 == def0 );
 assert ( optX == optX );

-// Both uninitialized compare equal
+// Both uninitialized compare equal 未初始化的对象是相等的
 assert ( def0 == def1 );

-// Only one initialized compare unequal.
+// Only one initialized compare unequal. 只有一个初始化对象则是不等的
 assert ( def0 != optX );

-// Both initialized compare as (*lhs == *rhs)
+// Both initialized compare as (*lhs == *rhs) 已初始化的对象则要比较 (*lhs == *rhs)
 assert ( optX == optY ) ;
 assert ( optX != optZ ) ;
 ``
@@ -773,12 +911,18 @@

 * [*Returns:] If `y` is not initialized, `false`. If `y` is initialized
 and `x` is not initialized, `true`. If both `x` and `y` are initialized,
-`(*x < *y)`.
-* [*Throws:] Nothing.
+`(*x < *y)`.\n
+ [*返回:]如果 `y` 未初始化,则返回 `false`. 如果 `y` 已初始而 `x` 未初始 化,则返回 `true`.
+  如果 `x` 和 `y` 均已初始化,则返回 `(*x < *y)`.
+* [*Throws:] Nothing.\n
+  [*抛出:]无。
 * [*Notes:] Pointers have shallow relational operators while `optional` has
 deep relational operators. Do not use `operator <` directly in generic code
-which expect to be given either an `optional<T>` or a pointer; use __FUNCTION_LESS_POINTEES__ instead.
-* [*Example:]
+which expect to be given either an `optional<T>` or a pointer; use __FUNCTION_LESS_POINTEES__ instead.\n
+  [*说明:]指针的比较操作符是"浅比较"的,而 `optional` 是"深比较"的。
+ 不要在使用 `optional<T>` 或指针的泛型代码中直接使用 `operator <`;应使用 __FUNCTION_LESS_POINTEES__ 来替代。
+* [*Example:]\n
+  [*例子:]
 ``
 T x(12);
 T y(34);
@@ -786,17 +930,17 @@
 optional<T> optX(x);
 optional<T> optY(y);

-// Identity always hold
+// Identity always hold 总是保持同一性
 assert ( !(def < def) );
 assert ( optX == optX );

-// Both uninitialized compare equal
+// Both uninitialized compare equal 两个未初始化对象是相等的
 assert ( def0 == def1 );

-// Only one initialized compare unequal.
+// Only one initialized compare unequal. 只有一个已初始化对象则是不等的
 assert ( def0 != optX );

-// Both initialized compare as (*lhs == *rhs)
+// Both initialized compare as (*lhs == *rhs) 两个已初始化对象则要比较 (*lhs == *rhs)
 assert ( optX == optY ) ;
 assert ( optX != optZ ) ;
 ``
@@ -807,8 +951,10 @@

 [: `bool operator != ( optional<T> const& x, optional<T> const& y );`]

-* [*Returns: ] `!( x == y );`
-* [*Throws:] Nothing.
+* [*Returns: ] `!( x == y );`\n
+  [*返回:]`!( x == y );`
+* [*Throws:] Nothing.\n
+  [*抛出:]无。

 __SPACE__

@@ -816,8 +962,10 @@

 [: `bool operator > ( optional<T> const& x, optional<T> const& y );`]

-* [*Returns: ] `( y < x );`
-* [*Throws:] Nothing.
+* [*Returns: ] `( y < x );`\n
+  [*返回:]`( y < x );`
+* [*Throws:] Nothing.\n
+  [*抛出:]无。

 __SPACE__

@@ -825,8 +973,10 @@

 [: `bool operator <= ( optional<T> const& x, optional<T> const& y );`]

-* [*Returns: ] `!( y<x );`
-* [*Throws:] Nothing.
+* [*Returns: ] `!( y<x );`\n
+  [*返回:]`!( y<x );`
+* [*Throws:] Nothing.\n
+  [*抛出:]无。

 __SPACE__

@@ -834,8 +984,10 @@

 [: `bool operator >= ( optional<T> const& x, optional<T> const& y );`]

-* [*Returns: ] `!( x<y );`
-* [*Throws:] Nothing.
+* [*Returns: ] `!( x<y );`\n
+  [*返回:]`!( x<y );`
+* [*Throws:] Nothing.\n
+  [*抛出:]无。

 __SPACE__

@@ -845,18 +997,27 @@

 * [*Effect:] If both `x` and `y` are initialized, calls `swap(*x,*y)`
 using `std::swap`. If only one is initialized, say `x`, calls:
-`y.reset(*x); x.reset();` If none is initialized, does nothing.
-* [*Postconditions:] The states of `x` and `y` interchanged.
+`y.reset(*x); x.reset();` If none is initialized, does nothing.\n
+ [*作用:]如果 `x` 和 `y` 均已初始化,则调用 `swap(*x,*y)`,使用 `std::swap`. + 如果只有一个已初始化,如 `x`, 则调用:`y.reset(*x); x.reset();`. 如果均未 初始化,则为空操作。
+* [*Postconditions:] The states of `x` and `y` interchanged.\n
+  [*后续条件:]`x` 和 `y` 的状态被交换。
* [*Throws:] If both are initialized, whatever `swap(T&,T&)` throws. If only
-one is initialized, whatever `T::T ( T const& )` throws.
+one is initialized, whatever `T::T ( T const& )` throws.\n
+ [*抛出:]如果均已初始化,则抛出 `swap(T&,T&)` 所抛出的任何异常。如果只有 一个已初始化,则抛出 `T::T ( T const& )` 所抛出的任何异常。
 * [*Notes:] If both are initialized, `swap(T&,T&)` is used unqualified but
 with `std::swap` introduced in scope.
-If only one is initialized, `T::~T()` and `T::T( T const& )` is called.
+If only one is initialized, `T::~T()` and `T::T( T const& )` is called.\n
+ [*说明:]如果均已初始化,则使用未限定的 `swap(T&,T&)`,不过 `std::swap` 被引入到当前域中。
+  如果只有一个已初始化,则调用 `T::~T()` 和 `T::T( T const& )` .
 * [*Exception Safety:] If both are initialized, this operation has the
 exception safety guarantees of `swap(T&,T&)`.
 If only one is initialized, it has the same basic guarantee as
-`optional<T>::reset( T const& )`.
-* [*Example:]
+`optional<T>::reset( T const& )`.\n
+ [*异常安全性:]如果均已初始化,则该操作具有 `swap(T&,T&)` 的异常安全性保 证。 + 如果只有一个已初始化,则该操作具有和 `optional<T>::reset( T const& )` 一 样的基本保证。
+* [*Example:]\n
+  [*例子:]
 ``
 T x(12);
 T y(21);
=======================================
--- /trunk/libs/optional/doc/special_cases.qbk  Mon Feb  8 07:24:10 2010
+++ /trunk/libs/optional/doc/special_cases.qbk  Wed Mar 24 00:54:49 2010
@@ -1,56 +1,71 @@
-
-[section Optional references]
+
+[section:optional_references Optional references  Optional引用]

 This library allows the template parameter `T` to be of reference type:
-`T&`, and to some extent, `T const&`.
+`T&`, and to some extent, `T const&`.\n
+本库允许模板参数 `T` 可以是引用类型:`T&`, 及其扩展 `T const&`.

 However, since references are not real objects some restrictions apply and
-some operations are not available in this case:
-
-* Converting constructors
-* Converting assignment
-* InPlace construction
-* InPlace assignment
-* Value-access via pointer
+some operations are not available in this case:\n
+不过,由于引用不是真正的对象,所以有一些限制,有些操作不可使用:
+
+* Converting constructors\n
+  转换构造函数
+* Converting assignment\n
+  转换赋值
+* InPlace construction\n
+  就地构造
+* InPlace assignment\n
+  就地赋值
+* Value-access via pointer\n
+  通过指针的值访问

 Also, even though `optional<T&>` treats it wrapped pseudo-object much as
-a real value, a true real reference is stored so aliasing will ocurr:
+a real value, a true real reference is stored so aliasing will ocurr:\n
+而且,虽然 `optional<T&>` 在处理其包装的伪对象时与真正的值对象非常相似,
+但实际上它保存的是一个真正的引用,所以可能发生以下容易混淆的情况:

* Copies of `optional<T&>` will copy the references but all these references
-will nonetheless reefer to the same object.
+will nonetheless reefer to the same object.\n
+ 复制 `optional<T&>` 将对引用进行复制,但所有被复制的引用都将引向同一个对 象。
 * Value-access will actually provide access to the referenced object
-rather than the reference itself.
+rather than the reference itself.\n
+  值访问操作提供对被引用的对象而不是引用本身的访问。

 [endsect]

-[section Rebinding semantics for assignment of optional references]
+[section:rebinding_semantics_for_assignment_of_optional_references Rebinding semantics for assignment of optional references
+optional引用赋值操作的重绑定语义]

If you assign to an ['uninitialized ] `optional<T&>` the effect is to bind (for
-the first time) to the object. Clearly, there is no other choice.
+the first time) to the object. Clearly, there is no other choice.\n
+如果你对一个['未初始化的] `optional<T&>` 进行赋值,效果将是将它绑定(对于第 一次赋值)到某个对象。显然,这里没有其它的选择。

     int x = 1 ;
     int& rx = x ;
     optional<int&> ora ;
     optional<int&> orb(x) ;
-    ora = orb ; // now 'ora' is bound to 'x' through 'rx'
-    *ora = 2 ; // Changes value of 'x' through 'ora'
+ ora = orb ; // now 'ora' is bound to 'x' through 'rx' 现在'ora'通 过'rx'被绑定到'x'
+    *ora = 2 ; // Changes value of 'x' through 'ora'  通过'ora'修改'x'的值
     assert(x==2);

 If you assign to a bare C++ reference, the assignment is forwarded to the
-referenced object; it's value changes but the reference is never rebound.
+referenced object; it's value changes but the reference is never rebound.\n
+如果你对一个C++裸引用进行赋值,赋值的操作将被前转至被引用的对象;结果是被引 用对象的值被改变而引用本身不会被重绑定。

     int a = 1 ;
     int& ra = a ;
     int b = 2 ;
     int& rb = b ;
-    ra = rb ; // Changes the value of 'a' to 'b'
+    ra = rb ; // Changes the value of 'a' to 'b'  修改'a'的值为'b'
     assert(a==b);
     b = 3 ;
-    assert(ra!=b); // 'ra' is not rebound to 'b'
+    assert(ra!=b); // 'ra' is not rebound to 'b'  'ra'不会重绑定到'b'

 Now, if you assign to an ['initialized ] `optional<T&>`, the effect is to
[*rebind] to the new object instead of assigning the referee. This is unlike
-bare C++ references.
+bare C++ references.\n
+现在,如果你对一个['已初始化的] `optional<T&>` 进行赋值,结果将是[*重绑定 ]到新的对象,而不是对引用物进行赋值。这和C++裸引用是不一样的。

     int a = 1 ;
     int b = 2 ;
@@ -58,23 +73,26 @@
     int& rb = b ;
     optional<int&> ora(ra) ;
     optional<int&> orb(rb) ;
-    ora = orb ; // 'ora' is rebound to 'b'
-    *ora = 3 ; // Changes value of 'b' (not 'a')
+    ora = orb ; // 'ora' is rebound to 'b'  'ora'被重绑定至'a'
+    *ora = 3 ; // Changes value of 'b' (not 'a')  修改'b'(而不是'a')的值
     assert(a==1);
     assert(b==3);

-[heading Rationale]
+[heading:rationale Rationale 原理]

Rebinding semantics for the assignment of ['initialized ] `optional` references has been chosen to provide [*consistency among initialization states] even at the
 expense of lack of consistency with the semantics of bare C++ references.
 It is true that `optional<U>` strives to behave as much as possible as `U`
does whenever it is initialized; but in the case when `U` is `T&`, doing so would
-result in inconsistent behavior w.r.t to the lvalue initialization state.
+result in inconsistent behavior w.r.t to the lvalue initialization state.\n
+对['已初始化的] `optional` 引用的赋值操作的重绑定语义提供了[*对初始化状态的 一致性],这是以违反C++裸引用语义为代价的。 +确实,`optional<U>` 尽可能表现得和 `U` 一样,不论它是否已初始化;但是如果 `U` 是 `T&`, 这样做就会导致和左值初始化状态相关的不一致行为。

 Imagine `optional<T&>` forwarding assignment to the referenced object (thus
 changing the referenced object value but not rebinding), and consider the
-following code:
+following code:\n
+设想 `optional<T&>` 将赋值操作前转至被引用的对象(修改被引用的对象而不是重绑 定),考虑一下以下代码:

     optional<int&> a = get();
     int x = 1 ;
@@ -82,20 +100,26 @@
     optional<int&> b(rx);
     a = b ;

-What does the assignment do?
+What does the assignment do?\n
+这个赋值操作会做什么?

If `a` is ['uninitialized], the answer is clear: it binds to `x` (we now have
 another reference to `x`).
 But what if `a` is already ['initialized]? it would change the value of the
 referenced object (whatever that is); which is inconsistent with the other
-possible case.
+possible case.\n
+如果 `a` 是['未初始化的],那么答案非常清楚:它将被绑定到 `x` (这样我们就有 了第二个到 `x` 的引用)。 +但是如果 `a` 已经['初始化]了呢?那么这个赋值操作可能会修改被引用对象(无论它 是什么)的值,但是这样做就会和在未初始化情形下的行为不一致。

If `optional<T&>` would assign just like `T&` does, you would never be able to
 use Optional's assignment without explicitly handling the previous
 initialization state unless your code is capable of functioning whether
-after the assignment, `a` aliases the same object as `b` or not.
-
-That is, you would have to discriminate in order to be consistency.
+after the assignment, `a` aliases the same object as `b` or not.\n
+如果 `optional<T&>` 的赋值只是象 `T&` 那样做,你就永远不能在没有显式处理过 原先的已初始化状态的时候使用 Optional 的赋值,
+除非你的代码能够判断在这个赋值之后,`a` 是 `b` 的别名抑或不是。
+
+That is, you would have to discriminate in order to be consistency.\n
+即,你不得不为了一致性而进行分别处理。

 If in your code rebinding to another object is not an option, then is very
likely that binding for the fist time isn't either. In such case, assignment
@@ -103,20 +127,25 @@
 that in such scenario the precondition that the lvalue must be already
 initialized exist. If it doesn't, then binding for the first time is OK
 while rebinding is not which is IMO very unlikely.
-In such scenario, you can assign the value itself directly, as in:
+In such scenario, you can assign the value itself directly, as in:\n
+如果将引用绑定到另一个对象对于你的代码来说是错误的,那么在第一次的时候通过 赋值操作来绑定而不是初始化很可能也是错误的。 +在这种情况下,赋值到一个['未初始化的] `optional<T&>` 应该被禁止。很可能这种 情况下前提条件是,左值必须是已初始化的。 +若非如此,则第一次的绑定是对的,而重绑定是错误的,这通常不大可能。这种情况 下你可以直接向它赋值,如:

     assert(!!opt);
     *opt=value;

 [endsect]

-[section In-Place Factories]
+[section:in_place_factories In-Place Factories 就地创建]

 One of the typical problems with wrappers and containers is that their
 interfaces usually provide an operation to initialize or assign the
 contained object as a copy of some other object. This not only requires the
underlying type to be __COPY_CONSTRUCTIBLE__, but also requires the existence of
-a fully constructed object, often temporary, just to follow the copy from:
+a fully constructed object, often temporary, just to follow the copy from:\n +使用包装器和容器的一个常见问题是,它们通常会有一个接口提供一个操作,将所含 对象初始化或赋值为另一个对象的拷贝。 +这不仅要求底层的类型是 __COPY_CONSTRUCTIBLE__,而且还要求一个完全构造的对 象,该对象通常是临时的,仅用作复制的来源:

     struct X
     {
@@ -134,14 +163,16 @@

     void foo()
     {
-        // Temporary object created.
+        // Temporary object created.  创建临时对象
         W ( X(123,"hello") ) ;
     }

 A solution to this problem is to support direct construction of the
 contained object right in the container's storage.
 In this scheme, the user only needs to supply the arguments to the
-constructor to use in the wrapped object construction.
+constructor to use in the wrapped object construction.\n
+解决这一问题的一种方法是,提供在容器的存储中直接构造所含对象的支持。
+这样一来,用户只需要将相关参数提供给构造函数,用于所含对象的构造。

     class W
     {
@@ -157,21 +188,27 @@
     {
         // Wrapped object constructed in-place
         // No temporary created.
+        // 就地创建所含对象,不再需要创建临时对象。
         W (123,"hello") ;
     }

 A limitation of this method is that it doesn't scale well to wrapped
 objects with multiple constructors nor to generic code were the constructor
-overloads are unknown.
+overloads are unknown.\n
+这种方法的限制在于,它不适用于带有多个构造函数的被包装对象,也不适用于对构 造函数重载不知情的泛型代码。

 The solution presented in this library is the family of [*InPlaceFactories]
 and [*TypedInPlaceFactories].
 These factories are a family of classes which encapsulate an increasing
 number of arbitrary constructor parameters and supply a method to construct
 an object of a given type using those parameters at an address specified by
-the user via placement new.
-
-For example, one member of this family looks like:
+the user via placement new.\n
+在本库中,解决的方法是 [*InPlaceFactories] 和 [*TypedInPlaceFactories] 家 族。 +这些工厂是一族类,这些类封装了不同参数数量的构造函数参数,提供一个方法来构 造给定类型的一个对象,
+构造时使用这些被封装的参数,并通过 placement new 在用户指定的地址进行构造。
+
+For example, one member of this family looks like:\n
+例如,这个类族中的其中一个类如下:

     template<class T,class A0, class A1>
     class TypedInPlaceFactory2
@@ -185,7 +222,8 @@
         void construct ( void* p ) { new (p) T(m_a0,m_a1) ; }
      } ;

-A wrapper class aware of this can use it as:
+A wrapper class aware of this can use it as:\n
+一个包装类可以这样来使用它:

     class W
     {
@@ -201,21 +239,27 @@
     {
         // Wrapped object constructed in-place via a TypedInPlaceFactory.
         // No temporary created.
+        // 通过 TypedInPlaceFactory 就地构造被包装对象。无需创建临时对象。
         W ( TypedInPlaceFactory2<X,int,std::string>(123,"hello")) ;
     }

-The factories are divided in two groups:
+The factories are divided in two groups:\n
+这些工厂类被分为两组:

 * [_TypedInPlaceFactories]: those which take the target type as a primary
-template parameter.
+template parameter.\n
+  [_TypedInPlaceFactories]: 它们以目标类型作为主模板参数。
 * [_InPlaceFactories]: those with a template `construct(void*)` member
-function taking the target type.
+function taking the target type.\n
+ [_InPlaceFactories]: 它们以模板化的 `construct(void*)` 成员函数来接受目标 类型。

 Within each group, all the family members differ only in the number of
-parameters allowed.
+parameters allowed.\n
+在每一组中,所有类族成员仅在可接受的参数数量上有所不同。

 This library provides an overloaded set of helper template functions to
-construct these factories without requiring unnecessary template parameters: +construct these factories without requiring unnecessary template parameters:\n
+本库还提供了一组重载的模板函数来构造这些工厂类,从而无需给定模板参数:

     template<class A0,...,class AN>
InPlaceFactoryN <A0,...,AN> in_place ( A0 const& a0, ..., AN const& aN) ;
@@ -223,7 +267,8 @@
     template<class T,class A0,...,class AN>
TypedInPlaceFactoryN <T,A0,...,AN> in_place ( T const& a0, A0 const& a0, ..., AN const& aN) ;

-In-place factories can be used generically by the wrapper and user as follows: +In-place factories can be used generically by the wrapper and user as follows:\n
+就地创建可以被包装器和用户泛型地使用,如下:

     class W
     {
@@ -242,28 +287,36 @@
     {
         // Wrapped object constructed in-place via a InPlaceFactory.
         // No temporary created.
+        // 通过 InPlaceFactory 就地构造被包装的对象。无需创建临时对象。
         W ( in_place(123,"hello") ) ;
     }

-The factories are implemented in the headers: __IN_PLACE_FACTORY_HPP__ and __TYPED_IN_PLACE_FACTORY_HPP__ +The factories are implemented in the headers: __IN_PLACE_FACTORY_HPP__ and __TYPED_IN_PLACE_FACTORY_HPP__\n +这些工厂类在头文件 __IN_PLACE_FACTORY_HPP__ 和 __TYPED_IN_PLACE_FACTORY_HPP__ 中实现。

 [endsect]

-[section A note about optional<bool>]
-
-`optional<bool>` should be used with special caution and consideration.
+[section:a_note_about_optional_bool_ A note about optional<bool> 关于 optional<bool>的说明]
+
+`optional<bool>` should be used with special caution and consideration.\n
+`optional<bool>` 在使用时需要特别小心和留意。

 First, it is functionally similar to a tristate boolean (false,maybe,true)
--such as __BOOST_TRIBOOL__-- except that in a tristate boolean, the maybe state [_represents a valid value], unlike the corresponding state of an uninitialized
 `optional<bool>`.
It should be carefully considered if an `optional<bool>` instead of a `tribool`
-is really needed.
+is really needed.\n
+首先,它的功能类似于三态布尔类型(false,maybe,true) -- 如 __BOOST_TRIBOOL__ -- 只有一点区别, +即在三态布尔类型中,maybe 状态[_代表了一个有效的值],而不是未初始化的 `optional<bool>` 的相应状态。
+如果真的要用 `optional<bool>` 替代 `tribool`,你要非常小心谨慎。

 Second, `optional<>` provides an implicit conversion to `bool`. This
conversion refers to the initialization state and not to the contained value.
 Using `optional<bool>` can lead to subtle errors due to the implicit `bool`
-conversion:
+conversion:\n
+其次,`optional<>` 提供了到 `bool` 的隐式转换。该转换表示了所含值是否为已初 始化状态。
+使用 `optional<bool>` 可能会由于这个到 `bool` 的隐式转换而导致微妙的错误:

     void foo ( bool v ) ;
     void bar()
@@ -271,20 +324,24 @@
         optional<bool> v = try();

         // The following intended to pass the value of 'v' to foo():
+        // 下面将 'v' 的值传递给 foo():
         foo(v);
         // But instead, the initialization state is passed
         // due to a typo: it should have been foo(*v).
+        // 但是实际上,被传递的是初始化状态。正确的写法应该是:foo(*v).
     }

 The only implicit conversion is to `bool`, and it is safe in the sense that
 typical integral promotions don't apply (i.e. if `foo()` takes an `int`
-instead, it won't compile).
+instead, it won't compile).\n
+隐式转换只是转为 `bool`, 不会对其进行整型类型的提升,所以它还是安全的(例 如,如果 `foo()` 接受的是一个 `int`, 它将不能编译)。

 [endsect]

-[section Exception Safety Guarantees]
-
-Because of the current implementation (see [link boost_optional.implementation_notes Implementation Notes]), all of the assignment methods: +[section:exception_safety_guarantees Exception Safety Guarantees 异常安全性 保证]
+
+Because of the current implementation (see [link boost_optional.implementation_notes Implementation Notes]), all of the assignment methods:\n +由于当前的实现(请见 [link boost_optional.implementation_notes 实现说明 ]),所有赋值方法:

 * `optional<T>::operator= ( optional<T> const& )`
 * `optional<T>::operator= ( T const& )`
@@ -295,22 +352,28 @@

 Can only ['guarantee] the [_basic exception safety]: The lvalue optional is
left [_uninitialized] if an exception is thrown (any previous value is ['first]
-destroyed using `T::~T()`)
-
-On the other hand, the ['uninitializing] methods:
+destroyed using `T::~T()`)\n
+只能['保证][_基本的异常安全性]:如果有异常被抛出,则左值 optional 将保持为 [_未初始化] (原来的值会['首先]用 `T::~T()` 销毁)。
+
+On the other hand, the ['uninitializing] methods:\n
+另一方面,['去初始化]方法:

 * `optional<T>::operator= ( detail::none_t )`
 * `optional<T>::reset()`

-Provide the no-throw guarantee (assuming a no-throw `T::~T()`)
+Provide the no-throw guarantee (assuming a no-throw `T::~T()`)\n
+提供了无抛出保证(假定 `T::~T()` 是无抛出的)。

 However, since `optional<>` itself doesn't throw any exceptions, the only
source for exceptions here are `T`'s constructor, so if you know the exception guarantees for `T::T ( T const& )`, you know that `optional`'s assignment and
-reset has the same guarantees.
+reset has the same guarantees.\n
+不过,由于 `optional<>` 本身不抛出任何异常,所以在这里异常的唯一来源是 `T` 的构造函数, +如果你知道 `T::T ( T const& )` 的异常安全性保证,那么你就可以知道 `optional` 的赋值和重置都具有相同的保证。

     //
     // Case 1: Exception thrown during assignment.
+    // Case 1: 在赋值时抛出异常。
     //
     T v0(123);
     optional<T> opt0(v0);
@@ -321,16 +384,19 @@
         opt0 = opt1 ;

         // If no exception was thrown, assignment succeeded.
+        // 如果没有异常抛出,则赋值成功。
         assert( *opt0 == v1 ) ;
     }
     catch(...)
     {
         // If any exception was thrown, 'opt0' is reset to uninitialized.
+        // 如果有任何异常抛出,则 'opt0' 被重置为未初始化。
         assert( !opt0 ) ;
     }

     //
     // Case 2: Exception thrown during reset(v)
+    // Case 2: 在 reset(v) 时抛出异常
     //
     T v0(123);
     optional<T> opt(v0);
@@ -340,15 +406,17 @@
         opt.reset ( v1 ) ;

         // If no exception was thrown, reset succeeded.
+        // 如果没有异常抛出,则重置成功。
         assert( *opt == v1 ) ;
     }
     catch(...)
     {
         // If any exception was thrown, 'opt' is reset to uninitialized.
+        // 如果有任何异常抛出,则 'opt' 被重置为未初始化。
         assert( !opt ) ;
     }

-[heading Swap]
+[heading Swap 交换]

 `void swap( optional<T>&, optional<T>& )` has the same exception guarantee
 as `swap(T&,T&)` when both optionals are initialized.
@@ -356,16 +424,21 @@
 exception guarantee as `optional<T>::reset( T const& )` (since
 `optional<T>::reset()` doesn't throw).
 If none of the optionals is initialized, it has no-throw guarantee
-since it is a no-op.
+since it is a no-op.\n
+`void swap( optional<T>&, optional<T>& )` 在两个 `optional` 均已初始化 时,具有与 `swap(T&,T&)` 相同的异常保证。 +如果只有一个 `optional` 是已初始化的,则它提供与 `optional<T>::reset( T const& )` 一样的['基本]异常保证 +(因为 `optional<T>::reset( T const& )` 不会抛出)。如果两个 `optional` 均未 初始化,则它具有无抛出保证,因为这是一个空操作。

 [endsect]

-[section Type requirements]
+[section:type_requirements Type requirements 类型要求]

In general, `T` must be __COPY_CONSTRUCTIBLE__ and have a no-throw destructor. -The copy-constructible requirement is not needed if [*InPlaceFactories] are used.
-
-`T` [_is not] required to be __SGI_DEFAULT_CONSTRUCTIBLE__.
+The copy-constructible requirement is not needed if [*InPlaceFactories] are used.\n +通常,`T` 必须是 __COPY_CONSTRUCTIBLE__ 且具有无抛出的析构函数。如果使用 [*InPlaceFactories],则无须要求可复制构造。
+
+`T` [_is not] required to be __SGI_DEFAULT_CONSTRUCTIBLE__.\n
+`T` [_并不]要求是 __SGI_DEFAULT_CONSTRUCTIBLE__。

 [endsect]

Other related posts:

  • » [boost-doc-zh] r391 committed - 翻译 optional 库的 qbk 文件并生成 html 目录 - boost-doc-zh