• <small id='0en5Y'></small><noframes id='0en5Y'>

    <legend id='0en5Y'><style id='0en5Y'><dir id='0en5Y'><q id='0en5Y'></q></dir></style></legend>

        <bdo id='0en5Y'></bdo><ul id='0en5Y'></ul>

      1. <i id='0en5Y'><tr id='0en5Y'><dt id='0en5Y'><q id='0en5Y'><span id='0en5Y'><b id='0en5Y'><form id='0en5Y'><ins id='0en5Y'></ins><ul id='0en5Y'></ul><sub id='0en5Y'></sub></form><legend id='0en5Y'></legend><bdo id='0en5Y'><pre id='0en5Y'><center id='0en5Y'></center></pre></bdo></b><th id='0en5Y'></th></span></q></dt></tr></i><div id='0en5Y'><tfoot id='0en5Y'></tfoot><dl id='0en5Y'><fieldset id='0en5Y'></fieldset></dl></div>
        <tfoot id='0en5Y'></tfoot>
      2. 是否可以将指针重新解释为维度数组引用?

        时间:2023-12-03
        <legend id='RfKmC'><style id='RfKmC'><dir id='RfKmC'><q id='RfKmC'></q></dir></style></legend>

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

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

          <tfoot id='RfKmC'></tfoot>

                  <bdo id='RfKmC'></bdo><ul id='RfKmC'></ul>
                  本文介绍了是否可以将指针重新解释为维度数组引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我有一些指针,我想将其重新解释为静态维度数组引用:

                  Suppose I have some pointer, which I want to reinterpret as static dimension array reference:

                  double *p;
                  double (&r)[4] = ?(p); // some construct?
                  
                  // clarify
                  template< size_t N> void function(double (&a)[N]);
                  ...
                   double *p;
                  function(p); // this will not work.
                  //  I would like to cast p as to make it appear as  double[N]
                  

                  可以这样做吗?我该怎么做?

                  Is it possible to do so? how do I do it?

                  推荐答案

                  太丑了:

                  double arr[4];
                  double* d = arr;
                  
                  double (&a)[4] = *static_cast<double(*)[4]>(static_cast<void*>(d));
                  

                  确保数组类型与指针最初来自的类型相匹配.

                  Be sure the array type matches what the pointer originally came from.

                  这篇关于是否可以将指针重新解释为维度数组引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C++ 将数组的引用传递给函数 下一篇:C++ 的 Sublime Text 自动完成插件?

                  相关文章

                    <bdo id='ViJts'></bdo><ul id='ViJts'></ul>

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

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

                    1. <legend id='ViJts'><style id='ViJts'><dir id='ViJts'><q id='ViJts'></q></dir></style></legend>