[boost-doc-zh] r360 committed - 翻译 foreach, function 的qbk/xml文件

  • From: boost-doc-zh@xxxxxxxxxxxxxx
  • To: boost-doc-zh-notify@xxxxxxxxxxxxx
  • Date: Mon, 04 Jan 2010 03:33:04 +0000

Revision: 360
Author: alai04
Date: Sun Jan  3 19:32:44 2010
Log: 翻译 foreach, function 的qbk/xml文件
http://code.google.com/p/boost-doc-zh/source/detail?r=360

Modified:
 /trunk/libs/foreach/doc/foreach.qbk
 /trunk/libs/function/doc/faq.xml
 /trunk/libs/function/doc/function.xml
 /trunk/libs/function/doc/history.xml
 /trunk/libs/function/doc/misc.xml
 /trunk/libs/function/doc/reference.xml
 /trunk/libs/function/doc/tests.xml
 /trunk/libs/function/doc/tutorial.xml

=======================================
--- /trunk/libs/foreach/doc/foreach.qbk Mon Dec 28 23:05:14 2009
+++ /trunk/libs/foreach/doc/foreach.qbk Sun Jan  3 19:32:44 2010
@@ -36,11 +36,11 @@
[def _noncopyable_ [@../../libs/utility/utility.htm#Class_noncopyable `boost::noncopyable`]] [def _iterator_ [@../../libs/iterator/doc/index.html Boost.Iterator]]

-[section Introduction]
-
-[:["Make simple things easy.]\n[*['-- Larry Wall]]]
-
-[h2 What is _foreach_?]
+[section:introduction Introduction 简介]
+
+[:["Make simple things easy. 把简单的事情容易化。]\n[*['-- Larry Wall]]]
+
+[h2 What is _foreach_?  _foreach_是什么?]

In C++, writing a loop that iterates over a sequence is tedious. We can either use iterators, which requires a considerable amount of boiler-plate, or we can
@@ -49,19 +49,29 @@
it will be used. In contrast, some other languages, like Perl, provide a dedicated "foreach" construct that automates this process. _foreach_ is just such a construct for C++. It iterates over sequences for us, freeing us from having to deal directly
-with iterators or write predicates.
+with iterators or write predicates.\n
+在C++中,写一个循环去迭代一个序列是很单调的。我们可以用迭代器,这需要相当大 量的代码, +或者可以用 `std::for_each()` 算法,将我们的循环体移到一个谓词中,这样并没有 减少代码量, +还使得我们的逻辑远离于使用的地点。作为对比,其它一些语言,如 Perl,就提供了 专门的 +"foreach" 结构来自动进行这一过程。_foreach_ 正是在C++中的一个同样作用的结 构。
+它为我们迭代一个序列,不需要我们来直接处理迭代器或编写谓词。

_foreach_ is designed for ease-of-use and efficiency. It does no dynamic allocations, makes no virtual function calls or calls through function pointers, and makes no calls that are not transparent to the compiler's optimizer. This results in near-optimal code generation; the performance of _foreach_ is usually within a few percent of the equivalent hand-coded loop. And although _foreach_ is a macro, it is a remarkably -well-behaved one. It evaluates its arguments exactly once, leading to no nasty surprises. +well-behaved one. It evaluates its arguments exactly once, leading to no nasty surprises.\n +_foreach_ 是为了易用性和高效性而设计的。它不进行动态的内存分配,没有虚拟函 数调用或通过函数指针的调用, +也没有令编译器的优化器无法处理的调用。这样可以生成近似于最优化的代 码;_foreach_ +的性能通常只比手工编写的循环差几个百分点。而且虽然 _foreach_ 是一个宏,但它 是有良好行为的。
+它只会对其参数进行一次求值,不会有令人讨厌的问题。

 [h2 Hello, world!]

 Below is a sample program that uses _foreach_ to loop over the contents of
-a `std::string`.
+a `std::string`.\n
+以下是一个例子,使用了 _foreach_ 来迭代一个 `std::string` 的内容。

     #include <string>
     #include <iostream>
@@ -79,54 +89,66 @@
         return 0;
     }

-This program outputs the following:
+This program outputs the following:\n
+程序的输出如下:

 [pre
 Hello, world!
 ]

-[h2 Supported Sequence Types]
+[h2 Supported Sequence Types 支持的序列类型]

_foreach_ iterates over sequences. But what qualifies as a sequence, exactly? Since _foreach_ is built on top of _range_, it automatically supports those types which _range_ recognizes as sequences. Specifically, _foreach_ works with types that satisfy
-the _single_pass_range_concept_. For example, we can use _foreach_ with:
-
-* STL containers
-* arrays
-* Null-terminated strings (`char` and `wchar_t`)
-* std::pair of iterators
+the _single_pass_range_concept_. For example, we can use _foreach_ with:\n
+_foreach_ 用于迭代某个序列。但是这个序列有什么要求呢?由于 _foreach_ 是构建 在 _range_ 之上的, +所以它自动支持了那些被 _range_ 认可的序列。特定地,_foreach_ 可用于满足 _single_pass_range_concept_ 的类型。
+例如,我们可以将 _foreach_ 用于:
+
+* STL containers\nSTL 容器
+* arrays\n数组
+* Null-terminated strings (`char` and `wchar_t`)\nNull-结尾的字符串(`char` 和 `wchar_t`)
+* std::pair of iterators\n由迭代器组成的 std::pair

[note The support for STL containers is very general; anything that looks like an STL container counts. If it has nested `iterator` and `const_iterator` types and `begin()` and `end()` member functions, _foreach_ will automatically know how to iterate over -it. It is in this way that _iterator_range_ and _sub_range_ work with _foreach_.] +it. It is in this way that _iterator_range_ and _sub_range_ work with _foreach_.\n +对 STL 容器的支持是非常全面的;任何类似于 STL 的容器都可算在内。只要它有嵌 套的 `iterator` +和 `const_iterator` 类型以及 `begin()` 和 `end()` 成员函数,_foreach_ 就可 以自动得知如何迭代它。
+这正是 _foreach_ 可用于 _iterator_range_ 和 _sub_range_ 的原因。]

 See the section on [link foreach.extensibility Extensibility] to find
-out how to make _foreach_ work with other types.
-
-[h2 Examples]
-
-Below are some examples that demonstrate all the different ways we can use _foreach_.
-
-Iterate over an STL container:
+out how to make _foreach_ work with other types.\n
+关于如何将 _foreach_ 用于其它类型,请见 [link foreach.extensibility 可扩展 性] 一节。
+
+[h2 Examples 例子]
+
+Below are some examples that demonstrate all the different ways we can use _foreach_.\n
+以下是一些例子,示范了我们使用 _foreach_ 的几种不同方式。
+
+Iterate over an STL container:\n
+迭代一个 STL 容器:

     std::list<int> list_int( /*...*/ );
     BOOST_FOREACH( int i, list_int )
     {
-        // do something with i
+        // do something with i  用i执行某些操作
     }

Iterate over an array, with covariance (i.e., the type of the iteration variable is
-not exactly the same as the element type of the container):
+not exactly the same as the element type of the container):\n
+迭代一个数组,具有协变性(即迭代变量的类型与容器的元素类型不完全相同):

     short array_short[] = {1,2,3};
     BOOST_FOREACH( int i, array_short )
     {
-        // The short was implicitly converted to an int
+ // The short was implicitly converted to an int short被隐式转换为 int
     }

-Predeclare the loop variable, and use `break`, `continue`, and `return` in the loop body: +Predeclare the loop variable, and use `break`, `continue`, and `return` in the loop body:\n
+预先声明循环变量,并在循环体中使用 `break`, `continue`, 和 `return` :

     std::deque<int> deque_int( /*...*/ );
     int i = 0;
@@ -137,88 +159,110 @@
         if( i == 2 ) break;
     }

-Iterate over a sequence by reference, and modify the underlying sequence:
+Iterate over a sequence by reference, and modify the underlying sequence:\n
+以引用方式迭代一个序列,并修改底层序列:

     short array_short[] = { 1, 2, 3 };
     BOOST_FOREACH( short & i, array_short )
     {
         ++i;
     }
-    // array_short contains {2,3,4} here
+    // array_short contains {2,3,4} here  现在 array_short 包含 {2,3,4}

 Iterate over a vector of vectors with nested _foreach_ loops. In this
-example, notice that braces around the loop body are not necessary:
+example, notice that braces around the loop body are not necessary:\n
+用嵌套的 _foreach_ 循环迭代一个 vector 的 vector. 在这个例子中,
+注意并不需要在循环体外面使用括号:

     std::vector<std::vector<int> > matrix_int;
     BOOST_FOREACH( std::vector<int> & row, matrix_int )
         BOOST_FOREACH( int & i, row )
             ++i;

-Iterate over an expression that returns a sequence by value (i.e. an rvalue): +Iterate over an expression that returns a sequence by value (i.e. an rvalue):\n
+迭代一个以值方式(即右值)返回一个序列的函数:

     extern std::vector<float> get_vector_float();
     BOOST_FOREACH( float f, get_vector_float() )
     {
         // Note: get_vector_float() will be called exactly once
+        // 注: get_vector_float() 只会被调用一次
     }

-Iterate in reverse:
+Iterate in reverse:\n
+以反序遍历:

     std::list<int> list_int( /*...*/ );
     BOOST_REVERSE_FOREACH( int i, list_int )
     {
-        // do something with i
+        // do something with i  用i来做一些操作
     }

 Iterating over rvalues doesn't work on some older compilers. Check the
 [link foreach.portability Portability] section to see whether your
-compiler supports this.
-
-[h2 Making _foreach_ Prettier]
+compiler supports this.\n
+在一些旧的编译器上,不能对右值进行迭代。请查看 [link foreach.portability 可 移植性] 一节,
+看看你的编译器是否支持。
+
+[h2 Making _foreach_ Prettier  让 _foreach_ 更漂亮]

People have complained about the name _foreach_. It's too long. `ALL CAPS` can get tiresome to look at. That may be true, but _foreach_ is merely following the [@http://www.boost.org/more/lib_guide.htm Boost Naming Convention]. That doesn't mean you're stuck with it, though. If you would like to use a different
-identifier (`foreach`, perhaps), you can simply do:
+identifier (`foreach`, perhaps), you can simply do:\n
+有的人对 _foreach_ 的名字有意见。它太长了。而且大写字母看起来有点烦人。这可 能是真的, +但 _foreach_ 不过是遵从了 [@http://www.boost.org/more/lib_guide.htm Boost 名字规则]。 +但是这并不意味着你必须用它。如果你想使用一个不同的标识符(可能是 `foreach`),你只要:

     #define foreach         BOOST_FOREACH
     #define reverse_foreach BOOST_REVERSE_FOREACH

 Only do this if you are sure that the identifier you choose will not cause
-name conflicts in your code.
+name conflicts in your code.\n
+你唯一要保证的是,你选用的标识符不会在你的代码中引起名字冲突。

 [note Do not use `#define foreach(x,y) BOOST_FOREACH(x,y)`.
  This can be problematic if the arguments are macros themselves. This would
  result in an additional expansion of these macros. Instead, use the
- form shown above.]
+ form shown above.\n
+ 不要用 `#define foreach(x,y) BOOST_FOREACH(x,y)`. 如果参数本身也是宏的 话,这会有问题。
+ 它会引起这些宏的额外扩展。你应该使用前面所说的形式。]

 [endsect]

-[section Extensibility]
+[section:extensibility Extensibility 可扩展性]

If we want to use _foreach_ to iterate over some new collection type, we must "teach" _foreach_ how to interact with our type. Since _foreach_ is built on top of _range_, we must extend _range_ in order to extend _foreach_. The section
-_extending_range_ explores this topic in detail.
+_extending_range_ explores this topic in detail.\n
+如果我们想用 _foreach_ 来迭代某些新的集合类型,我们必须 "教会" _foreach_ 如 何与我们的类型交互。 +因为 _foreach_ 是构建于 _range_ 之上的,所以我们必须扩展 _range_ 以扩展 _foreach_.
+_extending_range_ 详细解释了这个话题。

Below is an example for extending _foreach_ to iterate over a sub-string type,
-which contains two iterators into a `std::string`.
+which contains two iterators into a `std::string`.\n
+以下是一个扩展 _foreach_ 的例子,它迭代一个子串类型,该类型包含了两个指向同 一个
+`std::string` 的迭代器。

     namespace my
     {
         // sub_string: part of a string, as delimited by a pair
         // of iterators
+        // sub_string: 字符串的一部分,以一对迭代器来界定
         struct sub_string
         {
             std::string::iterator begin;
             std::string::iterator end;

-            /* ... implementation ... */
+            /* ... implementation 实现 ... */
         };

         // Add overloads of range_begin() and range_end() in the
// same namespace as sub_string, to be found by Argument-Dependent Lookup.
+        // 在 sub_string 的同一个名字空间中增加 boost_range_begin() 和
+ // boost_range_end() 的重载,才可以被ADL(Argument-Dependent Lookup)查找到。

         inline std::string::iterator range_begin( sub_string & x )
         {
@@ -232,6 +276,8 @@

// Also add overloads for const sub_strings. Note we use the conversion
         // from string::iterator to string::const_iterator here.
+        // 再增加对 const sub_strings 的重载。注意我们在这里使用了从
+        // string::iterator 到 string::const_iterator 的转换。

inline std::string::const_iterator range_begin( sub_string const & x )
         {
@@ -247,6 +293,7 @@
     namespace boost
     {
// specialize range_mutable_iterator and range_const_iterator in namespace boost
+        // 在名字空间 boost 中特化 rannge_iterator 和 range_const_iterator
         template<>
         struct range_mutable_iterator< my::sub_string >
         {
@@ -261,7 +308,9 @@
     }

 Now that we have taught _range_ (and hence _foreach_) about our type, we
-can now use _foreach_ to iterate over our sub_string type.
+can now use _foreach_ to iterate over our sub_string type.\n
+现在我们已经教会了 _range_ (也就教会了 _foreach_)关于我们的类型的知识,
+我们现在可以用 _foreach_ 来迭代我们的 sub_string 类型了。

     my::sub_string substr;
     BOOST_FOREACH( char ch, substr )
@@ -272,20 +321,25 @@
There are some portability issues we should be aware of when extending _foreach_. Be sure to check out the [link foreach.portability Portability] section. In particular, if your compiler does not support Argument-Dependent Lookup, the _range_portability_ section
-offers some suggested work-arounds.
-
-[h2 Making _foreach_ Work with Non-Copyable Sequence Types]
+offers some suggested work-arounds.\n
+我们已经知道在扩展 _foreach_ 时有一些移植性的问题。请查看 [link foreach.portability 可移植性] +一节进行确认。特定地,如果你的编译器不支持 Argument-Dependent Lookup, _range_portability_
+一节提供了一些变通的办法。
+
+[h2 Making _foreach_ Work with Non-Copyable Sequence Types 将 _foreach_ 用 于不可复制的序列类型]

 For sequence types that are non-copyable, we will need to tell _foreach_ to
not try to make copies. If our type inherits from _noncopyable_, no further action is required. If not, we must specialize the `boost::foreach::is_noncopyable<>` template, as
-follows:
+follows:\n
+对于不可复制的序列类型,我们需要告诉 _foreach_ 不要试图去进行复制。如果我们 的类型派生自 _noncopyable_, +则不需要任何动作。如果不是的话,我们就必须特化 `boost::foreach::is_noncopyable<>` 模板,如下:

     class noncopy_vector
     {
         // ...
     private:
-        noncopy_vector( noncopy_vector const & ); // non-copyable!
+ noncopy_vector( noncopy_vector const & ); // non-copyable! 不可复 制!
     };

     namespace boost { namespace foreach
@@ -298,9 +352,11 @@
     }}

Another way to achieve the same effect is to override the global `boost_foreach_is_noncopyable()` -function. Doing it this way has the advantage of being portable to older compilers.
-
-    // At global scope...
+function. Doing it this way has the advantage of being portable to older compilers.\n
+另一个有同样作用的方法是覆盖全局的 `boost_foreach_is_noncopyable()` 函数。
+这一方法的好处是可以移植到老的编译器。
+
+    // At global scope...  在全局作用域中...
     inline boost::mpl::true_ *
     boost_foreach_is_noncopyable( noncopy_vector *&, boost::foreach::tag )
     {
@@ -311,22 +367,32 @@
doesn't mean that _foreach_ always makes a copy of our sequence type. Obviously, doing so would be expensive and even wrong in some cases. _foreach_ is quite smart about when to make a copy and when not to. The `is_noncopyable<>` trait is needed to elide the copy, which
-is on a branch that might never get taken.]
-
-[h2 Optimizing _foreach_ for Lightweight Proxy Sequence Types]
+is on a branch that might never get taken.\n
+虽然我们必须告诉 _foreach_ 我们的类型是不可复制的,但这并不意味着 _foreach_ 总是对我们的序列类型进行复制。 +显然,这样做是代价昂贵的,而且在某些情况下还是错误的。_foreach_ 非常聪 明,知道何时应该复制,
+何时不该。`is_noncopyable<>` trait 用于取消复制,复制的分枝将不会被执行。]
+
+[h2 Optimizing _foreach_ for Lightweight Proxy Sequence Types 为轻量级代理 序列类型优化 _foreach_]

On some compilers, _foreach_ must occasionally take a slightly slower code path to guarantee correct handling of sequences stored in temporary objects. It asks itself, "Should I make a copy of this object?" and later, "Did I make a copy or not?" For some types of sequences, this is overkill. Consider a sequence which is a simple pair of iterators. Jumping through -hoops of fire to avoid copying it doesn't make sense because copying it is so cheap. +hoops of fire to avoid copying it doesn't make sense because copying it is so cheap.\n +在一些编译器上,_foreach_ 有时需要选择一条稍微慢一点的代码路径以保证正确地 处理保存临时对象的序列。 +它问自己,"我应该复制这个对象吗?",稍后又问,"我复制了这个对象吗? "。对于 某些序列类型,这是多余的。 +考虑由一对迭代器所组成的序列。并不值得为了避免复制而进行这些跳转,因为它的 复制代价是非常小的。

A pair of iterators is an example of a lightweight proxy. It does not store the values of the sequence; rather, it stores iterators to them. This means that iterating over a copy of the proxy object will give the same results as using the object itself. For such types, _foreach_ provides a hook that lets us tell it not to worry about the expense of making a copy. This can result in slightly faster loop execution. Simply specialize the
-`boost::foreach::is_lightweight_proxy<>` trait, as follows:
+`boost::foreach::is_lightweight_proxy<>` trait, as follows:\n
+这样的一对迭代器就是轻量级代理的例子。它并不保存序列中的值;而是保存它们的 迭代器。 +这意味着对这个代理对象的拷贝进行迭代与使用对象本身是同样的效果。对于这种类 型, +_foreach_ 提供了一个钩子让我们告诉它不需要关心复制的开销。这样可以生成更快 的循环执行。 +只需要象下面这样特化 `boost::foreach::is_lightweight_proxy<>` trait 就可以 了:

     struct sub_string
       : boost::iterator_range< std::string::iterator >
@@ -344,49 +410,66 @@
     }}

 Alternately, we could achieve the same effect by overriding the global
-`boost_foreach_is_lightweight_proxy()` function, as follows:
-
-    // At global scope...
+`boost_foreach_is_lightweight_proxy()` function, as follows:\n
+另一种有相同作用的方法是覆盖全局的 `boost_foreach_is_lightweight_proxy()` 函数,如下:
+
+    // At global scope...  在全局作用域中...
     inline boost::mpl::true_ *
boost_foreach_is_lightweight_proxy( sub_string *&, boost::foreach::tag )
     {
         return 0;
     }

-This method is portable to older compilers.
+This method is portable to older compilers.\n
+这个方法可移植到老的编译器。

 [endsect]

-[section Portability]
+[section:portability Portability 可移植性]

_foreach_ uses some fairly sophisticated techniques that not all compilers support. Depending on how compliant your compiler is, you may not be able to use _foreach_ in some scenarios. Since _foreach_ uses _range_, it inherits _range_'s portability issues. You can read about those
-issues in the _range_portability_ section.
+issues in the _range_portability_ section.\n
+_foreach_ 使用了一些相当复杂的技巧,不是所有编译器都可以支持。取决于你的编 译器对标准的兼容度, +你有可能在某些情形下不能使用 _foreach_。由于 _foreach_ 使用了 _range_, 所以 它继承了 _range_
+的可移植性问题。你可以在 _range_portability_ 一节中看到这些问题。

In addition to the demands placed on the compiler by _range_, _foreach_ places additional demands in order to handle rvalue sequences properly. (Recall that an rvalue is an unnamed object, so an example of an rvalue sequence would be a function that returns a `std::vector<>` by value.) Compilers vary in their handling of rvalues and lvalues. To cope with the situation _foreach_ defines three
-levels of compliance, described below:
+levels of compliance, described below:\n
+除了 _range_ 对编译器的要求以外,_foreach_ 还有其它的要求以正确处理右值序列 (右值是一个匿名对象, +右值序列的一个例子就是以值方式返回一个 `std::vector<>` 的函数)。编译器在处 理右值和左值时是有所不同的。
+为了应付这种情况,_foreach_ 定义了三个兼容度级别,描述如下:

 [table BOOST_FOREACH Compliance Levels
-  [[Level]     [Meaning]]
+  [[Level 级别]     [Meaning 意义]]
   [[*Level 0*] [['[_Highest level of compliance]]\n
- _foreach_ works with lvalues, rvalues and const-qualified rvalues.]] + _foreach_ works with lvalues, rvalues and const-qualified rvalues.\n
+                ['[_最高兼容度级别]]\n
+                _foreach_ 可用于左值、右值和 const-限定的右值。]]
   [[*Level 1*] [['[_Moderate level of compliance]]\n
_foreach_ works with lvalues and plain rvalues, but not const-qualified rvalues.\n - `BOOST_FOREACH_NO_CONST_RVALUE_DETECTION` is defined in this case.]] + `BOOST_FOREACH_NO_CONST_RVALUE_DETECTION` is defined in this case.\n
+                ['[_中等兼容度级别]]\n
+ _foreach_ 可用于左值和简单右值,但不可用于 const-限定的右 值。\n + 这种情况下定义了 `BOOST_FOREACH_NO_CONST_RVALUE_DETECTION`.]]
   [[*Level 2*] [['[_Lowest level of compliance]]\n
                 _foreach_ works with lvalues only, not rvalues.\n
- `BOOST_FOREACH_NO_RVALUE_DETECTION` is defined in this case.]] + `BOOST_FOREACH_NO_RVALUE_DETECTION` is defined in this case.\n
+                ['[_最低兼容度级别]]\n
+                _foreach_ 只可用于左值,不可用于右值。\n
+                这种情况下定义了 `BOOST_FOREACH_NO_RVALUE_DETECTION`.]]
 ]

Below are the compilers with which _foreach_ has been tested, and the compliance level _foreach_
-provides for them.
-
-[table Compiler Compliance Level
-  [[Compiler]                [Compliance Level]]
+provides for them.\n
+以下是 _foreach_ 已经测试过的编译器,以及它们对于 _foreach_ 的兼容度级别。
+
+[table Compiler Compliance Level 编译器兼容度级别
+  [[Compiler 编译器]                [Compliance Level 兼容度级别]]
   [[Visual C++ 8.0]          [Level 0]]
   [[Visual C++ 7.1]          [Level 0]]
   [[Visual C++ 7.0]          [Level 2]]
@@ -411,36 +494,42 @@

 [endsect]

-[section Pitfalls]
-
-This section describes some common pitfalls with _foreach_.
-
-[h2 Types With Commas]
+[section:pitfalls Pitfalls 缺陷]
+
+This section describes some common pitfalls with _foreach_.\n
+本节描述 _foreach_ 中的一些常见的缺陷。
+
+[h2 Types With Commas 带逗号的类型]

Since _foreach_ is a macro, it must have exactly two arguments, with exactly one comma separating them. That's not always convenient, especially when the type of the
-loop variable is a template. Consider trying to iterate over a `std::map`:
+loop variable is a template. Consider trying to iterate over a `std::map`:\n +由于 _foreach_ 是一个宏,它必须刚好有两个参数,并以一个逗号分隔它们。这并不 总是很方便,
+尤其当循环变量的类型是一个模板的时候。考虑一下对 `std::map` 进行迭代:

     std::map<int,int> m;

     // ERROR! Too many arguments to BOOST_FOREACH macro.
+    // 错误!BOOST_FOREACH 宏参数过多。
     BOOST_FOREACH(std::pair<int,int> p, m) // ...

-One way to fix this is with a typedef.
+One way to fix this is with a typedef.\n
+一个解决方法是使用 typedef.

     std::map<int,int> m;
     typedef std::pair<int,int> pair_t;

     BOOST_FOREACH(pair_t p, m) // ...

-Another way to fix it is to predeclare the loop variable:
+Another way to fix it is to predeclare the loop variable:\n
+另一个解决方法是预先声明循环变量:

     std::map<int,int> m;
     std::pair<int,int> p;

     BOOST_FOREACH(p, m) // ...

-[h2 Hoisting and Iterator Invalidation]
+[h2 Hoisting and Iterator Invalidation  Hoisting和无效迭代器]

 Under the covers, _foreach_ uses iterators to traverse the element
 sequence. Before the loop is executed, the end iterator is cached
@@ -448,9 +537,14 @@
 important optimization. It assumes, however, that the end iterator
 of the sequence is stable. It usually is, but if we modify the
 sequence by adding or removing elements while we are iterating
-over it, we may end up hoisting ourselves on our own petard.
-
-Consider the following code:
+over it, we may end up hoisting ourselves on our own petard.\n
+在内部,_foreach_ 使用了迭代器来遍历序列的元素。在循环执行之前,
+结束迭代器会缓存到一个局部变量中。这被称为 hoisting, 它是一个重要的优化。
+但是它假设该序列的结束迭代器是稳定的。通常也是这样,
+但如果我们在迭代序列时增加或删除了序列的元素,我们就可能自己破坏了 hoisting.
+
+Consider the following code:\n
+考虑以下代码:

     std::vector<int> vect(4, 4);
     BOOST_FOREACH(int i, vect)
@@ -459,30 +553,35 @@
     }

 This code will compile, but it has undefined behavior. That is because
-it is logically equivalent to the following:
+it is logically equivalent to the following:\n
+这段代码可以编译,但它具有未定义行为。这是因为它在逻辑上等同于以下代码:

     std::vector<int> vect(4, 4);
     for(std::vector<int>::iterator it1 = vect.begin(), it2 = vect.end();
         it1 != it2; ++it1)
     {
         int i = *it1;
-        vect.push_back(i + 1); // Oops! This invalidates it1 and it2!
+ vect.push_back(i + 1); // Oops! This invalidates it1 and it2! 这使 得 it1 和 it2 无效!
     }

 The call to `vect.push_back()` will cause all iterators into `vect` to
 become invalid, including `it1` and `it2`. The next iteration through
-the loop will cause the invalid iterators to be used. That's bad news.
+the loop will cause the invalid iterators to be used. That's bad news.\n
+对 `vect.push_back()` 的调用会导致 `vect` 中的所有迭代器变为无效,
+包括 `it1` 和 `it2`. 循环的下一次迭代会使用这些无效迭代器。这可是坏消息。

 The moral of the story is to think twice before adding and removing
 elements from the sequence over which you are iterating. If doing
 so could cause iterators to become invalid, don't do it. Use a regular
-`for` loop instead.
+`for` loop instead.\n
+正确的做法是,在迭代中增加或删除序列中的元素一定要三思。
+如果这样做会导致迭代器变为无效,就不要这样做。用一个普通的 `for` 循环来替 代。

 [endsect]

-[section History and Acknowledgements]
-
-[h2 History]
+[section:history_and_acknowledgements History and Acknowledgements 历史和鸣 谢]
+
+[h2 History 历史]

The ideas for _foreach_ began life in the Visual C++ group at Microsoft during the early phases of the design for C++\/CLI. Whether to add a dedicated "foreach" looping construct to the language was
@@ -502,14 +601,14 @@
accepted _range_ library, which increased its portability. This was the version that, on Dec. 12 2004, I finally submitted to Boost for review. It was accepted into Boost on May 5, 2005.

-[h2 Acknowledgements]
+[h2 Acknowledgements 鸣谢]

Thanks go out to Anson Tsao of Microsoft for coming up with the idea and demonstrating its feasibility. I would also like to thank [@http://boost.org/people/thorsten_ottosen.html Thorsten Ottosen] for the _range_ library, on which the current version of _foreach_ is built. Finally, I'd like to thank Russell Hind, Alisdair Meredith and Stefan Slapeta for their help porting to various compilers.

-[h2 Further Reading]
+[h2 Further Reading 进一步阅读]

For more information about how _foreach_ works, you may refer to the article
 [@http://www.artima.com/cppsource/foreach.html ["Conditional Love]] at
=======================================
--- /trunk/libs/function/doc/faq.xml    Mon Dec 28 23:05:14 2009
+++ /trunk/libs/function/doc/faq.xml    Sun Jan  3 19:32:44 2010
@@ -9,30 +9,39 @@
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
   "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd";>
<section id="function.faq" last-revision="$Date: 2006-11-03 15:41:10 -0400 (Fri, 03 Nov 2006) $">
-  <title>Frequently Asked Questions</title>
+  <title>Frequently Asked Questions 常见问题</title>

 <qandaset>
   <qandaentry>
     <question><para>Why can't I compare
     <classname>boost::function</classname> objects with
     <code>operator==</code> or
-    <code>operator!=</code>?</para></question>
+    <code>operator!=</code>?<sbr/>
+    为什么我不能用 <code>operator==</code> 或 <code>operator!=</code>
+    来比较 <classname>boost::function</classname> 对象?</para></question>

     <answer>
       <para>Comparison between <classname>boost::function</classname>
       objects cannot be implemented "well", and therefore will not be
       implemented. The typical semantics requested for <code>f ==
       g</code> given <classname>boost::function</classname> objects
-      <code>f</code> and <code>g</code> are:</para>
+      <code>f</code> and <code>g</code> are:<sbr/>
+ 在 <classname>boost::function</classname> 对象之间的比较不能“较好地 ”实现,因此不再实现。 + 对于 <code>f == g</code> 的典型的语义要求是给定 <classname>boost::function</classname> 对象
+      <code>f</code> 和 <code>g</code>:</para>
         <itemizedlist>
           <listitem><simpara>If <code>f</code> and <code>g</code>
           store function objects of the same type, use that type's
           <code>operator==</code> to compare
-          them.</simpara></listitem>
+          them.<sbr/>
+          如果 <code>f</code> 和 <code>g</code> 存储相同类型的函数对象,
+ 使用那个类型的 <code>operator==</code> 去比较它们。 </simpara></listitem>

           <listitem><simpara>If <code>f</code> and <code>g</code>
           store function objects of different types, return
-          <code>false</code>.</simpara></listitem>
+          <code>false</code>.<sbr/>
+          如果 <code>f</code> 和 <code>g</code> 存储不同的函数对象,
+          返回 <code>false</code>。</simpara></listitem>
         </itemizedlist>
       <para>The problem occurs when the type of the function objects
       stored by both <code>f</code> and <code>g</code> doesn't have an
@@ -49,7 +58,17 @@
       <classname>boost::function</classname> object: you will get an
       error at the assignment operator or constructor, not in
       <code>operator()</code>, because the function-call expression
-      must be bound in the constructor or assignment operator.</para>
+      must be bound in the constructor or assignment operator.<sbr/>
+ 当 <code>f</code> 和 <code>g</code> 存储的函数对象都没有 <code>operator==</code> 时就会发生问题: + 我们想让表达式 <code>f == g</code> 无法编译,这就像在标准容器中发生的 事情。 + 然而,对于 <classname>boost::function</classname> 来说这是无法实现 的,
+      因为它被赋予一个函数对象后,它不可避免地“抹去”一些类型信息,
+      所以其后它就不能再试图去调用 <code>operator==</code>:
+ 它必须既要在现在找到一种调用 <code>operator==</code> 的方法,又要在其 后永远不能调用它。
+      注意,举例来说,如果你试图将一个 <code>float</code> 值放入一个
+      <classname>boost::function</classname> 对象时会发生什么:
+ 你将得到一个来自于赋值操作符或构造函数,而不是 <code>operator()</code> 的错误,
+      因为函数调用表达式肯定会进入构造函数或赋值操作符。</para>

       <para>The most promising approach is to find a method of
       determining if <code>operator==</code> can be called for a
@@ -58,25 +77,36 @@
       thrown. However, to date there is no known way to detect if an
       arbitrary operator expression <code>f == g</code> is suitably
       defined. The best solution known has the following undesirable
-      qualities:</para>
+      qualities:<sbr/>
+ 最有希望的方法是找到一种检测 <code>operator==</code> 是否能被特定类型 调用的方法, + 并仅仅在它可用的时候才支持它;在其它情况下,抛出一个异常。然而,到目 前位置, + 还不知道有什么方法可以检测一个任意的操作符表达式 <code>f == g</code> 是否被合适地定义。
+      已知最好的解决方案有以下这些令人不快的性质:</para>

       <orderedlist>
         <listitem><simpara>Fails at compile-time for objects where
         <code>operator==</code> is not accessible (e.g., because it is
-        <code>private</code>).</simpara></listitem>
+        <code>private</code>).<sbr/>
+ 对于 <code>operator==</code> 不可访问的对象(例如,因为它是 <code>private</code> 的),
+        会在编译时失败。</simpara></listitem>

         <listitem><simpara>Fails at compile-time if calling
-        <code>operator==</code> is ambiguous.</simpara></listitem>
+        <code>operator==</code> is ambiguous.<sbr/>
+ 如果调用 <code>operator==</code> 是有歧义的,会在编译时失败。 </simpara></listitem>

         <listitem><simpara>Appears to be correct if the
         <code>operator==</code> declaration is correct, even though
-        <code>operator==</code> may not compile.</simpara></listitem>
+        <code>operator==</code> may not compile.<sbr/>
+ 如果 <code>operator==</code> 的声明是正确的,即使 <code>operator==</code>
+        可能没有被编译,看上去就是正确的。</simpara></listitem>
       </orderedlist>

       <para>All of these problems translate into failures in the
       <classname>boost::function</classname> constructors or
       assignment operator, <emphasis>even if the user never invokes
-      operator==</emphasis>. We can't do that to users.</para>
+      operator==</emphasis>. We can't do that to users.<sbr/>
+ 所有这些问题都被转化为 <classname>boost::function</classname> 的构造 函数或赋值操作符中的失败, + <emphasis>即使,用户从来没有调用过 operator==</emphasis>。我们不能对 用户做这样的事。</para>

       <para>The other option is to place the burden on users that want
       to use <code>operator==</code>, e.g., by providing an
@@ -89,12 +119,19 @@
       of <code>operator==</code> in the context in which it is most
       desired: multitarget callbacks. The
       <libraryname>Signals</libraryname> library has a way around
-      this.</para>
+      this.<sbr/>
+      另一种选择方案是把负担放到要使用 <code>operator==</code> 的用户身上,
+ 例如,通过提供一个他们可以特化的 <code>is_equality_comparable<code> traits。 + 这是一个可用的方案,但实际上是很危险的,因为忘记特化这个 traits 会导 致由 + <classname>boost::function</classname> 的 <code>operator==</code> 抛 出的意想不到的异常。 + 这在本质上否定了 <code>operator==</code> 在它最期望的上下文(多目标回 调)中的可用性。
+      <libraryname>Signals</libraryname> 库有一个和它差不多的方法。</para>
     </answer>
   </qandaentry>

   <qandaentry>
- <question><para>I see void pointers; is this [mess] type safe?</para></question>
+    <question><para>I see void pointers; is this [mess] type safe?<sbr/>
+    我看到了 void 指针,这会[扰乱]类型安全吗?</para></question>
     <answer>
 <para>Yes, <computeroutput>boost::function</computeroutput> is type
 safe even though it uses void pointers and pointers to functions
@@ -105,18 +142,29 @@
 pointer or pointer to void function. The reason that both are required
 is that one may cast between void pointers and object pointers safely
 or between different types of function pointers (provided you don't
-invoke a function pointer with the wrong type).  </para>
+invoke a function pointer with the wrong type).  <sbr/>
+是的,即使 <computeroutput>boost::function</computeroutput> 使用了 void 指 针和指向返回
+void 也没持有参数的函数的指针,它也是类型安全的。实际上,
+所有类型信息都编码在管理和调用函数指针和函数对象的函数中。
+只有这些函数才能被严格的“被 void 指针指向的类型”或“指向 void 函数的指针类型 ”实例化。 +这两者的前提是需要在 void 指针和对象指针之间或在不同类型的函数指针之间可以 安全地转型
+(倘若你没有使用错误的类型调用一个函数指针)。
+</para>
     </answer>
   </qandaentry>

   <qandaentry>
- <question><para>Why are there workarounds for void returns? C++ allows them!</para></question> - <answer><para>Void returns are permitted by the C++ standard, as in this code snippet: + <question><para>Why are there workarounds for void returns? C++ allows them!<sbr/> + 为什么会有专门应付空返回的 workarounds,C++ 是允许它们 的!</para></question> + <answer><para>Void returns are permitted by the C++ standard, as in this code snippet:<sbr/>
+    空返回被 C++ 标准允许,就像下面这样的代码片段:
 <programlisting>void f();
 void g() { return f(); }</programlisting>
     </para>

- <para> This is a valid usage of <computeroutput>boost::function</computeroutput> because void returns are not used. With void returns, we would attempting to compile ill-formed code similar to: + <para> This is a valid usage of <computeroutput>boost::function</computeroutput> because void returns are not used. With void returns, we would attempting to compile ill-formed code similar to:<sbr/> + 这是 <computeroutput>boost::function</computeroutput> 的一个合法使 用,因为空返回没有被使用。
+    利用空返回,我们可以企图编译如下病态的代码:
 <programlisting>int f();
 void g() { return f(); }</programlisting>
 </para>
@@ -124,28 +172,39 @@
 <para> In essence, not using void returns allows
<computeroutput>boost::function</computeroutput> to swallow a return value. This is
 consistent with allowing the user to assign and invoke functions and
-function objects with parameters that don't exactly match.</para>
+function objects with parameters that don't exactly match.<sbr/>
+实际上,没有使用的空返回允许 <computeroutput>boost::function</computeroutput> 吞下一个返回值。 +这是为了和用户在使用不严格匹配的参数赋值和调用函数与函数对象时保持一致。 </para>

     </answer>
   </qandaentry>

   <qandaentry>
-    <question><para>Why (function) cloning?</para></question>
+    <question><para>Why (function) cloning?<sbr/>
+    (函数)为什么要克隆?</para></question>
     <answer>
       <para>In November and December of 2000, the issue of cloning
       vs. reference counting was debated at length and it was decided
       that cloning gave more predictable semantics. I won't rehash the
       discussion here, but if it cloning is incorrect for a particular
-      application a reference-counting allocator could be used.</para>
+      application a reference-counting allocator could be used.<sbr/>
+      在 2000 年 11 和 12 月,克隆和引用计数的问题争论了很长时间,
+      最终决定克隆提供了更加可预言的语义。我不想对这场争论旧调重弹,
+ 但是如果对于一个特定应用来说克隆是不正确的,reference-counting allocator
+      (引用计数分配器)也可以使用。
+</para>
     </answer>
   </qandaentry>

   <qandaentry>
- <question><para>How much overhead does a call through <code><classname>boost::function</classname></code> incur?</para></question> + <question><para>How much overhead does a call through <code><classname>boost::function</classname></code> incur?<sbr/> + 通过 <code><classname>boost::function</classname></code> 进行调用会导致 多少代价?</para></question>
     <answer>
       <para>The cost of <code>boost::function</code> can be reasonably
       consistently measured at around 20ns +/- 10 ns on a modern >2GHz
-      platform versus directly inlining the code.</para>
+      platform versus directly inlining the code.<sbr/>
+ <code>boost::function</code> 的成本可以被相当一致地测量,在现代的
2GHz
+      的平台上与直接的内联代码相比大约相差 20ns +/- 10 ns。</para>

       <para>However, the performance of your application may benefit
       from or be disadvantaged by <code>boost::function</code>
@@ -153,7 +212,11 @@
       standard function pointer, differences of order of 10% have been
       noted to the benefit or disadvantage of using
       <code>boost::function</code> to call a function that contains a
-      tight loop depending on your compilation circumstances.</para>
+      tight loop depending on your compilation circumstances.<sbr/>
+ 然而,你的应用的性能可能会得益于或受损于 <code>boost::function</code>, + 依赖于你的 C++ 优化器的优化。与一个标准函数指针相比,大约 10% 的差 距, + 相对于使用 <code>boost::function</code> 调用一个包含依赖于你的编码环
+      的密集循环的函数来说,是无足轻重的。</para>

<para>[Answer provided by Matt Hurd. See <ulink url="http://article.gmane.org/gmane.comp.lib.boost.devel/33278"/>]</para>
     </answer>
=======================================
--- /trunk/libs/function/doc/function.xml       Mon Dec 28 23:05:14 2009
+++ /trunk/libs/function/doc/function.xml       Sun Jan  3 19:32:44 2010
@@ -1,65 +1,80 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
-  "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd";>
-<library name="Function" dirname="function" id="function"
- last-revision="$Date: 2004-07-24 22:59:30 -0400 (Sat, 24 Jul 2004) $"
-         xmlns:xi="http://www.w3.org/2001/XInclude";>
-<libraryinfo>
-  <author>
-    <firstname>Douglas</firstname>
-    <surname>Gregor</surname>
-    <email>dgregor -at- cs.indiana.edu</email>
-  </author>
-
-  <copyright>
-    <year>2001</year>
-    <year>2002</year>
-    <year>2003</year>
-    <year>2004</year>
-    <holder>Douglas Gregor</holder>
-  </copyright>
-
-  <legalnotice>
-    <para>Use, modification and distribution is subject to the Boost
-    Software License, Version 1.0. (See accompanying file
-    <filename>LICENSE_1_0.txt</filename> or copy at <ulink
- url="http://www.boost.org/LICENSE_1_0.txt";>http://www.boost.org/LICENSE_1_0.txt</ulink>)</para>
-  </legalnotice>
-
- <librarypurpose>Function object wrappers for deferred calls or callbacks</librarypurpose>
-  <librarycategory name="category:higher-order"/>
-</libraryinfo>
-
-<title>Boost.Function</title>
-
-<section id="function.intro">
-<title>Introduction</title>
-<para>The Boost.Function library contains a family of class templates
-that are function object wrappers. The notion is similar to a
-generalized callback. It shares features with function pointers in
-that both define a call interface (e.g., a function taking two integer
-arguments and returning a floating-point value) through which some
-implementation can be called, and the implementation that is invoked
-may change throughout the course of the program.<sbr/>
-Boost.Function 库包含一组作为 function object wrappers(函数对象包装类)的 类模板。 -在概念上类似一个泛化的 callback(回调)。它在两种情况下具有和函数指针相同的 特性, -一种是定义一个可用于某些可调用实现的调用接口(例如,一个持有两个整型参数并 返回一个浮点值的函数),
-另一种是在整个程序的流程中可能变化的调用。</para>
-
-<para> Generally, any place in which a function pointer would be used
-to defer a call or make a callback, Boost.Function can be used instead
-to allow the user greater flexibility in the implementation of the
-target. Targets can be any 'compatible' function object (or function
-pointer), meaning that the arguments to the interface designated by
-Boost.Function can be converted to the arguments of the target
-function object.</para>
-</section>
-
-<xi:include href="history.xml"/>
-<xi:include href="tutorial.xml"/>
-<xi:include href="reference.xml"/>
-<xi:include href="faq.xml"/>
-<xi:include href="misc.xml"/>
-<xi:include href="tests.xml"/>
-
+"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd";>
+<library dirname="function" id="function"
+ last-revision="$Date: 2004-07-24 22:59:30 -0400 (Sat, 24 Jul 2004) $"
+         name="Function">
+  <libraryinfo>
+    <author>
+      <firstname>Douglas</firstname>
+
+      <surname>Gregor</surname>
+
+      <email>dgregor -at- cs.indiana.edu</email>
+    </author>
+
+    <copyright>
+      <year>2001</year>
+
+      <year>2002</year>
+
+      <year>2003</year>
+
+      <year>2004</year>
+
+      <holder>Douglas Gregor</holder>
+    </copyright>
+
+    <legalnotice>
+      <para>Use, modification and distribution is subject to the Boost
+      Software License, Version 1.0. (See accompanying file
+      <filename>LICENSE_1_0.txt</filename> or copy at <ulink
+ url="http://www.boost.org/LICENSE_1_0.txt";>http://www.boost.org/LICENSE_1_0.txt</ulink>)</para>
+    </legalnotice>
+
+    <librarypurpose>Function object wrappers for deferred calls or
+    callbacks</librarypurpose>
+
+    <librarycategory name="category:higher-order" />
+  </libraryinfo>
+
+  <title>Boost.Function</title>
+
+  <section id="function.intro">
+    <title>Introduction</title>
+
+ <para>The Boost.Function library contains a family of class templates that
+    are function object wrappers. The notion is similar to a generalized
+ callback. It shares features with function pointers in that both define a
+    call interface (e.g., a function taking two integer arguments and
+ returning a floating-point value) through which some implementation can be + called, and the implementation that is invoked may change throughout the + course of the program.<sbr/> Boost.Function 库包含一组作为 function object + wrappers(函数对象包装类)的类模板。 在概念上类似一个泛化的 callback(回调)。它在两种情况下具有和函数指针相同的特性, + 一种是定义一个可用于某些可调用实现的调用接口(例如,一个持有两个整型参 数并返回一个浮点值的函数),
+    另一种是在整个程序的流程中可能变化的调用。</para>
+
+    <para>Generally, any place in which a function pointer would be used to
+    defer a call or make a callback, Boost.Function can be used instead to
+    allow the user greater flexibility in the implementation of the target.
+    Targets can be any 'compatible' function object (or function pointer),
+ meaning that the arguments to the interface designated by Boost.Function
+    can be converted to the arguments of the target function
+ object.<sbr/>通常,使用函数指针的任何地方都是用来推迟一个调用或做一个回 调,
+    Boost.Function 可以代替函数指针,允许用户在目标的实现上拥有更大的弹性。
+    目标可以是任何“兼容的”函数对象(或函数指针),这意味着传给接口的参数被
+    Boost.Function 指定为可以转换为目标函数对象的参数。</para>
+  </section>
+
+ <xi:include href="history.xml" xmlns:xi="http://www.w3.org/2001/XInclude"; />
+
+ <xi:include href="tutorial.xml" xmlns:xi="http://www.w3.org/2001/XInclude"; />
+
+ <xi:include href="reference.xml" xmlns:xi="http://www.w3.org/2001/XInclude"; />
+
+  <xi:include href="faq.xml" xmlns:xi="http://www.w3.org/2001/XInclude"; />
+
+  <xi:include href="misc.xml" xmlns:xi="http://www.w3.org/2001/XInclude"; />
+
+ <xi:include href="tests.xml" xmlns:xi="http://www.w3.org/2001/XInclude"; />
 </library>
=======================================
--- /trunk/libs/function/doc/history.xml        Mon Dec 28 23:05:14 2009
+++ /trunk/libs/function/doc/history.xml        Sun Jan  3 19:32:44 2010
@@ -9,7 +9,7 @@
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
   "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd";>
<section id="function.history" last-revision="$Date: 2008-10-16 09:21:50 -0400 (Thu, 16 Oct 2008) $">
-  <title>History &amp; Compatibility Notes</title>
+  <title>History &amp; Compatibility Notes 历史和兼容性注记</title>

 <itemizedlist spacing="compact">

@@ -17,11 +17,17 @@
     <itemizedlist spacing="compact">
       <listitem><para>Improved the performance of Boost.Function's
       swap() operation for large function objects. Original patch
-      contributed by Niels Dekker.</para></listitem>
-
- <listitem><para>Added a new header &lt;boost/function/function_typeof.hpp&gt; that provides support for using the Boost.Typeof library on Boost.Function objects.</para></listitem>
-
- <listitem><para>Added a new header &lt;boost/function/function_fwd.hpp&gt; that provides support for using the Boost.Typeof library on Boost.Function objects.</para></listitem>
+      contributed by Niels Dekker.<sbr/>
+      改进了 Boost.Function 的 swap() 操作对于大的函数对象的性能。
+      最初的补丁贡献自 Niels Dekker.</para></listitem>
+
+ <listitem><para>Added a new header &lt;boost/function/function_typeof.hpp&gt; that provides support for using the Boost.Typeof library on Boost.Function objects.<sbr/>
+      增加新的头文件 &lt;boost/function/function_typeof.hpp&gt;,
+ 提供对 Boost.Function 对象使用 Boost.Typeof 库的支持。 </para></listitem>
+
+ <listitem><para>Added a new header &lt;boost/function/function_fwd.hpp&gt; that provides support for using the Boost.Typeof library on Boost.Function objects.<sbr/>
+      增加新的头文件 &lt;boost/function/function_fwd.hpp&gt;,
+ 提供对 Boost.Function 对象使用 Boost.Typeof 库的支持。 </para></listitem>

<listitem><para>The <methodname alt="boost::function::target">target</methodname>()
       function now respects the cv-qualifiers of function objects
@@ -29,7 +35,11 @@
       (using <classname>boost::reference_wrapper</classname>), such
       that a reference to a <code>const</code> function object cannot
       be accessed as a reference to a non-<code>const</code> function
-      object.</para></listitem>
+      object.<sbr/>
+      <methodname alt="boost::function::target">target</methodname>()
+ 函数现在会关注以引用方式(用 <classname>boost::reference_wrapper</classname>) + 保存的函数对象的cv-限定符,这样,一个 <code>const</code> 函数对象的引 用将不能被当成一个非-
+      <code>const</code> 函数对象的引用来访问。</para></listitem>
     </itemizedlist>
   </listitem>

@@ -45,20 +55,32 @@
       backward-incompatible change, it is likely to affect only a few
       users. This change to Function was contributed by Emil
       Dotchevski, which also authored the corresponding C++ committee
-      proposal.</para></listitem>
+      proposal.<sbr/>
+      Boost.Function 现在实现了与基于 C++ 委员会的建议书
+ <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2308.html";>N2308</ulink> + 的 C++0x 分配器相同方式的分配器。这一变更去掉了 <classname>boost::function</classname> + 的 <computeroutput>Allocator</computeroutput> 模板参数,有利于构造函 数只带一个参数。 + 虽然这是一个后向不兼容的变更,但是它只影响到少量用户。Function 的这一 变更是由 + Emil Dotchevski 贡献的,他也是相应的 C++ 委员会建议书的作者是。 </para></listitem>
     </itemizedlist>
   </listitem>

   <listitem><para><bold>Version 1.34.0</bold>: </para>
     <itemizedlist spacing="compact">
- <listitem><para>Boost.Function now implements a small buffer optimization, which can drastically improve the performance when copying or construction Boost.Function objects storing small function objects. For instance, <code>bind(&amp;X:foo, &amp;x, _1, _2)</code> requires no heap allocation when placed into a Boost.Function object. Note that some exception-safety guarantees have changed: assignment provides the basic exception guarantee and <code>swap()</code> may throw.</para></listitem> + <listitem><para>Boost.Function now implements a small buffer optimization, which can drastically improve the performance when copying or construction Boost.Function objects storing small function objects. For instance, <code>bind(&amp;X:foo, &amp;x, _1, _2)</code> requires no heap allocation when placed into a Boost.Function object. Note that some exception-safety guarantees have changed: assignment provides the basic exception guarantee and <code>swap()</code> may throw.<sbr/> + Boost.Function 现在实现了一个 small buffer optimization(小缓冲优化 ), + 在拷贝或构造存储小函数对象的 Boost.Function 对象时强有力地提升了性 能。 + 例如,<code>bind(&amp;X:foo, &amp;x, _1, _2)</code> 在放入一个 Boost.Function
+      对象时,不再请求堆分配。注意一些反对观点――安全保证被改变:
+ 赋值提供基本的异常保证而且 <code>swap()</code> 可能抛出异常。 </para></listitem>
     </itemizedlist>
   </listitem>

   <listitem><para><bold>Version 1.30.0</bold>: </para>
     <itemizedlist spacing="compact">
       <listitem><para>All features deprecated in version 1.29.0 have
-      been removed from Boost.Function.</para></listitem>
+      been removed from Boost.Function.<sbr/>
+ 版本 1.29.0 中所有被列为反对的特性从 Boost.Function 中移除。 </para></listitem>

       <listitem><para><code><classname>boost::function</classname></code>
       and <code><classname>boost::functionN</classname></code> objects
@@ -67,18 +89,27 @@
       alt="boost::function::clear">clear</methodname>()</code>) and
       compared against 0 (semantically equivalent to calling
       <code><methodname
- alt="boost::function::empty">empty</methodname>()</code>).</para></listitem>
+      alt="boost::function::empty">empty</methodname>()</code>).<sbr/>
+      <code><classname>boost::function</classname></code> 和
+      <code><classname>boost::functionN</classname></code> 可以被赋为 0
+ (语义上等价于调用 <code><methodname alt="boost::function::clear">clear</methodname>()</code>),
+      还可以和 0 进行比较(语义上等价于调用 <code><methodname
+ alt="boost::function::empty">empty</methodname>()</code>)。 </para></listitem>

       <listitem><para>The Boost.Function code is now generated
       entirely by the <libraryname>Preprocessor</libraryname> library,
       so it is now possible to generate
       <code><classname>boost::function</classname></code> and
       <code><classname>boost::functionN</classname></code> class
-      templates for any number of arguments.</para></listitem>
+      templates for any number of arguments.<sbr/>
+ Boost.Function 的代码现在全部由 <libraryname>Preprocessor</libraryname> + 库生成,所以现在为任何参数个数生成 <code><classname>boost::function</classname></code> + 和 <code><classname>boost::functionN</classname></code> 类模板都是有 可能的。</para></listitem>

       <listitem><para>The
       <classname>boost::bad_function_call</classname> exception class
-      was introduced.</para></listitem>
+      was introduced.<sbr/>
+ 引入了 <classname>boost::bad_function_call</classname> 异常类。 </para></listitem>
       </itemizedlist>
   </listitem>

@@ -88,7 +119,10 @@
   features of the older Boost.Function have been deprecated and will
   be removed in the near future. Here is a list of features that have
   been deprecated, the likely impact of the deprecations, and how to
-  adjust your code:
+  adjust your code:<sbr/>
+  Boost.Function 的一部分被重新设计以最小化接口并使它更干净。
+ 几个很少使用或从来不用的旧 Boost.Function 的特性被列为反对并会在不远的将 来被移除。 + 以下是一个列表,列出这些被反对的特性,还有被反对后可能的影响,以及如何调 整你的代码:

 <itemizedlist spacing="compact">
<listitem><para>The <computeroutput>boost::function</computeroutput> class template syntax has
@@ -98,7 +132,12 @@
std::string)&gt;</computeroutput>, where all return and argument types are
   encoded in a single function type parameter. Any other template
parameters (e.g., the <computeroutput>Allocator</computeroutput>) follow this single
-  parameter.</para>
+  parameter.<sbr/>
+  <computeroutput>boost::function</computeroutput> 类模板的语法发生了变化。
+ 老的语法,比如 <computeroutput>boost::function&lt;int, float, double, std::string&gt;</computeroutput>
+  被改变成更自然的语法 boost::function<int (float, double, std::string)>,
+  这里所有的返回和参数类型被编码到一个单独的函数类型参数中。
+ 任何其它模板参数(比如 <computeroutput>Allocator</computeroutput>)跟在这 个单独参数之后。</para>

   <para> The resolution to this change depends on the
   abilities of your compiler: if your compiler supports template
@@ -111,25 +150,40 @@
   use the numbered Boost.Function classes. This option merely requires
changing types such as <computeroutput>boost::function&lt;void, int, int&gt;</computeroutput> to <computeroutput>boost::function2&lt;void, int, int&gt;</computeroutput> (adding the number of
-  function arguments to the end of the class name).</para>
+  function arguments to the end of the class name).<sbr/>
+ 这一改变的决定依赖于你的编译器的能力:如果你的编译器支持模板偏特化并可以 解析函数参数 + (大多数都可以),那就使用新的语法改变你的代码(推荐)或者直接使用那个语 法没有变化的 + <computeroutput>functionN</computeroutput> 类。如果你的编译器不支持模板偏 特化或函数类型, + 你必须使用后一种选择并使用带有编号的 Boost.Function 类。这一选择只不过需 要将类似 + <computeroutput>boost::function&lt;void, int, int&gt;</computeroutput> 的 类型改为
+  <computeroutput>boost::function2&lt;void, int, int&gt;</computeroutput>
+  (在类名的最后增加函数参数的个数)。</para>

   <para> Support for the old syntax with the
<computeroutput>boost::function</computeroutput> class template will persist for a short
   while, but will eventually be removed so that we can provide better
-  error messages and link compatibility. </para></listitem>
+  error messages and link compatibility. <sbr/>
+ <computeroutput>boost::function</computeroutput> 类模板对旧语法的支持会持 续一小段时间, + 但最终会被移除,以便我们可以提供更好的错误信息和连接兼容性。 </para></listitem>

   <listitem><para>The invocation
policy template parameter (<computeroutput>Policy</computeroutput>) has been deprecated
   and will be removed. There is no direct equivalent to this rarely
-  used feature.</para></listitem>
+  used feature.<sbr/>
+ invocation policy 类模板 (<computeroutput>Policy</computeroutput>) 被列为 反对并将被移除。
+  对这一很少使用的特性没有直接的对应物。</para></listitem>

   <listitem><para>The mixin template parameter
(<computeroutput>Mixin</computeroutput>) has been deprecated and will be removed. There
-  is not direct equivalent to this rarely used feature.</para></listitem>
+  is not direct equivalent to this rarely used feature.<sbr/>
+ mixin 模板参数 (<computeroutput>Mixin</computeroutput>) 被列为反对并将被 移除。
+  对这一很少使用的特性没有直接的对应物。</para></listitem>

   <listitem><para>The
<computeroutput>set</computeroutput> methods have been deprecated and will be
-  removed. Use the assignment operator instead.</para></listitem>
+  removed. Use the assignment operator instead.<sbr/>
+  <computeroutput>set</computeroutput> 方法被列为反对并将被移除。
+  使用赋值操作符代替。</para></listitem>
 </itemizedlist>
 </para>
 </listitem>
=======================================
--- /trunk/libs/function/doc/misc.xml   Mon Dec 28 23:05:14 2009
+++ /trunk/libs/function/doc/misc.xml   Sun Jan  3 19:32:44 2010
@@ -9,57 +9,89 @@
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
   "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd";>
<section id="function.misc" last-revision="$Date: 2008-07-14 14:32:29 -0400 (Mon, 14 Jul 2008) $">
-  <title>Miscellaneous Notes</title>
+  <title>Miscellaneous Notes 杂项注记</title>

   <section>
-    <title>Boost.Function vs. Function Pointers</title>
-<para>Boost.Function has several advantages over function pointers, namely:
+ <title>Boost.Function vs. Function Pointers Boost.Function与函数指针比 较</title> +<para>Boost.Function has several advantages over function pointers, namely:<sbr/>
+Boost.Function 有几个超越函数指针的好处,即:

 <itemizedlist spacing="compact">
- <listitem><para>Boost.Function allows arbitrary compatible function objects to be targets (instead of requiring an exact function signature).</para></listitem> - <listitem><para>Boost.Function may be used with argument-binding and other function object construction libraries.</para></listitem> - <listitem><para>Boost.Function has predictible behavior when an empty function object is called. </para></listitem> + <listitem><para>Boost.Function allows arbitrary compatible function objects to be targets (instead of requiring an exact function signature).<sbr/> + Boost.Function 允许任意的兼容函数对象作为目标(而不需要严格的函数识别标 识)。</para></listitem> + <listitem><para>Boost.Function may be used with argument-binding and other function object construction libraries.<sbr/> + Boost.Function 可以和参数绑定及其它函数对象构造库一起使用。 </para></listitem> + <listitem><para>Boost.Function has predictible behavior when an empty function object is called. <sbr/> + 当一个空函数对象被调用时,Boost.Function 有可预期行为。 </para></listitem>
 </itemizedlist></para>

-<para> And, of course, function pointers have several advantages over Boost.Function: +<para> And, of course, function pointers have several advantages over Boost.Function:<sbr/>
+当然,函数指针也有几个超越 Boost.Function 的好处:

 <itemizedlist spacing="compact">
- <listitem><para> Function pointers are smaller (the size of one pointer instead of four or more) </para></listitem> - <listitem><para> Function pointers are faster (Boost.Function may require two calls through function pointers) </para></listitem> - <listitem><para> Function pointers are backward-compatible with C libraries.</para></listitem>
-    <listitem><para> More readable error messages. </para></listitem>
+ <listitem><para> Function pointers are smaller (the size of one pointer instead of four or more) <sbr/>
+    函数指针更小(只有一个指针而不是三个指针的大小)</para></listitem>
+ <listitem><para> Function pointers are faster (Boost.Function may require two calls through function pointers) <sbr/> + 函数指针更快(Boost.Function 可能需要两次通过函数指针的调用 )</para></listitem> + <listitem><para> Function pointers are backward-compatible with C libraries.<sbr/>
+    函数指针可以向后兼容 C 库。</para></listitem>
+    <listitem><para> More readable error messages. <sbr/>
+    更可读的错误信息。</para></listitem>
 </itemizedlist>
 </para>
   </section>

   <section>
-    <title>Performance</title>
+    <title>Performance 性能</title>

 <section>
-  <title>Function object wrapper size</title>
- <para> Function object wrappers will be the size of a struct containing a member function pointer and two data pointers. The actual size can vary significantly depending on the underlying platform; on 32-bit Mac OS X with GCC, this amounts to 16 bytes, while it is 32 bytes Windows with Visual C++. Additionally, the function object target may be allocated on the heap, if it cannot be placed into the small-object buffer in the <code>boost::function</code> object.</para>
+  <title>Function object wrapper size 函数对象包装类的大小</title>
+ <para> Function object wrappers will be the size of a struct containing a member function pointer and two data pointers. The actual size can vary significantly depending on the underlying platform; on 32-bit Mac OS X with GCC, this amounts to 16 bytes, while it is 32 bytes Windows with Visual C++. Additionally, the function object target may be allocated on the heap, if it cannot be placed into the small-object buffer in the <code>boost::function</code> object.<sbr/> + 函数对象包装类相当于一个成员函数指针加上两个数据指针所组成的结构的大小。 实际的大小依据不同的底层平台而有所不同; + 在32位 Mac OS X 的 GCC 上,大小为16字节,而在 Windows 的 Visual C++ 上,则为32字节。 + 另外,函数对象目标可能分配在堆上,如果它不能被放入 <code>boost::function</code> 对象的小对象缓冲区中。</para>
 </section>

 <section>
-  <title>Copying efficiency</title>
- <para> Copying function object wrappers may require allocating memory for a copy of the function object target. The default allocator may be replaced with a faster custom allocator or one may choose to allow the function object wrappers to only store function object targets by reference (using <computeroutput>ref</computeroutput>) if the cost of this cloning becomes prohibitive. Small function objects can be stored within the <code>boost::function</code> object itself, improving copying efficiency.</para>
+  <title>Copying efficiency 拷贝效率</title>
+ <para> Copying function object wrappers may require allocating memory for a copy of the function object target. The default allocator may be replaced with a faster custom allocator or one may choose to allow the function object wrappers to only store function object targets by reference (using <computeroutput>ref</computeroutput>) if the cost of this cloning becomes prohibitive. Small function objects can be stored within the <code>boost::function</code> object itself, improving copying efficiency.<sbr/> + 拷贝函数对象包装类可能需要为函数对象目标的拷贝分配内存。缺省的分配器可以 替换成一个更快的、 + 定制的分配器或者由于这个克隆的成本高得令人望而却步,而可能选择一个允许函 数对象包装类仅仅以引用方式 + (使用 <computeroutput>ref</computeroutput>)存储函数对象目标的方式。小的 函数对象可以被保存在
+  <code>boost::function</code> 对象本身中,以提高复制的效率。
+
+</para>
  </section>

 <section>
-  <title>Invocation efficiency</title>
-<para> With a properly inlining compiler, an invocation of a function object requires one call through a function pointer. If the call is to a free function pointer, an additional call must be made to that function pointer (unless the compiler has very powerful interprocedural analysis).</para>
+  <title>Invocation efficiency 调用效率</title>
+<para> With a properly inlining compiler, an invocation of a function object requires one call through a function pointer. If the call is to a free function pointer, an additional call must be made to that function pointer (unless the compiler has very powerful interprocedural analysis).<sbr/>
+使用一个彻底内联的编译器,对一个函数对象的调用需要一次通过函数指针的调用。
+如果这个调用是一个自由的函数指针,就必须有一次附加的调用以生成这个函数指针
+(除非编译器具有非常强大的)进程间的分析能力。</para>
   </section>
 </section>

   <section>
-    <title>Combatting virtual function "bloat"</title>
-<para> The use of virtual functions tends to cause 'code bloat' on many compilers. When a class contains a virtual function, it is necessary to emit an additional function that classifies the type of the object. It has been our experience that these auxiliary functions increase the size of the executable significantly when many <computeroutput>boost::function</computeroutput> objects are used. </para>
-
-<para> In Boost.Function, an alternative but equivalent approach was taken using free functions instead of virtual functions. The Boost.Function object essentially holds two pointers to make a valid target call: a void pointer to the function object it contains and a void pointer to an "invoker" that can call the function object, given the function pointer. This invoker function performs the argument and return value conversions Boost.Function provides. A third pointer points to a free function called the "manager", which handles the cloning and destruction of function objects. The scheme is typesafe because the only functions that actually handle the function object, the invoker and the manager, are instantiated given the type of the function object, so they can safely cast the incoming void pointer (the function object pointer) to the appropriate type.</para>
+    <title>Combatting virtual function "bloat" 阻止虚拟函数“膨胀”</title>
+<para> The use of virtual functions tends to cause 'code bloat' on many compilers. When a class contains a virtual function, it is necessary to emit an additional function that classifies the type of the object. It has been our experience that these auxiliary functions increase the size of the executable significantly when many <computeroutput>boost::function</computeroutput> objects are used. <sbr/>
+在很多编译器上虚拟函数的使用趋向于代码膨胀。当一个类包含一个虚拟函数值,
+它必须发行一个额外的函数将对象的类型分类。根据我们的经验,当使用了很多
+<computeroutput>boost::function</computeroutput> 对象时,
+这些辅助函数对于可执行代码大小的增加是值得注意的。</para>
+
+<para> In Boost.Function, an alternative but equivalent approach was taken using free functions instead of virtual functions. The Boost.Function object essentially holds two pointers to make a valid target call: a void pointer to the function object it contains and a void pointer to an "invoker" that can call the function object, given the function pointer. This invoker function performs the argument and return value conversions Boost.Function provides. A third pointer points to a free function called the "manager", which handles the cloning and destruction of function objects. The scheme is typesafe because the only functions that actually handle the function object, the invoker and the manager, are instantiated given the type of the function object, so they can safely cast the incoming void pointer (the function object pointer) to the appropriate type.<sbr/>
+在 Boost.Function 中,一个可选且有效的方法是使用自由函数代替虚拟函数。
+Boost.Function 对象实际上持有两个指针做一次合法的目标调用:
+一个指向它所包含的函数对象的 void 指针和一个指向可以调用这个函数对象的“调用 者”的 void 指针,
+它给出函数指针。这个调用者函数执行 Boost.Function 提供的参数和返回值转换。
+第三个指针指向一个被称为“管理者”的函数,它处理函数对象的克隆和析构。
+这个方案是类型安全的,因为只有实际处理函数对象的函数(调用者和管理者),
+被给定的函数对象类型实例化,所以它们可以安全地将输入的 void 指针(函数对象 指针)转型为适当的类型。</para>
   </section>

   <section>
-    <title>Acknowledgements</title>
+    <title>Acknowledgements 鸣谢</title>

     <para> Many people were involved in the construction of this
     library. William Kempf, Jesse Jones and Karl Nelson were all
@@ -67,6 +99,10 @@
     library. John Maddock managed the formal review, and many
     reviewers gave excellent comments on interface, implementation,
     and documentation. Peter Dimov led us to the function
-    declarator-based syntax.</para>
+    declarator-based syntax.<sbr/>
+    很多人投身于此库的构建。William Kempf,Jesse Jones 和 Karl Nelson
+    在隔绝此库的接口和范围中给予极大的帮助。John Maddock 主持了正式评审,
+    很多详审参与者给出了关于接口,实现和文档的极好的意见。
+ Peter Dimov 引导我们走向 function declarator-based(基于函数声明符)的 语法。</para>
   </section>
 </section>
=======================================
--- /trunk/libs/function/doc/reference.xml      Mon Dec 28 23:05:14 2009
+++ /trunk/libs/function/doc/reference.xml      Sun Jan  3 19:32:44 2010
@@ -12,7 +12,7 @@
<library-reference id="function.reference" last-revision="$Date: 2008-07-14 14:32:29 -0400 (Mon, 14 Jul 2008) $">

 <section id="function.definitions">
-  <title>Definitions</title>
+  <title>Definitions 定义</title>
 <para>
   <itemizedlist>
     <listitem>
@@ -22,7 +22,12 @@
       <computeroutput>Arg2</computeroutput>, ...,
       <computeroutput>ArgN</computeroutput> and a
       return type <computeroutput>ResultType</computeroutput>, the
-      appropriate following function is well-formed:
+      appropriate following function is well-formed:<sbr/>
+      如果对于给定的一套参数类型 <computeroutput>Arg1</computeroutput>,
+ <computeroutput>Arg2</computeroutput>, ..., <computeroutput>ArgN</computeroutput> + 和返回类型 <computeroutput>ResultType</computeroutput>,适合于以下形 式,
+      则可以说这个函数对象 f 是 compatible(兼容)的:
+
 <programlisting>
<emphasis>// if ResultType is not <emphasis role="bold">void</emphasis></emphasis> ResultType foo(Arg1 arg1, Arg2 arg2, ..., Arg<emphasis>N</emphasis> arg<emphasis>N</emphasis>)
@@ -44,7 +49,12 @@
       (X::*mf)(Arg1, Arg2, ..., ArgN)
       cv-quals</code> be adapted to a
       function object with the following function call operator
-      overloads:
+      overloads:<sbr/>
+      对指向成员函数的指针有一条特殊的规定。尽管它们不是函数对象,
+      Boost.Function 也可以在内部将它们调整为函数对象。
+ 这要求这个指针指向的形式为 <code>R (X::*mf)(Arg1, Arg2, ..., ArgN) cv-quals</code>
+      的成员函数适合于带有如下函数调用操作符重载的函数对象:
+
 <programlisting>
<emphasis role="bold">template</emphasis>&lt;<emphasis role="bold">typename P</emphasis>&gt; R <emphasis role="bold">operator</emphasis>()(<emphasis>cv-quals</emphasis> P&amp; x, Arg1 arg1, Arg2 arg2, ..., Arg<emphasis>N</emphasis> arg<emphasis>N</emphasis>) <emphasis role="bold">const</emphasis>
@@ -61,7 +71,12 @@
       <code><classname>boost::is_stateless</classname>&lt;T&gt;</code>
       is true. The construction of or copy to a Boost.Function object
       from a stateless function object will not cause exceptions to be
-      thrown and will not allocate any storage.
+      thrown and will not allocate any storage.<sbr/>
+ 如果一个类型为 <code>F</code> 的函数对象 <code>f</code> 是一个函数指 针或者 + <code><classname>boost::is_stateless</classname>&lt;T&gt;</code> 为 true,
+      则这个函数对象是 <emphasis>stateless</emphasis> 的。一个 stateless
+ 函数对象的构造函数,或者将 stateless 函数对象拷贝到 Boost.Function 对 象中,
+      都不会抛出异常,而且不分配任何存储空间。
       </para>
     </listitem>
   </itemizedlist>
@@ -72,22 +87,26 @@
 <namespace name="boost">
   <class name="bad_function_call">
<inherit access="public"><classname>std::runtime_error</classname></inherit> - <purpose>An exception type thrown when an instance of a <code>function</code> object is empty when invoked.</purpose> + <purpose>An exception type thrown when an instance of a <code>function</code> object is empty when invoked.<sbr/> + 如果一个 <code>function</code> 对象的实例是空的,调用时就会抛出这个类型 的异常。</purpose>
     <constructor>
- <effects><simpara>Constructs a <code><classname>bad_function_call</classname></code> exception object.</simpara></effects> + <effects><simpara>Constructs a <code><classname>bad_function_call</classname></code> exception object.<sbr/> + 构造一个 <code><classname>bad_function_call</classname></code> 异常对 象。</simpara></effects>
     </constructor>
   </class>

   <class name="function_base">
     <purpose>The common base class for all Boost.Function
     objects. Objects of type function_base may not be created
-    directly.</purpose>
+    directly.<sbr/>
+ 所有 Boost.Function 对象的共通基类。不可以直接创建类型 function_base 的 对象。</purpose>

     <method-group name="capacity">
       <method name="empty" cv="const">
         <type>bool</type>
- <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.<sbr/> + 如果 <code>this</code> 有一个目标,则返回 <code>false</code>,否 则,返回 <code>true</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>
     </method-group>

@@ -109,9 +128,11 @@
         <returns><simpara>If <code>this</code> stores a target of type
         <code>Functor</code>, returns the address of the
         target. Otherwise, returns the NULL
-        pointer.</simpara></returns>
-
-        <throws><simpara>Will not throw.</simpara></throws>
+        pointer.<sbr/>
+        如果 <code>this</code> 存储一个类型 <code>Functor</code> 的目标,
+        则返回目标的地址。否则,返回 NULL 指针。</simpara></returns>
+
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </overloaded-method>

       <method name="contains" cv="const">
@@ -122,14 +143,19 @@
         <parameter name="f">
           <paramtype>const Functor&amp;</paramtype>
         </parameter>
- <returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code></simpara></returns> + <returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code><sbr/> + 如果 <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> 是非 NULL 的并且 + <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code>,
+        则返回 <code>true</code>。 </simpara></returns>

       </method>

       <method name="target_type" cv="const">
         <type>const std::type_info&amp;</type>
- <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.<sbr/> + 目标函数对象的 <code>typeid</code>,或者,如果 <code>this-&gt;<methodname>empty</methodname>()</code>,
+        返回 <code>typeid(void)</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>
     </method-group>
   </class>
@@ -145,7 +171,8 @@

     <inherit access="public"><classname>function_base</classname></inherit>

- <purpose>A set of generalized function pointers that can be used for callbacks or wrapping function objects.</purpose> + <purpose>A set of generalized function pointers that can be used for callbacks or wrapping function objects.<sbr/>
+    一组可以用于回调或包装函数对象的泛化的函数指针。</purpose>

     <description>
       <para>Class template <classname>functionN</classname> is
@@ -153,7 +180,10 @@
       alt="functionN">function0</classname>, <classname
       alt="functionN">function1</classname>, etc., up to some
       implementation-defined maximum. In this context, <code>N</code>
-      refers to the number of parameters.</para>
+      refers to the number of parameters.<sbr/>
+ 类模板 <classname>functionN</classname> 实际上是相关类 <classname alt="functionN">function0</classname>, + <classname alt="functionN">function1</classname> 等的一个家族,一直到 某个由实现定义的最大值。
+      在这里的上下文中,<code>N</code> 表示参数个数。</para>
     </description>

     <typedef name="result_type"><type>R</type></typedef>
@@ -184,7 +214,8 @@
       </template>

       <purpose>
- <simpara><libraryname>Lambda</libraryname> library support</simpara>
+        <simpara><libraryname>Lambda</libraryname> library support<sbr/>
+        <libraryname>Lambda</libraryname> 库的支持</simpara>
       </purpose>

       <typedef name="type"><type>result_type</type></typedef>
@@ -192,15 +223,18 @@

     <constructor>
<postconditions><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></postconditions>
-      <throws><simpara>Will not throw.</simpara></throws>
+      <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
     </constructor>

     <constructor>
       <parameter name="f">
         <paramtype>const <classname>functionN</classname>&amp;</paramtype>
       </parameter>
- <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.</simpara></postconditions> - <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.</simpara></throws> + <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.<sbr/> + 如果 <code>f</code> 有一个目标,则包含 <code>f</code> 的目标的一个拷 贝,或者, + 如果 <code>f.<methodname>empty</methodname>()</code>,则为空。 </simpara></postconditions> + <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.<sbr/> + 不会抛出异常,除非拷贝 <code>f</code> 的目标时抛出。 </simpara></throws>
     </constructor>

     <constructor>
@@ -208,8 +242,11 @@
         <template-type-parameter name="F"/>
       </template>
       <parameter name="f"><paramtype>F</paramtype></parameter>
- <requires><simpara>F is a function object Callable from <code>this</code>.</simpara></requires> - <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions> + <requires><simpara>F is a function object Callable from <code>this</code>.<sbr/>
+      F 是一个可由 <code>this</code> 调用的函数对象。</simpara></requires>
+ <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.<sbr/> + 如果 <code>f</code> 非空,则 <code>*this</code> 以 <code>f</code> 的 一个拷贝为目标,或者, + 如果 <code>f</code> 为空,则 <code>this-&gt;<methodname>empty</methodname>()</code>。 </simpara></postconditions>
     </constructor>

     <constructor>
@@ -219,14 +256,19 @@
       </template>
       <parameter name="f"><paramtype>F</paramtype></parameter>
       <parameter name="alloc"><paramtype>Allocator</paramtype></parameter>
- <requires><simpara>F is a function object Callable from <code>this</code>, Allocator is an allocator. The copy constructor and destructor of Allocator shall not throw.</simpara></requires> - <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions>
-
- <effects><simpara>If memory allocation is required, the given allocator (or a copy of it) will be used to allocate that memory.</simpara></effects> + <requires><simpara>F is a function object Callable from <code>this</code>, Allocator is an allocator. The copy constructor and destructor of Allocator shall not throw.<sbr/> + F 是一个可以从 <code>this</code> 调用的函数对象,Allocator 是一个分配 器。
+      Allocator 的复制构造函数和析构函数不能抛出异常。</simpara></requires>
+ <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.<sbr/> + 如果 <code>f</code> 非空,则 <code>*this</code> 以 <code>f</code> 的 一个拷贝为目标,或者, + 如果 <code>f</code> 为空,则 <code>this-&gt;<methodname>empty</methodname>()</code>。 </simpara></postconditions> + <effects><simpara>If memory allocation is required, the given allocator (or a copy of it) will be used to allocate that memory.<sbr/> + 如果需要分配内存,则给定的分配器(或它的一份拷贝)将被用于分配内存。 </simpara></effects>
     </constructor>

     <destructor>
- <effects><simpara>If <code>!this-&gt;<methodname>empty</methodname>()</code>, destroys the target of this.</simpara></effects> + <effects><simpara>If <code>!this-&gt;<methodname>empty</methodname>()</code>, destroys the target of this.<sbr/> + 如果 <code>!this-&gt;<methodname>empty</methodname>()</code>,销毁 this 的目标。</simpara></effects>

     </destructor>

@@ -234,14 +276,18 @@
       <parameter name="f">
         <paramtype>const <classname>functionN</classname>&amp;</paramtype>
       </parameter>
- <postconditions><simpara>If copy construction does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></postconditions> + <postconditions><simpara>If copy construction does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.<sbr/> + 如果拷贝构造不抛出异常,如果 <code>f</code> 有一个目标,则 <code>*this</code> 以 <code>f</code> 的目标的拷贝为目标, + 或者,如果 <code>f.<methodname>empty</methodname>()</code>,则为空。 如果拷贝构造抛出异常, + 则 <code>this-&gt;<methodname>empty</methodname>()</code>。 </simpara></postconditions>
     </copy-assignment>

     <method-group name="modifiers">
       <method name="swap">
         <type>void</type>
<parameter name="f"><paramtype>const <classname>functionN</classname>&amp;</paramtype></parameter> - <effects><simpara>Interchanges the targets of <code>*this</code> and <code>f</code>.</simpara></effects> + <effects><simpara>Interchanges the targets of <code>*this</code> and <code>f</code>.<sbr/> + 交换 <code>*this</code> 的目标和 <code>f</code>。 </simpara></effects>
       </method>

       <method name="clear">
@@ -253,20 +299,24 @@
     <method-group name="capacity">
       <method name="empty" cv="const">
         <type>bool</type>
- <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.<sbr/> + 如果 <code>this</code> 有一个目标,则为 <code>false</code>,否 则,为 <code>true</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>

       <method name="conversion-operator" cv="const">
         <type>safe_bool</type>
- <returns><simpara>A <code>safe_bool</code> that evaluates <code>false</code> in a boolean context when <code>this-&gt;<methodname>empty</methodname>()</code>, and <code>true</code> otherwise.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara>A <code>safe_bool</code> that evaluates <code>false</code> in a boolean context when <code>this-&gt;<methodname>empty</methodname>()</code>, and <code>true</code> otherwise.<sbr/> + 当 <code>this-&gt;<methodname>empty</methodname>()</code> 时,为一 个在布尔上下文中求值为 + <code>false</code> 的 <code>safe_bool</code>,否则,为求值为 <code>true</code> 的
+        <code>safe_bool</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>

       <method name="operator!" cv="const">
         <type>bool</type>
<returns><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>
     </method-group>

@@ -288,9 +338,11 @@
         <returns><simpara>If <code>this</code> stores a target of type
         <code>Functor</code>, returns the address of the
         target. Otherwise, returns the NULL
-        pointer.</simpara></returns>
-
-        <throws><simpara>Will not throw.</simpara></throws>
+        pointer.<sbr/>
+        如果 <code>this</code> 存储一个类型为 <code>Functor</code> 的目标,
+        则返回目标的地址。否则,返回 NULL 指针。</simpara></returns>
+
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </overloaded-method>

       <method name="contains" cv="const">
@@ -301,14 +353,19 @@
         <parameter name="f">
           <paramtype>const Functor&amp;</paramtype>
         </parameter>
- <returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code></simpara></returns> + <returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code><sbr/> + 如果 <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> 为非 NULL, + 而且 <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code>,
+        则为 <code>true</code>。</simpara></returns>

       </method>

       <method name="target_type" cv="const">
         <type>const std::type_info&amp;</type>
- <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.<sbr/> + target function object(目标函数对象)的 <code>typeid</code>,或 者, + 如果 <code>this-&gt;<methodname>empty</methodname>()</code>,则为 <code>typeid(void)</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>

     </method-group>
@@ -320,9 +377,14 @@
         <parameter name="a2"><paramtype>arg2_type</paramtype></parameter>
         <parameter><paramtype>...</paramtype></parameter>
         <parameter name="aN"><paramtype>argN_type</paramtype></parameter>
- <effects><simpara><code>f(a1, a2, ..., aN)</code>, where <code>f</code> is the target of <code>*this</code>.</simpara></effects> - <returns><simpara>if <code>R</code> is <code>void</code>, nothing is returned; otherwise, the return value of the call to <code>f</code> is returned.</simpara></returns> - <throws><simpara><code><classname>bad_function_call</classname></code> if <code>this-&gt;<methodname>empty</methodname>()</code>. Otherwise, may through any exception thrown by the target function <code>f</code>.</simpara></throws> + <effects><simpara><code>f(a1, a2, ..., aN)</code>, where <code>f</code> is the target of <code>*this</code>.<sbr/> + <code>f(a1, a2, ..., aN)</code>,其中 <code>f</code> 为 <code>*this</code> 的目标。</simpara></effects> + <returns><simpara>if <code>R</code> is <code>void</code>, nothing is returned; otherwise, the return value of the call to <code>f</code> is returned.<sbr/> + 如果 <code>R</code> 为 <code>void</code>,什么都不返回,否则,为调 用 <code>f</code> 时的返回值。</simpara></returns> + <throws><simpara><code><classname>bad_function_call</classname></code> if <code>this-&gt;<methodname>empty</methodname>()</code>. Otherwise, may through any exception thrown by the target function <code>f</code>.<sbr/>
+        如果 <code>this-&gt;<methodname>empty</methodname>()</code>,则抛出
+        <code><classname>bad_function_call</classname></code>。
+ 否则,为目标函数 <code>f</code> 所可能抛出的任何异常。 </simpara></throws>
       </method>
     </method-group>

@@ -408,33 +470,45 @@
         </signature>

         <returns><simpara>True when <code>f</code> stores an object of
- type <code>Functor</code> and one of the following conditions applies: + type <code>Functor</code> and one of the following conditions applies:<sbr/> + 当 <code>f</code> 存储了一个类型为 <code>Functor</code> 的对象,而 且满足下列条件之一时,为 true:
           <itemizedlist>

             <listitem><simpara><code>g</code> is of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
             and <code>f.target&lt;Functor&gt;() == g.<methodname
- alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem> + alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.<sbr/> + <code>g</code> 的类型是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>,
+            而且,<code>f.target&lt;Functor&gt;() == g.<methodname
+ alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>。 </simpara></listitem>

             <listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
             and
<code><functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()),
-            g)</code>.</simpara></listitem>
+            g)</code>.<sbr/>
+ <code>g</code> 的类型不是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>, + 而 且,<code><functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()),
+            g)</code>。</simpara></listitem>

           </itemizedlist>
           </simpara></returns>

         <notes><simpara><code><classname>functionN</classname></code>
         objects are not
-        <conceptname>EqualityComparable</conceptname>.</simpara></notes>
+        <conceptname>EqualityComparable</conceptname>.<sbr/>
+        <code><classname>functionN</classname></code> 对象不是
+ <conceptname>EqualityComparable</conceptname>(可等值比较)的。 </simpara></notes>

         <rationale><simpara>The <code>safe_bool</code> conversion
         opens a loophole whereby two <code>functionN</code>
         instances can be compared via <code>==</code>, although this
         is not feasible to implement. The undefined <code>void
         operator==</code> closes the loophole and ensures a
-        compile-time or link-time error.</simpara></rationale>
+        compile-time or link-time error.<sbr/>
+ <code>safe_bool</code> 转换打开一个漏洞,使得两个 <code>functionN</code> + 实例可以通过 <code>==</code> 进行比较,尽管对于实现来说这是不可行 的。 + 未定义的 <code>void operator==</code> 封闭这个漏洞并确保一个编译时 或连接时错误。</simpara></rationale>
       </overloaded-function>

       <overloaded-function name="operator!=">
@@ -505,31 +579,43 @@
         <returns><simpara>True when <code>f</code> does not store an
         object of type <code>Functor</code> or it stores an object of
         type <code>Functor</code> and one of the following conditions
-        applies:
+        applies:<sbr/>
+        当 <code>f</code> 没有存储一个类型为 <code>Functor</code>
+ 的对象时或者它存储一个类型为 <code>Functor</code> 的对象并满足下列 条件之一时,为 true:
           <itemizedlist>

             <listitem><simpara><code>g</code> is of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
             and <code>f.target&lt;Functor&gt;() != g.<methodname
- alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem> + alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.<sbr/> + <code>g</code> 的类型是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>,
+            而且 <code>f.target&lt;Functor&gt;() != g.<methodname
+ alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>。 </simpara></listitem>

             <listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code> - and <code>!<functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem> + and <code>!<functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.<sbr/> + <code>g</code> 的类型不是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>, + 而且 <code>!<functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()), g)</code>。</simpara></listitem>

           </itemizedlist>
           </simpara></returns>

         <notes><simpara><code><classname>functionN</classname></code>
         objects are not
-        <conceptname>EqualityComparable</conceptname>.</simpara></notes>
+        <conceptname>EqualityComparable</conceptname>.<sbr/>
+        <code><classname>functionN</classname></code> 对象不是
+ <conceptname>EqualityComparable</conceptname>(可等值比较)的。 </simpara></notes>

         <rationale><simpara>The <code>safe_bool</code> conversion
         opens a loophole whereby two <code>functionN</code>
         instances can be compared via <code>!=</code>, although this
         is not feasible to implement. The undefined <code>void
         operator!=</code> closes the loophole and ensures a
-        compile-time or link-time error.</simpara></rationale>
+        compile-time or link-time error.<sbr/>
+ <code>safe_bool</code> 转换打开一个漏洞,使得两个 <code>functionN</code> + 实例可以通过 <code>!=</code> 进行比较,尽管对于实现来说这是不可行 的。 + 未定义的 <code>void operator!=</code> 封闭这个漏洞并确保一个编译时 或连接时错误。</simpara></rationale>
       </overloaded-function>
     </free-function-group>
   </class>
@@ -543,7 +629,8 @@
<inherit access="public"><classname>functionN</classname>&lt;R, T1, T2, ..., TN&gt;</inherit>

     <purpose>A generalized function pointer that can be used for
-    callbacks or wrapping function objects.</purpose>
+    callbacks or wrapping function objects.<sbr/>
+    一个可以用于回调或包装函数对象的泛化的函数指针。</purpose>

     <description>
       <para>Class template <classname>function</classname> is a thin
@@ -552,13 +639,20 @@
       alt="functionN">function1</classname>, etc. It accepts a
       function type with N arguments and will will derive from
       <classname>functionN</classname> instantiated with the arguments
-      it receives.</para>
+      it receives.<sbr/>
+      类模板 <classname>function</classname> 是包围在带编号的类模板
+ <classname alt="functionN">function0</classname>, <classname alt="functionN">function1</classname>
+      等外面的一层薄薄的包装。它接受一个带有 N 个参数的函数类型,
+ 并从被它所接收的参数实例化的 <classname>functionN</classname> 继承。 </para>

       <para>The semantics of all operations in class template
       <classname>function</classname> are equivalent to that of the
       underlying <classname>functionN</classname> object, although
       additional member functions are required to allow proper copy
-      construction and copy assignment of function objects.</para>
+      construction and copy assignment of function objects.<sbr/>
+ 在类模板 <classname>function</classname> 上的所有操作的语义都等价于在 下层的
+      <classname>functionN</classname> 对象上的同样操作,
+ 尽管需要额外的成员函数以允许函数对象的特有的拷贝构造和拷贝赋值。 </para>
     </description>

     <typedef name="result_type"><type>R</type></typedef>
@@ -589,7 +683,8 @@
       </template>

       <purpose>
- <simpara><libraryname>Lambda</libraryname> library support</simpara>
+        <simpara><libraryname>Lambda</libraryname> library support<sbr/>
+        <libraryname>Lambda</libraryname> 库的支持</simpara>
       </purpose>

       <typedef name="type"><type>result_type</type></typedef>
@@ -597,23 +692,29 @@

     <constructor>
<postconditions><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></postconditions>
-      <throws><simpara>Will not throw.</simpara></throws>
+      <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
     </constructor>

     <constructor>
       <parameter name="f">
         <paramtype>const <classname>functionN</classname>&amp;</paramtype>
       </parameter>
- <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.</simpara></postconditions> - <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.</simpara></throws> + <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.<sbr/> + 如果 <code>f</code> 有一个目标,则包含 <code>f</code> 的目标的一个拷 贝,或者, + 如果 <code>f.<methodname>empty</methodname>()</code>,则为空。 </simpara></postconditions> + <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.<sbr/> + 不会抛出异常,除非拷贝 <code>f</code> 的目标时抛出。 </simpara></throws>
     </constructor>

     <constructor>
       <parameter name="f">
         <paramtype>const <classname>function</classname>&amp;</paramtype>
       </parameter>
- <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.</simpara></postconditions> - <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.</simpara></throws> + <postconditions><simpara>Contains a copy of the <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>.<sbr/> + 如果 <code>f</code> 有一个目标,则包含 <code>f</code> 的目标的一个拷 贝,或者, + 如果 <code>f.<methodname>empty</methodname>()</code>,则为空。 </simpara></postconditions> + <throws><simpara>Will not throw unless copying the target of <code>f</code> throws.<sbr/> + 不会抛出异常,除非拷贝 <code>f</code> 的目标时抛出。 </simpara></throws>
     </constructor>

     <constructor>
@@ -621,8 +722,11 @@
         <template-type-parameter name="F"/>
       </template>
       <parameter name="f"><paramtype>F</paramtype></parameter>
- <requires><simpara>F is a function object Callable from <code>this</code>.</simpara></requires> - <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions> + <requires><simpara>F is a function object Callable from <code>this</code>.<sbr/>
+      F 是一个可由 <code>this</code> 调用的函数对象。</simpara></requires>
+ <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.<sbr/> + 如果 <code>f</code> 非空,则 <code>*this</code> 以 <code>f</code> 的 一个拷贝为目标,或者, + 如果 <code>f</code> 为空,则 <code>this-&gt;<methodname>empty</methodname>()</code>。 </simpara></postconditions>
     </constructor>

     <constructor>
@@ -632,14 +736,19 @@
       </template>
       <parameter name="f"><paramtype>F</paramtype></parameter>
       <parameter name="alloc"><paramtype>Allocator</paramtype></parameter>
- <requires><simpara>F is a function object Callable from <code>this</code>, Allocator is an allocator. The copy constructor and destructor of Allocator shall not throw.</simpara></requires> - <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.</simpara></postconditions>
-
- <effects><simpara>If memory allocation is required, the given allocator (or a copy of it) will be used to allocate that memory.</simpara></effects> + <requires><simpara>F is a function object Callable from <code>this</code>, Allocator is an allocator. The copy constructor and destructor of Allocator shall not throw.<sbr/> + F 是一个可以从 <code>this</code> 调用的函数对象,Allocator 是一个分配 器。
+      Allocator 的复制构造函数和析构函数不能抛出异常。</simpara></requires>
+ <postconditions><simpara><code>*this</code> targets a copy of <code>f</code> if <code>f</code> is nonempty, or <code>this-&gt;<methodname>empty</methodname>()</code> if <code>f</code> is empty.<sbr/> + 如果 <code>f</code> 非空,则 <code>*this</code> 以 <code>f</code> 的 一个拷贝为目标,或者, + 如果 <code>f</code> 为空,则 <code>this-&gt;<methodname>empty</methodname>()</code>。 </simpara></postconditions> + <effects><simpara>If memory allocation is required, the given allocator (or a copy of it) will be used to allocate that memory.<sbr/> + 如果需要分配内存,则给定的分配器(或它的一份拷贝)将被用于分配内存。 </simpara></effects>
     </constructor>

     <destructor>
- <effects><simpara>If <code>!this-&gt;<methodname>empty</methodname>()</code>, destroys the target of <code>this</code>.</simpara></effects> + <effects><simpara>If <code>!this-&gt;<methodname>empty</methodname>()</code>, destroys the target of <code>this</code>.<sbr/> + 如果 <code>!this-&gt;<methodname>empty</methodname>()</code>,销毁 <code>this</code> 的目标。</simpara></effects>

     </destructor>

@@ -647,48 +756,59 @@
       <parameter name="f">
         <paramtype>const <classname>function</classname>&amp;</paramtype>
       </parameter>
- <postconditions><simpara>If copy construction does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></postconditions> + <postconditions><simpara>If copy construction does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.<sbr/> + 如果拷贝构造不抛出异常,如果 <code>f</code> 有一个目标,则 <code>*this</code> 以 <code>f</code> 的目标的拷贝为目标, + 或者,如果 <code>f.<methodname>empty</methodname>()</code>,则为空。 如果拷贝构造抛出异常, + 则 <code>this-&gt;<methodname>empty</methodname>()</code>。 </simpara></postconditions>
     </copy-assignment>

     <copy-assignment>
       <parameter name="f">
         <paramtype>const <classname>function</classname>&amp;</paramtype>
       </parameter>
- <postconditions><simpara>If copy construction of the target of <code>f</code> does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. </simpara></postconditions> - <throws><simpara>Will not throw when the target of <code>f</code> is a stateless function object or a reference to the function object. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></throws> + <postconditions><simpara>If copy construction of the target of <code>f</code> does not throw, <code>*this</code> targets a copy of <code>f</code>'s target, if it has one, or is empty if <code>f.<methodname>empty</methodname>()</code>. <sbr/> + 如果拷贝构造不抛出异常,如果 <code>f</code> 有一个目标,则 <code>*this</code> 以 <code>f</code> 的目标的拷贝为目标, + 或者,如果 <code>f.<methodname>empty</methodname>()</code>,则为空。 如果拷贝构造抛出异常, + 则 <code>this-&gt;<methodname>empty</methodname>()</code>。 </simpara></postconditions> + <throws><simpara>Will not throw when the target of <code>f</code> is a stateless function object or a reference to the function object. If copy construction does throw, <code>this-&gt;<methodname>empty</methodname>()</code>.<sbr/> + 当 f 的目标是一个 stateless 函数对象或者是一个引向函数对象的引用,则 不抛出异常。</simpara></throws>
     </copy-assignment>

     <method-group name="modifiers">
       <method name="swap">
         <type>void</type>
<parameter name="f"><paramtype>const <classname>function</classname>&amp;</paramtype></parameter> - <effects><simpara>Interchanges the targets of <code>*this</code> and <code>f</code>.</simpara></effects> + <effects><simpara>Interchanges the targets of <code>*this</code> and <code>f</code>.<sbr/> + 交换 <code>*this</code> 的目标和 <code>f</code>。 </simpara></effects>
       </method>

       <method name="clear">
         <type>void</type>
<postconditions><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></postconditions>
-        <throws><simpara>Will not throw.</simpara></throws>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>
     </method-group>

     <method-group name="capacity">
       <method name="empty" cv="const">
         <type>bool</type>
- <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara><code>false</code> if <code>this</code> has a target, and <code>true</code> otherwise.<sbr/> + 如果 <code>this</code> 有一个目标,则为 <code>false</code>,否 则,为 <code>true</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>

       <method name="conversion-operator" cv="const">
         <type>safe_bool</type>
- <returns><simpara>A <code>safe_bool</code> that evaluates <code>false</code> in a boolean context when <code>this-&gt;<methodname>empty</methodname>()</code>, and <code>true</code> otherwise.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara>A <code>safe_bool</code> that evaluates <code>false</code> in a boolean context when <code>this-&gt;<methodname>empty</methodname>()</code>, and <code>true</code> otherwise.<sbr/> + 当 <code>this-&gt;<methodname>empty</methodname>()</code> 时,为一 个在布尔上下文中求值为 <code>false</code> + 的 <code>safe_bool</code>,否则,为求值为 <code>true</code> 的 <code>safe_bool</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>

       <method name="operator!" cv="const">
         <type>bool</type>
<returns><simpara><code>this-&gt;<methodname>empty</methodname>()</code></simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>
     </method-group>

@@ -710,8 +830,10 @@
         <returns><simpara>If <code>this</code> stores a target of type
         <code>Functor</code>, returns the address of the
         target. Otherwise, returns the NULL
-        pointer.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+        pointer.<sbr/>
+        如果 <code>this</code> 存储一个类型为 <code>Functor</code> 的目标,
+        则返回目标的地址。否则,返回 NULL 指针。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </overloaded-method>

       <method name="contains" cv="const">
@@ -722,14 +844,19 @@
         <parameter name="f">
           <paramtype>const Functor&amp;</paramtype>
         </parameter>
- <returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code></simpara></returns> + <returns><simpara><code>true</code> if <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> is non-NULL and <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code><sbr/> + 如果 <code>this-&gt;<methodname>target</methodname>&lt;Functor&gt;()</code> 为非 NULL, + 而且 <code><functionname>function_equal</functionname>(*(this-&gt;target&lt;Functor&gt;()), f)</code>,
+        则为 <code>true</code>。</simpara></returns>

       </method>

       <method name="target_type" cv="const">
         <type>const std::type_info&amp;</type>
- <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.</simpara></returns>
-        <throws><simpara>Will not throw.</simpara></throws>
+ <returns><simpara><code>typeid</code> of the target function object, or <code>typeid(void)</code> if <code>this-&gt;<methodname>empty</methodname>()</code>.<sbr/> + target function object(目标函数对象)的 <code>typeid</code>,或 者,如果 + <code>this-&gt;<methodname>empty</methodname>()</code>,则为 <code>typeid(void)</code>。</simpara></returns>
+        <throws><simpara>will not throw<sbr/>不抛出异常</simpara></throws>
       </method>
     </method-group>

@@ -740,9 +867,14 @@
         <parameter name="a2"><paramtype>arg2_type</paramtype></parameter>
         <parameter><paramtype>...</paramtype></parameter>
         <parameter name="aN"><paramtype>argN_type</paramtype></parameter>
- <effects><simpara><code>f(a1, a2, ..., aN)</code>, where <code>f</code> is the target of <code>*this</code>.</simpara></effects> - <returns><simpara>if <code>R</code> is <code>void</code>, nothing is returned; otherwise, the return value of the call to <code>f</code> is returned.</simpara></returns> - <throws><simpara><code><classname>bad_function_call</classname></code> if <code>this-&gt;<methodname>empty</methodname>()</code>. Otherwise, may through any exception thrown by the target function <code>f</code>.</simpara></throws> + <effects><simpara><code>f(a1, a2, ..., aN)</code>, where <code>f</code> is the target of <code>*this</code>.<sbr/> + <code>f(a1, a2, ..., aN)</code>,其中 <code>f</code> 为 <code>*this</code> 的目标。</simpara></effects> + <returns><simpara>if <code>R</code> is <code>void</code>, nothing is returned; otherwise, the return value of the call to <code>f</code> is returned.<sbr/> + 如果 <code>R</code> 为 <code>void</code>,什么都不返回,否则,为调 用 <code>f</code> 时的返回值。</simpara></returns> + <throws><simpara><code><classname>bad_function_call</classname></code> if <code>this-&gt;<methodname>empty</methodname>()</code>. Otherwise, may through any exception thrown by the target function <code>f</code>.<sbr/>
+        如果 <code>this-&gt;<methodname>empty</methodname>()</code>,则抛出
+        <code><classname>bad_function_call</classname></code>。
+ 否则,为目标函数 <code>f</code> 所可能抛出的任何异常。 </simpara></throws>
       </method>
     </method-group>

@@ -807,31 +939,43 @@
         </signature>

         <returns><simpara>True when <code>f</code> stores an object of
- type <code>Functor</code> and one of the following conditions applies: + type <code>Functor</code> and one of the following conditions applies:<sbr/> + 当 <code>f</code> 存储了一个类型为 <code>Functor</code> 的对象,而 且满足下列条件之一时,为 true:
           <itemizedlist>

             <listitem><simpara><code>g</code> is of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
             and <code>f.target&lt;Functor&gt;() == g.<methodname
- alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem> + alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.<sbr/> + <code>g</code> 的类型是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>,
+            而且,<code>f.target&lt;Functor&gt;() == g.<methodname
+ alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>。 </simpara></listitem>

             <listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code> - and <code><functionname>function_equals</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem> + and <code><functionname>function_equals</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.<sbr/> + <code>g</code> 的类型不是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>, + 而 且,<code><functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()),
+            g)</code>。</simpara></listitem>

           </itemizedlist>
           </simpara></returns>

         <notes><simpara><code><classname>function</classname></code>
         objects are not
-        <conceptname>EqualityComparable</conceptname>.</simpara></notes>
+        <conceptname>EqualityComparable</conceptname>.<sbr/>
+        <code><classname>function</classname></code> 对象不是
+ <conceptname>EqualityComparable</conceptname>(可等值比较)的。 </simpara></notes>

         <rationale><simpara>The <code>safe_bool</code> conversion
         opens a loophole whereby two <code>function</code>
         instances can be compared via <code>==</code>, although this
         is not feasible to implement. The undefined <code>void
         operator==</code> closes the loophole and ensures a
-        compile-time or link-time error.</simpara></rationale>
+        compile-time or link-time error.<sbr/>
+ <code>safe_bool</code> 转换打开一个漏洞,使得两个 <code>function</code> + 实例可以通过 <code>==</code> 进行比较,尽管对于实现来说这是不可行 的。 + 未定义的 <code>void operator==</code> 封闭这个漏洞并确保一个编译时 或连接时错误。</simpara></rationale>
       </overloaded-function>

       <overloaded-function name="operator!=">
@@ -884,31 +1028,43 @@
         <returns><simpara>True when <code>f</code> does not store an
         object of type <code>Functor</code> or it stores an object of
         type <code>Functor</code> and one of the following conditions
-        applies:
+        applies:<sbr/>
+        当 <code>f</code> 没有存储一个类型为 <code>Functor</code>
+ 的对象时或者它存储一个类型为 <code>Functor</code> 的对象并满足下列 条件之一时,为 true:
           <itemizedlist>

             <listitem><simpara><code>g</code> is of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>
             and <code>f.target&lt;Functor&gt;() != g.<methodname
- alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.</simpara></listitem> + alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>.<sbr/> + <code>g</code> 的类型是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>,
+            而且 <code>f.target&lt;Functor&gt;() != g.<methodname
+ alt="reference_wrapper::get_pointer">get_pointer</methodname>()</code>。 </simpara></listitem>

             <listitem><simpara><code>g</code> is not of type
<code><classname>reference_wrapper</classname>&lt;Functor&gt;</code> - and <code>!<functionname>function_equals</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.</simpara></listitem> + and <code>!<functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()), g)</code>.<sbr/> + <code>g</code> 的类型不是 <code><classname>reference_wrapper</classname>&lt;Functor&gt;</code>, + 而且 <code>!<functionname>function_equal</functionname>(*(f.target&lt;Functor&gt;()), g)</code>。</simpara></listitem>

           </itemizedlist>
           </simpara></returns>

         <notes><simpara><code><classname>function</classname></code>
         objects are not
-        <conceptname>EqualityComparable</conceptname>.</simpara></notes>
+        <conceptname>EqualityComparable</conceptname>.<sbr/>
+        <code><classname>function</classname></code> 对象不是
+ <conceptname>EqualityComparable</conceptname>(可等值比较)的。 </simpara></notes>

         <rationale><simpara>The <code>safe_bool</code> conversion
         opens a loophole whereby two <code>function</code>
         instances can be compared via <code>!=</code>, although this
         is not feasible to implement. The undefined <code>void
         operator!=</code> closes the loophole and ensures a
-        compile-time or link-time error.</simpara></rationale>
+        compile-time or link-time error.<sbr/>
+ <code>safe_bool</code> 转换打开一个漏洞,使得两个 <code>function</code> + 实例可以通过 <code>!=</code> 进行比较,尽管对于实现来说这是不可行 的。 + 未定义的 <code>void operator!=</code> 封闭这个漏洞并确保一个编译时 或连接时错误。</simpara></rationale>
       </overloaded-function>
     </free-function-group>
   </class>
@@ -929,9 +1085,11 @@
     <parameter name="g">
       <paramtype>const G&amp;</paramtype>
     </parameter>
- <purpose><simpara>Compare two function objects for equality.</simpara></purpose>
+    <purpose><simpara>Compare two function objects for equality.<sbr/>
+    比较两个函数对象是否相等。</simpara></purpose>
     <returns><simpara><code>f == g</code>.</simpara></returns>
-    <throws><simpara>Only if <code>f == g</code> throws.</simpara></throws>
+    <throws><simpara>Only if <code>f == g</code> throws.<sbr/>
+    只有当 <code>f == g</code> 时才会抛出。</simpara></throws>
   </function>
   </namespace>
 </header>
=======================================
--- /trunk/libs/function/doc/tests.xml  Mon Dec 28 23:05:14 2009
+++ /trunk/libs/function/doc/tests.xml  Sun Jan  3 19:32:44 2010
@@ -10,48 +10,67 @@
   "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd";>
<testsuite id="function.testsuite" last-revision="$Date: 2006-11-03 15:41:10 -0400 (Fri, 03 Nov 2006) $">
   <run-test filename="function_test.cpp" name="lib_function_test">
- <purpose><para>Test the capabilities of the <classname>boost::function</classname> class template.</para></purpose> - <if-fails><para>The <classname>boost::function</classname> class template may not be usable on your compiler. However, the library may still be usable via the <classname>boost::functionN</classname> class templates.</para></if-fails> + <purpose><para>Test the capabilities of the <classname>boost::function</classname> class template.<sbr/> + 测试 <classname>boost::function</classname> 类模板的功能。 </para></purpose> + <if-fails><para>The <classname>boost::function</classname> class template may not be usable on your compiler. However, the library may still be usable via the <classname>boost::functionN</classname> class templates.<sbr/>
+    <classname>boost::function</classname> 类模板在你的编译器上可能不可用。
+ 但是,通过 <classname>boost::functionN</classname> 类模板这个库依然可 用。</para></if-fails>
   </run-test>

   <run-test filename="function_n_test.cpp">
- <purpose><para>Test the capabilities of the <classname>boost::functionN</classname> class templates.</para></purpose> + <purpose><para>Test the capabilities of the <classname>boost::functionN</classname> class templates.<sbr/> + 测试 Test the capabilities of the <classname>boost::functionN</classname> 类模板的功能。</para></purpose>
   </run-test>

   <run-test filename="allocator_test.cpp">
-    <purpose><para>Test the use of custom allocators.</para></purpose>
- <if-fails><para>Allocators are ignored by the implementation.</para></if-fails>
+    <purpose><para>Test the use of custom allocators.<sbr/>
+    测试定制的分配器的使用。</para></purpose>
+    <if-fails><para>Allocators are ignored by the implementation.<sbr/>
+    分配器被实现忽略。</para></if-fails>
   </run-test>

   <run-test filename="stateless_test.cpp">
- <purpose><para>Test the optimization of stateless function objects in the Boost.Function library.</para></purpose> - <if-fails><para>The exception-safety and performance guarantees given for stateless function objects may not be met by the implementation.</para></if-fails> + <purpose><para>Test the optimization of stateless function objects in the Boost.Function library.<sbr/>
+    测试 Boost.Function 库中对 stateless 函数对象的优化</para></purpose>
+ <if-fails><para>The exception-safety and performance guarantees given for stateless function objects may not be met by the implementation.<sbr/> + 实现没有满足 stateless 函数对象所应得到的异常安全和性能保证。 </para></if-fails>
   </run-test>

   <run-test filename="lambda_test.cpp">
- <purpose><para>Test the interaction between Boost.Function and Boost.Lambda.</para></purpose> - <if-fails><para>Either Boost.Lambda does not work on the platform, or Boost.Function cannot safely be applied without the use of <functionname>boost::unlambda</functionname>.</para></if-fails> + <purpose><para>Test the interaction between Boost.Function and Boost.Lambda.<sbr/>
+    测试 Boost.Function 和 Boost.Lambda 之间的交互作用。</para></purpose>
+ <if-fails><para>Either Boost.Lambda does not work on the platform, or Boost.Function cannot safely be applied without the use of <functionname>boost::unlambda</functionname>.<sbr/> + Boost.Lambda 在这个平台上不能工作,而且 Boost.Function 在没有使用 <functionname>boost::unlambda</functionname>
+    的时候也无法安全地使用。</para></if-fails>
   </run-test>

   <run-test filename="contains_test.cpp">
     <purpose><para>Test the operation of the
     <code><methodname>target</methodname></code> member function and the
-    equality operators.</para></purpose>
+    equality operators.<sbr/>
+ 测试 <code><methodname>target</methodname></code> 成员函数的作用和等于 操作符。</para></purpose>
   </run-test>

   <compile-fail-test filename="function_test_fail1.cpp">
- <purpose><para>Test the (incorrect!) use of comparisons between Boost.Function function objects.</para></purpose> - <if-fails><para>Intuitive (but incorrect!) code may compile and will give meaningless results.</para></if-fails> + <purpose><para>Test the (incorrect!) use of comparisons between Boost.Function function objects.<sbr/> + 测试 Boost.Function 函数对象之间的比较的(错误的!)使用。 </para></purpose> + <if-fails><para>Intuitive (but incorrect!) code may compile and will give meaningless results.<sbr/> + 符合直觉的(但是错误的!)代码可以编译并给出无意义的结果。 </para></if-fails>
   </compile-fail-test>

   <compile-fail-test filename="function_test_fail2.cpp">
- <purpose><para>Test the use of an incompatible function object with Boost.Function</para></purpose> - <if-fails><para>Incorrect code may compile (with potentially unexpected results).</para></if-fails> + <purpose><para>Test the use of an incompatible function object with Boost.Function<sbr/>
+    测试一个和 Boost.Function 一起使用的不兼容的函数对象。</para></purpose>
+ <if-fails><para>Incorrect code may compile (with potentially unexpected results).<sbr/>
+    错误的代码可以编译(有潜在的无法预料的结果)。</para></if-fails>
   </compile-fail-test>

   <compile-test filename="function_30.cpp">
- <purpose><para>Test the generation of a Boost.Function function object adaptor accepting 30 arguments.</para></purpose> - <if-fails><para>The Boost.Function library may work for function object adaptors of up to 10 parameters, but will be unable to generate adaptors for an arbitrary number of parameters. Failure often indicates an error in the compiler's preprocessor.</para></if-fails> + <purpose><para>Test the generation of a Boost.Function function object adaptor accepting 30 arguments.<sbr/> + 测试一个接收 30 个参数的 Boost.Function 函数对象适配器的生成。 </para></purpose> + <if-fails><para>The Boost.Function library may work for function object adaptors of up to 10 parameters, but will be unable to generate adaptors for an arbitrary number of parameters. Failure often indicates an error in the compiler's preprocessor.<sbr/> + Boost.Function 库可能对不超过 10 个参数的函数对象适配器可以工作,但无法 生成任意参数数量的适配器。
+    失败通常预示编译器的预处理存在错误。</para></if-fails>
   </compile-test>

   <run-test filename="function_arith_cxx98.cpp">
@@ -76,7 +95,8 @@
     return 0;
 }
 </source>
-    <purpose><para>Test the first tutorial example.</para></purpose>
+    <purpose><para>Test the first tutorial example.<sbr/>
+    测试指南中的第一个示例。</para></purpose>
   </run-test>

   <run-test filename="function_arith_portable.cpp">
@@ -99,7 +119,8 @@
     return 0;
 }
 </source>
-    <purpose><para>Test the first tutorial example.</para></purpose>
+    <purpose><para>Test the first tutorial example.<sbr/>
+    测试指南中的第一个示例。</para></purpose>
   </run-test>

   <run-test filename="sum_avg_cxx98.cpp">
@@ -117,7 +138,8 @@
     return 0;
 }
 </source>
-    <purpose><para>Test the second tutorial example.</para></purpose>
+    <purpose><para>Test the second tutorial example.<sbr/>
+    测试指南中的第二个示例。</para></purpose>
   </run-test>

   <run-test filename="sum_avg_portable.cpp">
@@ -135,7 +157,8 @@
     return 0;
 }
 </source>
-    <purpose><para>Test the second tutorial example.</para></purpose>
+    <purpose><para>Test the second tutorial example.<sbr/>
+    测试指南中的第二个示例。</para></purpose>
   </run-test>

   <run-test filename="mem_fun_cxx98.cpp">
@@ -155,7 +178,8 @@
     return 0;
 }
 </source>
- <purpose><para>Test member function example from tutorial.</para></purpose>
+    <purpose><para>Test member function example from tutorial.<sbr/>
+    测试指南中的成员函数示例。</para></purpose>
   </run-test>

   <run-test filename="mem_fun_portable.cpp">
@@ -175,7 +199,8 @@
     return 0;
 }
 </source>
- <purpose><para>Test member function example from tutorial.</para></purpose>
+    <purpose><para>Test member function example from tutorial.<sbr/>
+    测试指南中的成员函数示例。</para></purpose>
   </run-test>

   <run-test filename="std_bind_cxx98.cpp">
@@ -195,7 +220,8 @@
     return 0;
 }
 </source>
- <purpose><para>Test standard binders example from tutorial.</para></purpose>
+    <purpose><para>Test standard binders example from tutorial.<sbr/>
+    测试指南中的标准绑定器示例。</para></purpose>
   </run-test>

   <run-test filename="std_bind_portable.cpp">
@@ -215,7 +241,8 @@
     return 0;
 }
 </source>
- <purpose><para>Test standard binders example from tutorial.</para></purpose>
+    <purpose><para>Test standard binders example from tutorial.<sbr/>
+    测试指南中的标准绑定器示例。</para></purpose>
   </run-test>

   <run-test filename="function_ref_cxx98.cpp">
@@ -234,7 +261,8 @@
     return 0;
 }
 </source>
- <purpose><para>Test <functionname>boost::ref</functionname> example from tutorial.</para></purpose> + <purpose><para>Test <functionname>boost::ref</functionname> example from tutorial.<sbr/> + 测试指南中的 <functionname>boost::ref</functionname> 示例。 </para></purpose>
   </run-test>

   <run-test filename="function_ref_portable.cpp">
@@ -253,6 +281,7 @@
     return 0;
 }
 </source>
- <purpose><para>Test <functionname>boost::ref</functionname> example from tutorial.</para></purpose> + <purpose><para>Test <functionname>boost::ref</functionname> example from tutorial.<sbr/> + 测试指南中的 <functionname>boost::ref</functionname> 示例。 </para></purpose>
   </run-test>
 </testsuite>
=======================================
--- /trunk/libs/function/doc/tutorial.xml       Mon Dec 28 23:05:14 2009
+++ /trunk/libs/function/doc/tutorial.xml       Sun Jan  3 19:32:44 2010
@@ -21,14 +21,18 @@
 preferred form is not supported on all platforms due to compiler
 bugs. The compatible form will work on all compilers supported by
 Boost.Function. Consult the table below to determine which syntactic
-form to use for your compiler.
+form to use for your compiler.<sbr/>
+Boost.Function 有两种语法形式:首选形式和兼容形式。首选形式更接近于 C++
+语言,并减少了需要被考虑的独立的模板参数的个数,通常会改进可读性,
+但是,由于编译器的 bug 首选形式并不被所有的平台支持。兼容性是可以工作在所有 +Boost.Function 支持的编译器上。参考下面的表格以确定在你的编译器上使用哪种语 法形式。

   <informaltable>
     <tgroup cols="2" align="left">
       <thead>
         <row>
-          <entry>Preferred syntax</entry>
-          <entry>Portable syntax</entry>
+          <entry>Preferred syntax 首选语法</entry>
+          <entry>Portable syntax 兼容语法</entry>
         </row>
       </thead>
       <tbody>
@@ -45,7 +49,8 @@
           </entry>
           <entry>
             <itemizedlist spacing="compact">
- <listitem><simpara><emphasis>Any compiler supporting the preferred syntax</emphasis></simpara></listitem> + <listitem><simpara><emphasis>Any compiler supporting the preferred syntax<sbr/>
+                支持首选语法的任何编译器</emphasis></simpara></listitem>
<listitem><simpara>Microsoft Visual C++ 6.0, 7.0</simpara></listitem>
               <listitem><simpara>Borland C++ 5.5.1</simpara></listitem>
<listitem><simpara>Sun WorkShop 6 update 2 C++ 5.3</simpara></listitem>
@@ -59,12 +64,14 @@

 </para>

-<para> If your compiler does not appear in this list, please try the preferred syntax and report your results to the Boost list so that we can keep this table up-to-date.</para> +<para> If your compiler does not appear in this list, please try the preferred syntax and report your results to the Boost list so that we can keep this table up-to-date.<sbr/> +如果你的编译器没有出现在这个列表中,请试用首选语法并向 Boost 邮件列表报告你 的结果,
+以便我们可以保持这个表格的最新状态。</para>

 <using-class name="boost::function"/>

 <section>
-<title>Basic Usage</title> <para> A function wrapper is defined simply
+<title>Basic Usage 基本用法</title> <para> A function wrapper is defined simply
 by instantiating the <computeroutput>function</computeroutput> class
 template with the desired return type and argument types, formulated
 as a C++ function type. Any number of arguments may be supplied, up to
@@ -72,14 +79,19 @@
 following declares a function object wrapper
 <computeroutput>f</computeroutput> that takes two
 <computeroutput>int</computeroutput> parameters and returns a
-<computeroutput>float</computeroutput>:
+<computeroutput>float</computeroutput>:<sbr/>
+一个函数包装类可以简单地通过用想要的返回类型和参数类型来实例化
+<computeroutput>function</computeroutput> 类模板来定义,简称为 C++ 函数类 型。
+任何个数的参数都可以提供,直到某个实现定义的上限(10 是缺省的最大值)。
+下面就是声明一个 function object wrapper(函数对象包装类 )<computeroutput>f</computeroutput>, +它持有两个 <computeroutput>int</computeroutput> 参数并返回一个 <computeroutput>float</computeroutput>:

   <informaltable>
     <tgroup cols="2" align="left">
       <thead>
         <row>
-          <entry>Preferred syntax</entry>
-          <entry>Portable syntax</entry>
+          <entry>Preferred syntax 首选语法</entry>
+          <entry>Portable syntax 兼容语法</entry>
         </row>
       </thead>
       <tbody>
@@ -97,7 +109,8 @@
 </para>

 <para> By default, function object wrappers are empty, so we can create a
-function object to assign to <computeroutput>f</computeroutput>:
+function object to assign to <computeroutput>f</computeroutput>:<sbr/>
+缺省情况下,函数对象包装类是空的,所以我们创建一个函数对象赋给 <computeroutput>f</computeroutput>:

 <programlisting name="function.tutorial.int_div">struct int_div {
   float operator()(int x, int y) const { return ((float)x)/y; };
@@ -107,7 +120,9 @@

 <para> Now we can use <computeroutput>f</computeroutput> to execute
 the underlying function object
-<computeroutput>int_div</computeroutput>:
+<computeroutput>int_div</computeroutput>:<sbr/>
+现在我们可以用 <computeroutput>f</computeroutput> 来执行底层的函数对象
+<computeroutput>int_div</computeroutput>:

<programlisting name="function.tutorial.call_int_div">std::cout &lt;&lt; f(5, 3) &lt;&lt; std::endl;</programlisting>
 </para>
@@ -118,11 +133,15 @@
 <computeroutput>long</computeroutput> operands, the implicit
 conversions would have been applied to the arguments without any user
 interference. The only limit on the types of arguments is that they be
-CopyConstructible, so we can even use references and arrays:
+CopyConstructible, so we can even use references and arrays:<sbr/>
+我们可以自由地赋任何函数对象给 <computeroutput>f</computeroutput>。
+如果 <computeroutput>int_div</computeroutput> 被定义为持有两个
+<computeroutput>long</computeroutput> 操作数,隐式转换会在没有任何用户干预 的情况下应用于参数。 +对于参数类型的仅有的限制是它们是可拷贝构造的,所以我们甚至可以用引用或数 组:

   <informaltable>
     <tgroup cols="1" align="left">
-      <thead><row><entry>Preferred syntax</entry></row></thead>
+      <thead><row><entry>Preferred syntax 首选语法</entry></row></thead>
       <tbody>
         <row>
           <entry>
@@ -134,7 +153,7 @@
   </informaltable>
   <informaltable>
     <tgroup cols="1" align="left">
-      <thead><row><entry>Portable syntax</entry></row></thead>
+      <thead><row><entry>Portable syntax 兼容语法</entry></row></thead>
       <tbody>
         <row>
 <entry>
@@ -160,7 +179,12 @@
 <para> Invoking a function object wrapper that does not actually
 contain a function object is a precondition violation, much like
trying to call through a null function pointer, and will throw a <classname>bad_function_call</classname> exception). We can check for an -empty function object wrapper by using it in a boolean context (it evaluates <computeroutput>true</computeroutput> if the wrapper is not empty) or compare it against <computeroutput>0</computeroutput>. For instance: +empty function object wrapper by using it in a boolean context (it evaluates <computeroutput>true</computeroutput> if the wrapper is not empty) or compare it against <computeroutput>0</computeroutput>. For instance:<sbr/> +调用一个实际上没有包含函数对象的函数对象包装类是一个 precondition violation(前提违例), +很像试图用一个空的函数指针调用函数,并抛出一个 <classname>bad_function_call</classname> 异常。 +我们可以通过在一个布尔上下文中使用它(如果包装类不为空,将求值为 <computeroutput>true</computeroutput>) +或将它和 <computeroutput>0</computeroutput> 作比较来检查空函数对象包装类。 例如:
+
 <programlisting name="function.tutorial.check_empty">if (f)
   std::cout &lt;&lt; f(5, 3) &lt;&lt; std::endl;
 else
@@ -169,31 +193,40 @@

 <para> Alternatively,
 <computeroutput><methodname>empty</methodname>()</computeroutput>
-method will return whether or not the wrapper is empty.  </para>
-
-<para> Finally, we can clear out a function target by assigning it to <computeroutput>0</computeroutput> or by calling the <computeroutput><methodname>clear</methodname>()</computeroutput> member function, e.g.,
+method will return whether or not the wrapper is empty.<sbr/>
+另一个可选方法 是,<computeroutput><methodname>empty</methodname>()</computeroutput>
+方法可以返回这个包装类是否为空。</para>
+
+<para> Finally, we can clear out a function target by assigning it to <computeroutput>0</computeroutput> or by calling the <computeroutput><methodname>clear</methodname>()</computeroutput> member function, e.g., <sbr/>
+最后,我们可以通过为它赋值为 <computeroutput>0</computeroutput> 或调用
+<computeroutput><methodname>clear</methodname>()</computeroutput> 成员函数 来清空一个函数目标,例如,
 <programlisting name="function.tutorial.clear">f = 0;</programlisting>
 </para>

 </section>

 <section>
-  <title>Free functions</title>
-<para> Free function pointers can be considered singleton function objects with const function call operators, and can therefore be directly used with the function object wrappers:
+  <title>Free functions 自由函数</title>
+<para> Free function pointers can be considered singleton function objects with const function call operators, and can therefore be directly used with the function object wrappers: <sbr/> +自由函数指针被认为是带有 const 函数调用操作符的单例函数对象,并因此可以直接 用于函数对象包装类: <programlisting name="function.tutorial.mul_ints">float mul_ints(int x, int y) { return ((float)x) * y; }</programlisting> <programlisting name="function.tutorial.use_mul_ints">f = &amp;mul_ints;</programlisting>
 </para>

-<para> Note that the <computeroutput>&amp;</computeroutput> isn't really necessary unless you happen to be using Microsoft Visual C++ version 6. </para> +<para> Note that the <computeroutput>&amp;</computeroutput> isn't really necessary unless you happen to be using Microsoft Visual C++ version 6. <sbr/> +注意,<computeroutput>&amp;</computeroutput> 并不是真的必要,除非你使用 Microsoft Visual C++ 版本 6。</para>
 </section>

 <section>
-  <title>Member functions</title>
+  <title>Member functions 成员函数</title>

 <para> In many systems, callbacks often call to member functions of a
 particular object. This is often referred to as "argument binding",
 and is beyond the scope of Boost.Function. The use of member functions
-directly, however, is supported, so the following code is valid:
+directly, however, is supported, so the following code is valid:<sbr/>
+在很多系统中,回调通常是对一个特定对象的成员函数的调用。
+这通常被认为是“参数绑定”,而且已经超出 Boost.Function 的范畴。
+无论如何,直接调用成员函数是被支持的,所以下面的代码是合法的:

 <programlisting name="function.tutorial.X">struct X {
   int foo(int);
@@ -203,8 +236,8 @@
     <tgroup cols="2" align="left">
       <thead>
         <row>
-          <entry>Preferred syntax</entry>
-          <entry>Portable syntax</entry>
+          <entry>Preferred syntax 首选语法</entry>
+          <entry>Portable syntax 兼容语法</entry>
         </row>
       </thead>
       <tbody>
@@ -231,24 +264,30 @@
 </informaltable>
 </para>

-<para> Several libraries exist that support argument binding. Three such libraries are summarized below: +<para> Several libraries exist that support argument binding. Three such libraries are summarized below:<sbr/>
+有几个支持参数绑定的库已经存在。下面概述三个这样的库:
 <itemizedlist>
<listitem> <para><libraryname>Bind</libraryname>. This library allows binding of
   arguments for any function object. It is lightweight and very
-  portable.</para></listitem>
+  portable.<sbr/>
+  <libraryname>Bind</libraryname>。这个库允许任何函数对象的参数绑定。
+  它是轻量级的而且可移植性好。</para></listitem>

   <listitem> <para>The C++ Standard library. Using
   <computeroutput>std::bind1st</computeroutput> and
   <computeroutput>std::mem_fun</computeroutput> together one can bind
   the object of a pointer-to-member function for use with
-  Boost.Function:
+  Boost.Function:<sbr/>
+  C++ 标准库。将 <computeroutput>std::bind1st</computeroutput> 和
+  <computeroutput>std::mem_fun</computeroutput> 合在一起使用,
+  可以将一个指向成员函数的指针的对象绑定到 Boost.Function:

   <informaltable>
     <tgroup cols="2" align="left">
       <thead>
         <row>
-          <entry>Preferred syntax</entry>
-          <entry>Portable syntax</entry>
+          <entry>Preferred syntax 首选语法</entry>
+          <entry>Portable syntax 兼容语法</entry>
         </row>
       </thead>
       <tbody>
@@ -274,27 +313,33 @@
 </para>
 </listitem>

- <listitem><para>The <libraryname>Lambda</libraryname> library. This library provides a powerful composition mechanism to construct function objects that uses very natural C++ syntax. Lambda requires a compiler that is reasonably conformant to the C++ standard. </para></listitem> + <listitem><para>The <libraryname>Lambda</libraryname> library. This library provides a powerful composition mechanism to construct function objects that uses very natural C++ syntax. Lambda requires a compiler that is reasonably conformant to the C++ standard. <sbr/> + <libraryname>Lambda</libraryname> 库。这个库提供一个强大的合成机制,利用 非常自然的 C++ 语法去构造函数对象。
+  lambda 需要一个相当符合 C++ 标准的编译器。</para></listitem>
 </itemizedlist>
 </para>

 </section>

 <section>
-  <title>References to Function Objects</title> <para> In some cases it is
+ <title>References to Function Objects 引向函数对象的引用</title> <para> In some cases it is
   expensive (or semantically incorrect) to have Boost.Function clone a
   function object. In such cases, it is possible to request that
   Boost.Function keep only a reference to the actual function
   object. This is done using the <computeroutput>ref</computeroutput>
   and <computeroutput>cref</computeroutput> functions to wrap a
-  reference to a function object:
+  reference to a function object:<sbr/>
+ 在某些情况下,让 Boost.Function 克隆一个函数对象需要付出高昂的代价(或者 是语义错误的)。 + 在这样的情况下,要求 Boost.Function 只保留引向实际的函数对象的引用是有可 能的。 + 这可以通过使用 <computeroutput>ref</computeroutput> 和 <computeroutput>cref</computeroutput>
+  函数去包装一个引向函数对象的引用来做到:

   <informaltable>
     <tgroup cols="2" align="left">
       <thead>
         <row>
-          <entry>Preferred syntax</entry>
-          <entry>Portable syntax</entry>
+          <entry>Preferred syntax 首选语法</entry>
+          <entry>Portable syntax 兼容语法</entry>
         </row>
       </thead>
       <tbody>
@@ -325,19 +370,27 @@
 <computeroutput>f</computeroutput>'s reference to
 <computeroutput>a_function_object</computeroutput>. Additionally, when
 using references to function objects, Boost.Function will not throw
-exceptions during assignment or construction.
+exceptions during assignment or construction.<sbr/>
+这里,<computeroutput>f</computeroutput> 不会生成 <computeroutput>a_function_object</computeroutput> +的一个拷贝,当 <computeroutput>f2</computeroutput> 以 <computeroutput>f</computeroutput> +的引向 <computeroutput>a_function_object</computeroutput> 的引用为目标 时,也不会生成这个拷贝。 +另外,当使用引向函数对象的引用时,Boost.Function 在赋值和构造过程中不会抛出 异常。
 </para>
 </section>

 <section>
-  <title>Comparing Boost.Function function objects</title>
+ <title>Comparing Boost.Function function objects 比较 Boost.Function 函数 对象</title>

   <para>Function object wrappers can be compared via <code>==</code>
   or <code>!=</code> against any function object that can be stored
   within the wrapper. If the function object wrapper contains a
   function object of that type, it will be compared against the given
   function object (which must be either be
- <conceptname>EqualityComparable</conceptname> or have an overloaded <functionname>boost::function_equal</functionname>). For instance:</para> + <conceptname>EqualityComparable</conceptname> or have an overloaded <functionname>boost::function_equal</functionname>). For instance:<sbr/> + 函数对象包装类可以通过 <code>==</code> 或 <code>!=</code> 与任何能够存储 在这个包装类内的函数对象进行比较。 + 如果这个函数对象包装类包含一个某种类型的函数对象,它将和给定的函数对象 (这个函数对象必须是 + <conceptname>EqualityComparable</conceptname> 的,而且必须有一个 <functionname>boost::function_equal</functionname>
+  的重载)进行比较。例如:</para>

<programlisting name="function.tutorial.compare">int compute_with_X(X*, int);

@@ -350,7 +403,10 @@
    of the object in the
    <code><classname>reference_wrapper</classname></code> is compared
    against the address of the object stored by the function object
-   wrapper:</para>
+   wrapper:<sbr/>
+ 当和一个 <code><classname>reference_wrapper</classname></code> 的实例进 行比较时,
+   <code><classname>reference_wrapper</classname></code>
+   中的对象的地址和函数对象包装类中存储的对象的地址进行比较:</para>

<programlisting name="function.tutorial.compare-ref">a_stateful_object so1, so2;
 f = <functionname>boost::ref</functionname>(so1);

Other related posts:

  • » [boost-doc-zh] r360 committed - 翻译 foreach, function 的qbk/xml文件 - boost-doc-zh