[問題] template argumet deduction fail

看板C_and_CPP (C/C++)作者 (read and be read)時間9年前 (2016/09/30 00:33), 9年前編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
開發平台(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

09/30 07:10, , 1F
E_A 不在 GG 的 scope 中啊
09/30 07:10, 1F
文章代碼(AID): #1NxK9O1U (C_and_CPP)
文章代碼(AID): #1NxK9O1U (C_and_CPP)