msgid ""
msgstr ""
"Project-Id-Version: English (Boost Json Translation (zh_Hans))\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-06-06 23:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: English <https://insights.cppalliance.org/weblate/projects/"
"boost-json-documentation-zh_Hans/doc-pages-allocators-background-adoc/en/>\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 2026.5\n"

#: :11
#, read-only, safe-html, strict-same
msgid ""
"= 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}:"
msgstr ""
"= 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}:"

#: :22
#, read-only, safe-html, strict-same
msgid ""
"The standard allocator is {req_DefaultConstructible}. To support stateful "
"allocators, containers provide additional constructor overloads taking an "
"allocator instance parameter."
msgstr ""
"The standard allocator is {req_DefaultConstructible}. To support stateful "
"allocators, containers provide additional constructor overloads taking an "
"allocator instance parameter."

#: :31
#, read-only, safe-html, strict-same
msgid "While the system works, it has some usability problems:"
msgstr "While the system works, it has some usability problems:"

#: :33
#, read-only, safe-html, strict-same
msgid "The container must be a class template."
msgstr "The container must be a class template."

#: :34
#, read-only, safe-html, strict-same
msgid "Parameterizing the allocator on the element type is clumsy."
msgstr "Parameterizing the allocator on the element type is clumsy."

#: :35
#, read-only, safe-html, strict-same
msgid "The system of allocator traits, especially POCCA and POCMA,"
msgstr "The system of allocator traits, especially POCCA and POCMA,"

#: :36
#, read-only, safe-html, strict-same
msgid "is complicated and error-prone."
msgstr "is complicated and error-prone."

#: :38
#, read-only, safe-html, strict-same
msgid ""
"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."
msgstr ""
"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."

#: :42
#, read-only, safe-html, strict-same
msgid "Polymorphic Allocators"
msgstr "Polymorphic Allocators"

#: :44
#, read-only, safe-html, strict-same
msgid ""
"{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:"
msgstr ""
"{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:"

#: :53
#, read-only, safe-html, strict-same
msgid ""
"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:"
msgstr ""
"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:"

#: :63
#, read-only, safe-html, strict-same
msgid "A polymorphic allocator constructs with a pointer to a memory resource:"
msgstr "A polymorphic allocator constructs with a pointer to a memory resource:"

#: :70
#, read-only, safe-html, strict-same
msgid ""
"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:"
msgstr ""
"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:"

#: :81
#, read-only, safe-html, strict-same
msgid ""
"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:"
msgstr ""
"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:"

#: :91
#, read-only, safe-html, strict-same
msgid ""
"This can be worked around by declaring the container to use a custom "
"allocator (perhaps using a `std::shared_ptr< std::pmr::memory_resource >` 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:"
msgstr ""
"This can be worked around by declaring the container to use a custom "
"allocator (perhaps using a `std::shared_ptr< std::pmr::memory_resource >` 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:"

#: :102
#, read-only, safe-html, strict-same
msgid ""
"Workarounds for this problem are worse than the problem itself. The library "
"could return a pair with the vector and "
"`std::unique_ptr<std::pmr::memory_resource>` 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)."
msgstr ""
"Workarounds for this problem are worse than the problem itself. The library "
"could return a pair with the vector and "
"`std::unique_ptr<std::pmr::memory_resource>` 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)."

#: :109
#, read-only, safe-html, strict-same
msgid "Problem Statement"
msgstr "Problem Statement"

#: :111
#, read-only, safe-html, strict-same
msgid ""
"We would like an allocator model using a single type `T` with the following "
"properties:"
msgstr ""
"We would like an allocator model using a single type `T` with the following "
"properties:"

#: :114
#, read-only, safe-html, strict-same
msgid "`T` is not a class template"
msgstr "`T` is not a class template"

#: :115
#, read-only, safe-html, strict-same
msgid "`T` references a {ref_memory_resource}"
msgstr "`T` references a {ref_memory_resource}"

#: :116
#, read-only, safe-html, strict-same
msgid "`T` supports both reference semantics or shared ownership"
msgstr "`T` supports both reference semantics or shared ownership"

#: :117
#, read-only, safe-html, strict-same
msgid "`T` interoperates with code already using `std::pmr`"
msgstr "`T` interoperates with code already using `std::pmr`"

#: :119
#, read-only, safe-html, strict-same
msgid ""
"Boost.JSON solves this problem by introducing a new smart pointer called "
"<<ref_storage_ptr>> 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."
msgstr ""
"Boost.JSON solves this problem by introducing a new smart pointer called "
"<<ref_storage_ptr>> 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."
