[英]C++: enum type as template argument - global scope
我有這種情況:
template<typename myEnumType>
int foo(const myEnumType & shortest_paths_algorithm)
{
...
}
int main()
{
myEnumType enum_type_istance;
int a = foo(enum_type_istance)
}
如果我宣布
typedef enum {AAA, BBB} myEnumType;
在函數聲明之前一切正常。 然而,如果我在創建enum_type_istance變量之前編寫上面的行,請獲取錯誤
沒有用於調用'foo(main():: myEnumType&)'候選者的匹配函數是:template int foo(const myEnumType&)
為什么??? 我怎樣才能在主內部進行類型定義? 謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.