[問題] CRTP 如何寫return type?

看板C_and_CPP作者 (JOMI)時間6年前 (2018/11/06 16:56), 編輯推噓0(005)
留言5則, 3人參與, 6年前最新討論串1/1
這標題有點難下... 目前使用C++11 我有需求想寫CRTP 的寫法 發現我有個盲點 https://ideone.com/A480at 我發現我根本對於 derived class的function return type無法掌握 C++14直接寫auto真的不用想太多 但是若在C++11 或更早的C++ 是不是做不到? C++11試圖寫 -> decltype(????) 裡面不知道怎麼寫 C++98 是完全不知道怎麼寫? 請教一下 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 110.26.160.166 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1541523408.A.896.html

11/07 01:46, 6年前 , 1F
用 typedef 不行嗎?
11/07 01:46, 1F

11/08 00:35, 6年前 , 2F
std::result_of,或是decltype(...)
11/08 00:35, 2F

11/08 00:35, 6年前 , 3F
-> decltype(static_cast<T*>(this)->VirtualFuncImpl)
11/08 00:35, 3F

11/08 21:42, 6年前 , 4F
樓上的編譯不會過吧...
11/08 21:42, 4F

11/08 21:43, 6年前 , 5F
文章代碼(AID): #1RuSVGYM (C_and_CPP)