久久久久久久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 仍然相關嗎?)
主站蜘蛛池模板: 国产精品一区一区三区 | 久草免费福利 | 成人伊人网 | 亚洲国产精品久久久 | 亚洲欧美日韩一区 | 在线免费观看黄 | 久久少妇视频 | 国产成人一区二区 | 夜夜操影院| 日韩亚洲欧美在线 | av在线精品 | 亚洲 欧美 日韩 在线 | 黄色免费片 | 国产激情网站 | 视频爱爱免费视频爱爱太爽 | 亚洲黄色一级 | 国产三级视频 | 国产视频一区二区在线播放 | 国产美女一区 | 成 人 黄 色 片 在线播放 | 久久视频免费看 | 日韩成人综合 | 亚洲精品黄 | 日韩免费高清 | 国产1级片| av免费观看网址 | 亚洲精品久久久久avwww潮水 | 国产高潮在线观看 | 免费91网站 | 日韩中文字幕在线 | 久热综合 | 日本欧美久久久久免费播放网 | 欧美一级在线观看 | 少妇一级淫片免费看 | 99热精品在线观看 | 免费视频一区 | 毛片毛片毛片毛片毛片 | 一区二区三区四区视频在线观看 | 女人高潮特级毛片 | 国产高清视频在线观看 | 成人在线播放视频 |