<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.1" version="1.1">
  <file original="NoName" source-language="en" datatype="plaintext" target-language="zh_Hans">
    <body>
      <trans-unit xml:space="preserve" approved="no" id="f1a8367f304a0723" weblate-flags="safe-html, strict-same">
        <source>= Background The first version of allocators in C++ defined the named requirement {req_Allocator}, and made each standard container a class template parameterized on the allocator type. For example, here is the declaration for {std_vector}:</source>
        <target state="translated">= 背景 C++中分配器的第一个版本定义了名为{req_Allocator}的要求，并将每个标准容器设计为以分配器类型为模板参数的类模板。例如，以下是 {std_vector} 的声明：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">11</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="c911bfe8607b2d7f" weblate-flags="safe-html, strict-same">
        <source>The standard allocator is {req_DefaultConstructible}. To support stateful allocators, containers provide additional constructor overloads taking an allocator instance parameter.</source>
        <target state="translated">标准分配器是{req_DefaultConstructible}。为支持有状态分配器，容器提供了额外的构造函数重载，接受一个分配器实例参数。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">22</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="bc1b23b12d903cfb" weblate-flags="safe-html, strict-same">
        <source>While the system works, it has some usability problems:</source>
        <target state="translated">尽管该机制能够正常工作，但仍存在一些可用性问题：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">31</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="6c60de6a9ab6cc1b" weblate-flags="safe-html, strict-same">
        <source>The container must be a class template.</source>
        <target state="translated">容器必须是一个类模板。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">33</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="a03ad2e2ad385ffc" weblate-flags="safe-html, strict-same">
        <source>Parameterizing the allocator on the element type is clumsy.</source>
        <target state="translated">在元素类型上参数化分配器的方式显得笨拙。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">34</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="5226384777a007c5" weblate-flags="safe-html, strict-same">
        <source>The system of allocator traits, especially POCCA and POCMA,</source>
        <target state="translated">分配器特征机制，尤其是 POCCA 和 POCMA，</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">35</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="876c8d7cae93663c" weblate-flags="safe-html, strict-same">
        <source>is complicated and error-prone.</source>
        <target state="translated">是复杂且容易出错的。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">36</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="672631018b430cec" weblate-flags="safe-html, strict-same">
        <source>Allocator-based programs which use multiple allocator types incur a greater number of function template instantiations and are generally slower to compile because class template function definitions must be visible at all call sites.</source>
        <target state="translated">使用多种分配器类型的基于分配器的程序会引发更多的函数模板实例化，且通常编译速度更慢，因为类模板的函数定义必须在所有调用点可见。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">38</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="57ee2b373435b1f7" weblate-flags="safe-html, strict-same">
        <source>Polymorphic Allocators</source>
        <target state="translated">多态分配器</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">42</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="ca99023583eb3f58" weblate-flags="safe-html, strict-same">
        <source>{cpp}17 improves the allocator model by representing the low-level allocation operation with an abstract interface called {ref_memory_resource}, which is not parameterized on the element type, and has no traits:</source>
        <target state="translated">{cpp}17通过引入一个名为 {ref_memory_resource} 的抽象接口来表示底层分配操作，从而改进分配器模型。该接口未在元素类型上参数化，且无特征：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">44</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="3f23b95c6eea0e0e" weblate-flags="safe-html, strict-same">
        <source>The class template {ref_polymorphic_allocator} wraps a {ref_memory_resource} pointer and meets the requirements of {req_Allocator}, allowing it to be used where an allocator is expected. The standard provides type aliases using the polymorphic allocator for standard containers:</source>
        <target state="translated">类模板{ref_polymorphic_allocator}包装了{ref_memory_resource}指针，并满足{req_Allocator}要求，使其可在需要分配器的地方使用。标准库为使用多态分配器的标准容器提供了类型别名：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">53</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="480d4e6d9b989693" weblate-flags="safe-html, strict-same">
        <source>A polymorphic allocator constructs with a pointer to a memory resource:</source>
        <target state="translated">多态分配器通过一个指向内存资源的指针进行构造：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">63</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="92193f3cdd626efd" weblate-flags="safe-html, strict-same">
        <source>The memory resource is passed by pointer; ownership is not transferred. The caller is responsible for extending the lifetime of the memory resource until the last container which is using it goes out of scope, otherwise the behavior is undefined. Sometimes this is the correct model, such as in this example which uses a monotonic resource constructed from a local stack buffer:</source>
        <target state="translated">内存资源通过指针传递；所有权不发生转移。调用方需负责确保该内存资源的生命周期持续到所有使用它的容器都离开作用域为止，否则行为未定义。在某些场景下，这种模型是合适的，例如以下示例中使用了一个基于局部栈缓冲区构造的单调内存资源：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">70</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="104ff11f1f2a93b6" weblate-flags="safe-html, strict-same">
        <source>However, sometimes shared ownership is needed. Specifically, that the lifetime extension of the memory resource should be automatic. For example, if a library wants to return a container which owns an instance of the library's custom memory resource as shown below:</source>
        <target state="translated">然而，有时需要共享所有权，即内存资源的生命周期应自动延长。例如，若某个库希望返回一个容器，该容器拥有该库自定义内存资源的实例，如下所示：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">81</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="87dc8128071bd84f" weblate-flags="safe-html, strict-same">
        <source>This can be worked around by declaring the container to use a custom allocator (perhaps using a `std::shared_ptr&lt; std::pmr::memory_resource &gt;` as a data member). This hinders library composition; every library now exports unique, incompatible container types. A raw memory resource pointer is also easy to misuse:</source>
        <target state="translated">可通过声明容器使用自定义分配器（可能使用`std::shared_ptr&amp;lt; std::pmr::memory_resource &amp;gt;`作为数据成员）来解决此问题。这会阻碍库的组合；每个库都会导出各自独特且互不兼容的容器类型。原始内存资源指针也容易被误用：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">91</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="2f02af4636a06f8f" weblate-flags="safe-html, strict-same">
        <source>Workarounds for this problem are worse than the problem itself. The library could return a pair with the vector and `std::unique_ptr&lt;std::pmr::memory_resource&gt;` which the caller must manage. Or the library could change its function signatures to accept a {ref_memory_resource}``*`` provided by the caller, where the library also makes public the desired memory resources (`my_resource` above).</source>
        <target state="translated">针对此问题的变通方案往往比问题本身更糟糕。该库可以返回一个包含 vector 和`std::unique_ptr&lt;std::pmr::memory_resource&gt;`的pair，必须由调用方自行管理。或者，该库也可以修改其函数签名，接受调用方提供的{ref_memory_resource}``*``，同时将所需的内存资源（如上文的`my_resource`）公开。&lt;/std::pmr::memory_resource&gt;</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">102</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="5024b625fa92112a" weblate-flags="safe-html, strict-same">
        <source>Problem Statement</source>
        <target state="translated">问题陈述</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">109</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="9dbb29613cc6c6c7" weblate-flags="safe-html, strict-same">
        <source>We would like an allocator model using a single type `T` with the following properties:</source>
        <target state="translated">我们希望采用一种使用单一类型`T`的分配器模型，该模型具有以下特性：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">111</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="3acced75cdcdb5c0" weblate-flags="safe-html, strict-same">
        <source>`T` is not a class template</source>
        <target state="translated">`T`不是类模板</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">114</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="949b54164822d3ae" weblate-flags="safe-html, strict-same">
        <source>`T` references a {ref_memory_resource}</source>
        <target state="translated">`T`引用一个 {ref_memory_resource}</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">115</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="88ea0578d4558e3e" weblate-flags="safe-html, strict-same">
        <source>`T` supports both reference semantics or shared ownership</source>
        <target state="translated">`T`同时支持引用语义和共享所有权</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">116</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="736dc967c7ac172c" weblate-flags="safe-html, strict-same">
        <source>`T` interoperates with code already using `std::pmr`</source>
        <target state="translated">`T`能与已使用`std::pmr`的代码互操作</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">117</context>
        </context-group>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="e738c249b5a0baea" weblate-flags="safe-html, strict-same">
        <source>Boost.JSON solves this problem by introducing a new smart pointer called &lt;&lt;ref_storage_ptr&gt;&gt; which builds upon {cpp}17's memory allocation interfaces, accomplishing the goals above. As a result, libraries which use this type compose more easily and enjoy faster compilation, as member functions for containers which use the type can be defined out-of-line.</source>
        <target state="translated">Boost.JSON通过引入一个名为&amp;lt;&lt;ref_storage_ptr&gt;&amp;gt; 的新型智能指针解决此问题，该指针基于{cpp}17的内存分配接口构建，实现了上述目标。因此，使用该类型的库更易于组合，并能获得更快的编译速度，因为使用该类型的容器的成员函数可以定义在类外（out-of-line）。&lt;/ref_storage_ptr&gt;</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile"></context>
          <context context-type="linenumber">119</context>
        </context-group>
      </trans-unit>
    </body>
  </file>
</xliff>
