[問題] shared_ptr與unique_ptr支援的operators

看板C_and_CPP (C/C++)作者 (眾生都是未來佛)時間12年前 (2014/02/16 22:46), 編輯推噓0(006)
留言6則, 2人參與, 最新討論串1/1
最近在研究shared_ptr與unique_ptr。 我想知道它們支援哪些operators,所以就查了MSDN: http://msdn.microsoft.com/zh-tw/library/ee410601.aspx 但沒有發現上面有寫支援operator[]。 但我實際用VC++ 2013,確實可以使用operator[]。 例如: unique_ptr<int[]> a(new int[5]); a[0] = 3; cout << a[0]; 後來查了Boost文件也是沒看到: http://www.boost.org/doc/libs/1_37_0/doc/html/boost/interprocess/unique_ptr.html 縮:http://bit.ly/1eEDtMP 請問operator[]到底是不是C++11 unique_ptr標準定義的東西? -- 楞嚴咒(附注音): http://sdrv.ms/130iapv -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 1.34.170.182 ※ 編輯: zxvc 來自: 1.34.170.182 (02/16 22:46)

02/16 23:42, , 1F
陣列有[]沒*和->, 一般則相反
02/16 23:42, 1F

02/16 23:43, , 2F
shared_ptr 則沒矩陣版
02/16 23:43, 2F

02/17 09:51, , 3F
謝謝F大的提示。我查了一下,MSDN在這個網頁有提到array版的
02/17 09:51, 3F

02/17 09:52, , 4F
02/17 09:52, 4F

02/17 09:54, , 5F
只是為何MSDN跟Boost網頁不明顯分開列兩種版本就不知為什麼。
02/17 09:54, 5F

02/17 09:57, , 6F
cppreference.com則有寫明確支援operator[]。
02/17 09:57, 6F
文章代碼(AID): #1J0CyeMz (C_and_CPP)
文章代碼(AID): #1J0CyeMz (C_and_CPP)