• <bdo id='WkBc8'></bdo><ul id='WkBc8'></ul>

    <i id='WkBc8'><tr id='WkBc8'><dt id='WkBc8'><q id='WkBc8'><span id='WkBc8'><b id='WkBc8'><form id='WkBc8'><ins id='WkBc8'></ins><ul id='WkBc8'></ul><sub id='WkBc8'></sub></form><legend id='WkBc8'></legend><bdo id='WkBc8'><pre id='WkBc8'><center id='WkBc8'></center></pre></bdo></b><th id='WkBc8'></th></span></q></dt></tr></i><div id='WkBc8'><tfoot id='WkBc8'></tfoot><dl id='WkBc8'><fieldset id='WkBc8'></fieldset></dl></div>

    <small id='WkBc8'></small><noframes id='WkBc8'>

  • <legend id='WkBc8'><style id='WkBc8'><dir id='WkBc8'><q id='WkBc8'></q></dir></style></legend>

        <tfoot id='WkBc8'></tfoot>
      1. 将流缓冲的内容复制到字符串

        时间:2023-06-30

        <small id='9lQy2'></small><noframes id='9lQy2'>

          <tbody id='9lQy2'></tbody>

          <bdo id='9lQy2'></bdo><ul id='9lQy2'></ul>
            <tfoot id='9lQy2'></tfoot>
            <i id='9lQy2'><tr id='9lQy2'><dt id='9lQy2'><q id='9lQy2'><span id='9lQy2'><b id='9lQy2'><form id='9lQy2'><ins id='9lQy2'></ins><ul id='9lQy2'></ul><sub id='9lQy2'></sub></form><legend id='9lQy2'></legend><bdo id='9lQy2'><pre id='9lQy2'><center id='9lQy2'></center></pre></bdo></b><th id='9lQy2'></th></span></q></dt></tr></i><div id='9lQy2'><tfoot id='9lQy2'></tfoot><dl id='9lQy2'><fieldset id='9lQy2'></fieldset></dl></div>
            <legend id='9lQy2'><style id='9lQy2'><dir id='9lQy2'><q id='9lQy2'></q></dir></style></legend>
                • 本文介绍了将流缓冲的内容复制到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  显然 boost::asio::async_read 不喜欢字符串,因为 boost::asio::buffer 的唯一重载允许我创建 const_buffers,所以我坚持将所有内容读入流缓冲.
                  现在我想将 streambuf 的内容复制到一个字符串中,但它显然只支持写入 char* (sgetn()),使用 streambuf 创建一个 istream 并使用 getline().

                  Apparently boost::asio::async_read doesn't like strings, as the only overload of boost::asio::buffer allows me to create const_buffers, so I'm stuck with reading everything into a streambuf.
                  Now I want to copy the contents of the streambuf into a string, but it apparently only supports writing to char* (sgetn()), creating an istream with the streambuf and using getline().

                  有没有其他方法可以在不过度复制的情况下使用streambufs内容创建字符串?

                  Is there any other way to create a string with the streambufs contents without excessive copying?

                  推荐答案

                  我最不喜欢这样的回答:你不想要 X,你想要 Y,这是如何做 Y",但在这种情况下我我很确定我知道 tstenner 想要什么.

                  I mostly don't like answers that say "You don't want X, you want Y instead and here's how to do Y" but in this instance I'm pretty sure I know what tstenner wanted.

                  在 Boost 1.66 中,动态字符串添加了缓冲区类型,以便async_read可以直接调整大小并写入字符串缓冲区.

                  In Boost 1.66, the dynamic string buffer type was added so async_read can directly resize and write to a string buffer.

                  这篇关于将流缓冲的内容复制到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <i id='aVfTM'><tr id='aVfTM'><dt id='aVfTM'><q id='aVfTM'><span id='aVfTM'><b id='aVfTM'><form id='aVfTM'><ins id='aVfTM'></ins><ul id='aVfTM'></ul><sub id='aVfTM'></sub></form><legend id='aVfTM'></legend><bdo id='aVfTM'><pre id='aVfTM'><center id='aVfTM'></center></pre></bdo></b><th id='aVfTM'></th></span></q></dt></tr></i><div id='aVfTM'><tfoot id='aVfTM'></tfoot><dl id='aVfTM'><fieldset id='aVfTM'></fieldset></dl></div>
                    <tfoot id='aVfTM'></tfoot>

                    <small id='aVfTM'></small><noframes id='aVfTM'>

                    <legend id='aVfTM'><style id='aVfTM'><dir id='aVfTM'><q id='aVfTM'></q></dir></style></legend>
                        • <bdo id='aVfTM'></bdo><ul id='aVfTM'></ul>
                            <tbody id='aVfTM'></tbody>