• <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. 是否可以将指针重新解释为维度数组引用?

        Is it possible to reinterpret pointer as dimensioned array reference?(是否可以将指针重新解释为维度数组引用?)
        <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++ stl unordered_map implementation, reference validity(C++ stl unordered_map 实现,参考有效性)
                  C++: Is it possible to use a reference as the value in a map?(C++:是否可以使用引用作为映射中的值?)
                  Where ampersand quot;amp;quot; can be put when passing argument by reference?(其中符号“amp;通过引用传递参数时可以放置吗?)
                  Why can a non-const reference parameter be bound to a temporary object?(为什么可以将非常量引用参数绑定到临时对象?)
                  What is a dangling reference?(什么是悬空引用?)
                  C++ reference changes when push_back new element to std::vector(当 push_back 新元素到 std::vector 时,C++ 引用发生变化)
                    <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>
                        <tbody id='ViJts'></tbody>

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