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

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

    1. <small id='n6ib3'></small><noframes id='n6ib3'>

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

        使 std::vector 分配对齐的内存

        时间:2023-07-19

        1. <small id='yvXGN'></small><noframes id='yvXGN'>

          <legend id='yvXGN'><style id='yvXGN'><dir id='yvXGN'><q id='yvXGN'></q></dir></style></legend>
            <bdo id='yvXGN'></bdo><ul id='yvXGN'></ul>

            1. <tfoot id='yvXGN'></tfoot>

                <i id='yvXGN'><tr id='yvXGN'><dt id='yvXGN'><q id='yvXGN'><span id='yvXGN'><b id='yvXGN'><form id='yvXGN'><ins id='yvXGN'></ins><ul id='yvXGN'></ul><sub id='yvXGN'></sub></form><legend id='yvXGN'></legend><bdo id='yvXGN'><pre id='yvXGN'><center id='yvXGN'></center></pre></bdo></b><th id='yvXGN'></th></span></q></dt></tr></i><div id='yvXGN'><tfoot id='yvXGN'></tfoot><dl id='yvXGN'><fieldset id='yvXGN'></fieldset></dl></div>
                  <tbody id='yvXGN'></tbody>
                  本文介绍了使 std::vector 分配对齐的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以使自定义结构的 std::vector 分配对齐的内存以使用 SIMD 指令进行进一步处理?如果可以使用 Allocator,有没有人碰巧有这样一个他可以共享的分配器?

                  Is it possible to make std::vector of custom structs allocate aligned memory for further processing with SIMD instructions? If it is possible to do with Allocator, does anyone happen to have such an allocator he could share?

                  推荐答案

                  从 C++17 开始,只需使用 std::vector<__m256i> 或任何其他对齐类型.operator new 有对齐版本,它被 std::allocator 用于对齐类型(以及普通的 new 表达式,所以new __m256i[N] 从 C++17 开始也是安全的.

                  Starting in C++17, just use std::vector<__m256i> or with any other aligned type. There's aligned version of operator new, it is used by std::allocator for aligned types (as well as by plain new-expression, so new __m256i[N] is also safe starting in C++17).

                  @MarcGlisse 发表了这样的评论,这是一个使其更显眼的答案.

                  There's a comment by @MarcGlisse saying this, making this an answer to make it more visible.

                  这篇关于使 std::vector 分配对齐的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:"new" 和有什么不一样?和“malloc"和“calloc"在 C++ 中? 下一篇:如何在C++中获取Windows下的内存使用情况

                  相关文章

                  <legend id='WxIgH'><style id='WxIgH'><dir id='WxIgH'><q id='WxIgH'></q></dir></style></legend>

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

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