<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)則?GSL.view:視圖

          GSL.view: Views

          GSL.view:視圖

          These types allow the user to distinguish between owning and non-owning pointers and between pointers to a single object and pointers to the first element of a sequence.

          這些類型使用戶可以區(qū)分擁有和不擁有的指針,以及指向單個(gè)對(duì)象的指針和指向序列的第一個(gè)元素的指針。

          These "views" are never owners.

          這里的各種“view”絕不是所有者。

          References are never owners (see?R.4. Note: References have many opportunities to outlive the objects they refer to (returning a local variable by reference, holding a reference to an element of a vector and doing?push_back, binding to?std::max(x, y + 1), etc. The Lifetime safety profile aims to address those things, but even so?owner?does not make sense and is discouraged.

          引用永遠(yuǎn)都不是所有者(請(qǐng)參閱R.4.注意:引用有很多機(jī)會(huì)使它們引用的對(duì)象壽命更長(zhǎng)(通過引用返回局部變量,持有對(duì)vector元素的引用并進(jìn)行push_back,綁定到std :: max(x,y + 1)等)。生命周期安全規(guī)則群組旨在解決這些問題,但是即使如此,owner 也沒有意義,因此不建議使用。

          The names are mostly ISO standard-library style (lower case and underscore):

          名稱主要是ISO標(biāo)準(zhǔn)庫(kù)樣式(小寫和下劃線):

          • T*?// The?T*?is not an owner, might be null; assumed to be pointing to a single element.

            T * // T *不是所有者,可以為null;假定指向單個(gè)元素。

          • T&?// The?T&?is not an owner and can never be a "null reference"; references are always bound to objects.

            T&// T&不是所有者,永遠(yuǎn)不能是“空引用”;引用始終綁定到對(duì)象。

          The "raw-pointer" notation (e.g.?int*) is assumed to have its most common meaning; that is, a pointer points to an object, but does not own it. Owners should be converted to resource handles (e.g.,?unique_ptr?or?vector) or marked?owner.

          假定“原始指針”表示法(例如int *)具有最常見的含義;也就是說,指針指向一個(gè)對(duì)象,但不擁有它。所有者應(yīng)轉(zhuǎn)換為資源句柄(例如,unique_ptr或vector )或標(biāo)記為所有者

          • owner?// a?T*?that owns the object pointed/referred to; might be?nullptr.

            owner //一個(gè)T *,它擁有指向/引用的對(duì)象;可能為nullptr。

          owner?is used to mark owning pointers in code that cannot be upgraded to use proper resource handles. Reasons for that include:

          owner用于在無法升級(jí)為使用適當(dāng)資源句柄的代碼中標(biāo)記所有者指針。原因包括:

          • Cost of conversion.

            轉(zhuǎn)換成本。

          • The pointer is used with an ABI.

            該指針與ABI一起使用。

          • The pointer is part of the implementation of a resource handle.

            指針是資源句柄實(shí)現(xiàn)的一部分。

          An?owner?differs from a resource handle for a?T?by still requiring an explicit?delete.

          owner 與T的資源句柄不同,它仍然需要顯式刪除。

          An?owner?is assumed to refer to an object on the free store (heap).

          假定owner 引用自由存儲(chǔ)(堆)上的對(duì)象。

          If something is not supposed to be?nullptr, say so:

          如果不應(yīng)該使用nullptr,請(qǐng)這樣說:

          • not_null?//?T?is usually a pointer type (e.g.,?not_null?and?not_null>) that must not be?nullptr.?T?can be any type for which?==nullptr?is meaningful.

            not_null // T通常是一個(gè)指針類型(例如not_null 和not_null >),不能為nullptr。T可以是== nullptr有意義的任何類型。

          • span?//?[p:p+n), constructor from?{p, q}?and?{p, n};?T?is the pointer type

            span // [p:p + n),{p,q}和{p,n}的構(gòu)造函數(shù);T是指針類型

          • span_p?//?{p, predicate}?[p:q)?where?q?is the first element for which?predicate(*p)?is true

            span_p // {p,謂詞} [p:q)其中q是謂詞(* p)為true的第一個(gè)元素

          A?span?refers to zero or more mutable?Ts unless?T?is a?const?type.

          除非T是const類型,否則span 表示零個(gè)或多個(gè)可變Ts。

          "Pointer arithmetic" is best done within?spans. A?char*?that points to more than one?char?but is not a C-style string (e.g., a pointer into an input buffer) should be represented by a?span.

          最好在范圍完成“指針?biāo)阈g(shù)”。指向多個(gè)char但不是C樣式字符串的char *(例如,指向輸入緩沖區(qū)的指針)應(yīng)以span表示。

          • zstring?// a?char*?supposed to be a C-style string; that is, a zero-terminated sequence of?char?or?nullptr

            zstring //一個(gè)char *,應(yīng)該是C樣式的字符串;即char或nullptr的零終止序列

          • czstring?// a?const char*?supposed to be a C-style string; that is, a zero-terminated sequence of?const?char?or?nullptr

            czstring //一個(gè)const char *,應(yīng)該是C樣式的字符串;也就是說,一個(gè)以零結(jié)尾的const char或nullptr序列

          Logically, those last two aliases are not needed, but we are not always logical, and they make the distinction between a pointer to one?char?and a pointer to a C-style string explicit. A sequence of characters that is not assumed to be zero-terminated should be a?char*, rather than a?zstring. French accent optional.

          從邏輯上講,不需要最后兩個(gè)別名,但是我們并不總是合乎邏輯的,它們使指向一個(gè)char的指針和指向C樣式字符串的指針之間的區(qū)別變得明確。不假定以零結(jié)尾的字符序列應(yīng)該是char *,而不是zstring。法國(guó)口音可選。

          Use?not_null?for C-style strings that cannot be?nullptr. ??? Do we need a name for?not_null? or is its ugliness a feature?

          對(duì)于不能為nullptr的C樣式字符串,請(qǐng)使用not_null 。???我們需要一個(gè)not_null 的名稱嗎?還是它的丑陋功能?


          原文鏈接

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#gslview-views


          新書介紹

          《實(shí)戰(zhàn)Python設(shè)計(jì)模式》是作者最近出版的新書,拜托多多關(guān)注!

          本書利用Python 的標(biāo)準(zhǔn)GUI 工具包tkinter,通過可執(zhí)行的示例對(duì)23 個(gè)設(shè)計(jì)模式逐個(gè)進(jìn)行說明。這樣一方面可以使讀者了解真實(shí)的軟件開發(fā)工作中每個(gè)設(shè)計(jì)模式的運(yùn)用場(chǎng)景和想要解決的問題;另一方面通過對(duì)這些問題的解決過程進(jìn)行說明,讓讀者明白在編寫代碼時(shí)如何判斷使用設(shè)計(jì)模式的利弊,并合理運(yùn)用設(shè)計(jì)模式。

          對(duì)設(shè)計(jì)模式感興趣而且希望隨學(xué)隨用的讀者通過本書可以快速跨越從理解到運(yùn)用的門檻;希望學(xué)習(xí)Python GUI 編程的讀者可以將本書中的示例作為設(shè)計(jì)和開發(fā)的參考;使用Python 語言進(jìn)行圖像分析、數(shù)據(jù)處理工作的讀者可以直接以本書中的示例為基礎(chǔ),迅速構(gòu)建自己的系統(tǒng)架構(gòu)。




          覺得本文有幫助?請(qǐng)分享給更多人。

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

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



          瀏覽 86
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          <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>
                  18禁91 | 夜夜撸日日| 中文字幕人乱码中文字的预防方法 | 国产午夜黄色视频在线观看 | HYZEO神尾舞视频 |