久久久久久久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 仍然相關嗎?)
主站蜘蛛池模板: 国产欧美精品 | 国产精品久久久久久久久大全 | 羞羞涩涩在线观看 | 国产中文区二幕区2012 | 自拍偷拍第一页 | 欧美精品在欧美一区二区 | 国产线视频精品免费观看视频 | 超碰成人免费 | 在线观看的av | 国产精品久久久久久高潮 | 国产黄色av电影 | www.天天操.com | 亚洲精品一区二区三区丝袜 | 午夜不卡福利视频 | 久久久久久久久久久久一区二区 | 亚洲国产精品va在线看黑人 | 欧美6一10sex性hd | 午夜寂寞影院列表 | 盗摄精品av一区二区三区 | 亚洲激情视频在线 | 欧美一级久久久猛烈a大片 日韩av免费在线观看 | 欧美精品中文字幕久久二区 | 国产成人精品一区二区在线 | 日韩av一区二区在线观看 | 久久亚洲一区二区三区四区 | 日日夜精品视频 | 91精品久久久久久久久久入口 | 视频国产一区 | 成人做爰9片免费看网站 | 精品国产乱码久久久久久蜜柚 | 国产成人叼嘿视频在线观看 | 成人精品久久日伦片大全免费 | 天天夜夜人人 | 久草青青草 | 国产精品资源在线观看 | 91.xxx.高清在线 | 欧美色综合一区二区三区 | 视频一区二区三区四区五区 | 精品视频一区二区三区 | 欧美激情精品久久久久久 | 91在线精品秘密一区二区 |