[問題] C++ STL custom allocator 的初始化問題

看板C_and_CPP (C/C++)作者 (私は幸せです)時間9年前 (2017/02/21 15:31), 9年前編輯推噓5(505)
留言10則, 4人參與, 最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) Linux 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) Clang/LLVM 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) libstdc++ 問題(Question): 無法排序,缺少一個匹配的函式 餵入的資料(Input):預期的正確結果(Expected Output): 正確編譯 錯誤結果(Wrong Output): 編譯失敗 http://pastebin.com/raw/NrkcKpMc 程式碼(Code):(請善用置底文網頁, 記得排版) http://pastebin.com/raw/LThxMpcn ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.66.155 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1487662277.A.E9B.html ※ 編輯: Hazukashiine (140.113.136.217), 02/21/2017 16:05:40

02/21 16:31, , 1F
explicit拿掉
02/21 16:31, 1F

02/21 16:33, , 2F
Allocator concept有規定要支援 Allocator a=other;
02/21 16:33, 2F

02/21 16:33, , 3F
這樣的用法
02/21 16:33, 3F
感謝大大QQ 那那那我可以把所有的 explicit 都拿掉嗎~~? ※ 編輯: Hazukashiine (140.113.66.155), 02/21/2017 17:00:54

02/21 22:25, , 4F
兩個有帶參數的都要拿掉 沒參數的那個應該沒差?
02/21 22:25, 4F

02/21 23:39, , 5F
不確定耶 但是全部都拿掉能正確編譯 OwO
02/21 23:39, 5F

02/22 11:07, , 6F
default ctor帶explicit有什麼用@@?
02/22 11:07, 6F

02/22 11:43, , 7F
不知道耶 我是參考這篇的 https://goo.gl/QlRPj7
02/22 11:43, 7F

02/22 17:19, , 8F
那一堆inline是多餘的吧?
02/22 17:19, 8F

02/22 19:22, , 9F
印象中寫在 class 裡面好像就是預設 inline 的樣子
02/22 19:22, 9F

02/23 21:05, , 10F
default ctor帶explicit會不讓你用A a={};這樣
02/23 21:05, 10F
文章代碼(AID): #1Og-p5wR (C_and_CPP)
文章代碼(AID): #1Og-p5wR (C_and_CPP)