[問題] CRTP 如何寫return type?

作者: lovejomi (JOMI)   2018-11-07 00:56:44
這標題有點難下...
目前使用C++11 我有需求想寫CRTP 的寫法
發現我有個盲點
https://ideone.com/A480at
我發現我根本對於 derived class的function return type無法掌握
C++14直接寫auto真的不用想太多
但是若在C++11 或更早的C++ 是不是做不到?
C++11試圖寫 -> decltype(????) 裡面不知道怎麼寫
C++98 是完全不知道怎麼寫?
請教一下
謝謝
作者: notBeing (read and be read)   2018-11-07 01:46:00
用 typedef 不行嗎?
作者: ibmibmibm (BestSteve)   2018-11-08 00:35:00
std::result_of,或是decltype(...)-> decltype(static_cast<T*>(this)->VirtualFuncImpl)
作者: PkmX (阿貓)   2018-11-08 21:42:00
樓上的編譯不會過吧...https://wandbox.org/permlink/YeHhtbGpRscoBA8m C++11解法

Links booklink

Contact Us: admin [ a t ] ucptt.com