看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) g++, C++98 問題(Question): function template無法從傳入的argument推導出對應的parameter type 程式碼(Code):(請善用置底文網頁, 記得排版) /* Header.h */ class A { public: enum E_A { eNone, //... }; typedef enum E_A E; }; class GG { public: template <class L> bool Foo(typename L::E eLE) { //... } }; /* Main.cpp */ #include "Header.h" int main() { GG objGG; objGG.Foo<A>(A::eNone); // ok objGG.Foo(A::eNone); // fail return 0; } 補充說明(Supplement):Compiler Info 1. no matching function for call to ‘GG::Foo(A::E_A)’ 2. template argument deduction/substitution failed: 3. couldn't deduce template parameter ‘L’ 請問deduction的機制中,是否在文件上有特別指明A::eNone這種形式的argument, 無法deduce出A的描述?謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.224.55.30 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1475166808.A.05E.html ※ 編輯: notBeing (36.224.55.30), 09/30/2016 00:34:00
CoNsTaR: E_A 不在 GG 的 scope 中啊 09/30 07:10