<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          C++核心準則R.4: 原始引用(T&)不包含所有權(quán)

          c51c93b008c9261339d0ee9076e88bfa.webp

          R.4: A raw reference (a?T&) is non-owning

          R.4:?原始引用(T&)不包含所有權(quán)



          Reason(原因)

          There is nothing (in the C++ standard or in most code) to say otherwise and most raw references are non-owning. We want owners identified so that we can reliably and efficiently delete the objects pointed to by owning pointers.

          這一點不存在例外(無論是C++標準還是大部分代碼中),實際上大多數(shù)原始引用就是不包含所有權(quán)的。我希望所有者被明確下來以便我們可以可靠而且高效的刪除所有權(quán)指針指向的對象。


          Example(示例)

          void f()
          {
          int& r = *new int{7}; // bad: raw owning reference
          // ...
          delete &r; // bad: violated the rule against deleting raw pointers
          }

          See also:?The raw pointer rule:

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rr-ptr

          參見原始指針原則。


          Enforcement(實施建議)

          See the raw pointer rule:

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGidelines.md#Rr-ptr

          參見原始指針原則


          原文鏈接:

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r3-a-raw-pointer-a-t-is-non-owning




          覺得本文有幫助?請分享給更多人。

          關(guān)注【面向?qū)ο笏伎肌枯p松學習每一天!

          面向?qū)ο箝_發(fā),面向?qū)ο笏伎迹?/span>

          瀏覽 40
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  北条麻妃av无码一区二区 | 亚洲操肥婆 | 色丁香午夜婷 | 污污污污污污污污污网站 | 激情五月天网站 |