[問題] C++ SLT map<struct*,int> 的行為??

看板C_and_CPP (C/C++)作者 (路人甲)時間5年前 (2020/06/01 11:25), 編輯推噓1(103)
留言4則, 3人參與, 5年前最新討論串1/1
最近在trace C++的程式碼 碰到的問題 想請問 STL的map 如果是把struct或class的指標當作key 讓它對應到int map的行為會是把指標指向的地址當作key 還是會把struct/class裡的所有成員變數當作key啊?? 感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.16.173 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1590981956.A.F06.html

06/01 11:33, 5年前 , 1F
要看你第三個參數型別是怎麼被 instantiate
06/01 11:33, 1F

06/01 17:03, 5年前 , 2F
你沒特別寫他要怎麼知道要怎麼用你的member 當key?
06/01 17:03, 2F

06/01 17:58, 5年前 , 3F
根據你的標題所述,不考慮explicit specialization
06/01 17:58, 3F

06/01 17:58, 5年前 , 4F
的話是用pointer的operator<()
06/01 17:58, 4F
文章代碼(AID): #1Ur7L4y6 (C_and_CPP)
文章代碼(AID): #1Ur7L4y6 (C_and_CPP)