[問題] template argumet deduction fail

作者: notBeing (read and be read)   2016-09-30 00:33:26
開發平台(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的描述?謝謝
作者: CoNsTaR ((const *))   2016-09-30 07:10:00
E_A 不在 GG 的 scope 中啊

Links booklink

Contact Us: admin [ a t ] ucptt.com