久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

C++11 中 COW std::string 實現的合法性

Legality of COW std::string implementation in C++11(C++11 中 COW std::string 實現的合法性)
本文介紹了C++11 中 COW std::string 實現的合法性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

據我所知,寫時復制不是在 C++11 中實現符合標準的 std::string 的可行方法,但是當它最近在討論中出現時,我發現我自己無法直接支持這種說法.

It had been my understanding that copy-on-write is not a viable way to implement a conforming std::string in C++11, but when it came up in discussion recently I found myself unable to directly support that statement.

C++11 不承認基于 COW 的 std::string 實現,我是否正確?

Am I correct that C++11 does not admit COW based implementations of std::string?

如果是,這個限制是否在新標準(where)的某處明確說明?

If so, is this restriction explicitly stated somewhere in the new standard (where)?

或者這個限制是隱含的,從某種意義上說,這是對 std::string 的新要求的綜合影響,排除了基于 COW 的 std::string.在這種情況下,我會對C++11 有效禁止基于 COW 的 std::string 實現"的章節和詩句風格派生感興趣.

Or is this restriction implied, in the sense that it is the combined effect of the new requirements on std::string that precludes a COW based implementation of std::string. In this case, I'd be interested in a chapter and verse style derivation of 'C++11 effectively prohibits COW based std::string implementations'.

推薦答案

這是不允許的,因為按照標準 21.4.1 p6,迭代器/引用失效只允許

It's not allowed, because as per the standard 21.4.1 p6, invalidation of iterators/references is only allowed for

——作為任何標準庫函數的參數引用將非常量 basic_string 作為參數.

— as an argument to any standard library function taking a reference to non-const basic_string as an argument.

——調用非常量成員函數,除了 operator[]、at、front、back、begin、rbegin、結束,然后撕裂.

— Calling non-const member functions, except operator[], at, front, back, begin, rbegin, end, and rend.

對于 COW 字符串,調用非常量 operator[] 將需要進行復制(并使引用無效),這是上一段所不允許的.因此,在 C++11 中使用 COW 字符串不再合法.

For a COW string, calling non-const operator[] would require making a copy (and invalidating references), which is disallowed by the paragraph above. Hence, it's no longer legal to have a COW string in C++11.

這篇關于C++11 中 COW std::string 實現的合法性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉換為 HSV 并將 HSV 轉換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉換為字符串?)
When to use inline function and when not to use it?(什么時候使用內聯函數,什么時候不使用?)
Examples of good gotos in C or C++(C 或 C++ 中好的 goto 示例)
Significance of ios_base::sync_with_stdio(false); cin.tie(NULL);(ios_base::sync_with_stdio(false) 的意義;cin.tie(NULL);)
Is TCHAR still relevant?(TCHAR 仍然相關嗎?)
主站蜘蛛池模板: 欧美亚洲另类在线 | 中文字幕久久精品 | 国产jizz女人多喷水99 | 欧美在线一二三 | 午夜视频在线观看一区二区 | 欧美aaa一级片 | 亚洲自拍偷拍免费视频 | 日韩在线免费 | 91免费高清视频 | 国产精品一区二区久久久久 | 在线看片福利 | 亚洲一二三区精品 | 日本一区二区三区精品视频 | 久久99深爱久久99精品 | 最新伦理片| 欧美激情亚洲天堂 | 国产成人一区二区 | 欧美亚洲激情 | 日韩第一页 | 免费三级黄 | 久久亚洲一区 | 国产精品欧美一区喷水 | 亚洲a视频 | 亚洲91精品 | 国产精品美女www爽爽爽视频 | 国产精品免费av | 久久成人免费观看 | 国产日韩久久 | 综合九九 | 亚洲精品视频观看 | 国产一区二区三区在线观看免费 | 日日爱av| 中文字幕精品一区二区三区精品 | 成人 在线 | 欧美日韩成人 | 欧美a∨ | 亚洲国产一区二区三区 | 夜夜草 | 狠狠色香婷婷久久亚洲精品 | 国产精品久久久久久久久 | 波多野结衣亚洲 |