<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++核心準(zhǔn)則ES.60:避免在資源管理函數(shù)之外使用new和delete

          6140aec2496f68e85ced8be899cb3b36.webp

          ES.60: Avoid?new?and?delete?outside resource management functions

          ES.60:避免在資源管理函數(shù)之外使用new和delete


          Reason(原因)

          Direct resource management in application code is error-prone and tedious.

          在應(yīng)用代碼中直接進(jìn)行資源管理麻煩且易錯(cuò)。


          Note(注意)

          This is also known as the rule of "No naked?new!"

          本準(zhǔn)則也被稱為“禁止暴露的new操作”


          Example, bad(反面示例)

          void f(int n)
          {
          auto p = new X[n]; // n default constructed Xs
          // ...
          delete[] p;
          }

          There can be code in the?...?part that causes the?delete?never to happen.

          在...省略的位置的代碼可以讓delete操作永遠(yuǎn)不發(fā)生。


          See also:?R: Resource management

          參見:R:資源管理規(guī)則群組

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r-resource-management


          Enforcement(實(shí)施建議)

          Flag naked?news and naked?deletes.

          標(biāo)記暴露的new和delete操作。


          原文鏈接

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es60-avoid-new-and-delete-outside-resource-management-functions



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

          關(guān)注微信公眾號【面向?qū)ο笏伎肌枯p松學(xué)習(xí)每一天!

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


          瀏覽 44
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          <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>
                  www操逼 | 波多野结衣一区久久在线观看 | 日韩黄色操少妇视频 | 三级网站成人 | 大香蕉75在线 |