Reputation: 1749
I've a this situation:
template<typename myEnumType>
int foo(const myEnumType & shortest_paths_algorithm)
{
...
}
int main()
{
myEnumType enum_type_istance;
int a = foo(enum_type_istance)
}
if I declare
typedef enum {AAA, BBB} myEnumType;
before the function declaration everything is ok. While, if I write the above line before creating enum_type_istance variable, get the error
no matching function for call to ‘foo(main()::myEnumType&)’ candidate is: template int foo(const myEnumType&)
why??? how can I type-define inside the main? thank you!
Upvotes: 3
Views: 373
Reputation: 76240
You are using C++ prior to C++11, which does not allow "local" types to be used in template arguments. This feature has been, luckily, introduced in C++11. As you can see it compiles just fine with the -std=c++11
flag, while it fails without.
Upvotes: 4