C ++: enumeration type as template argument - global scope

I have 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 announce

typedef enum {AAA, BBB} myEnumType;

before the function declaration, everything is in order. Although, if I write the above line before creating the enum_type_istance variable, I get an error

there is no corresponding function to call 'foo (main () :: myEnumType &) candidate: template int foo (const myEnumType &)

why??? How can I determine the type inside the main? thank!

+3
source share
1 answer

++ ++ 11, "" . , , ++ 11. , -std=c++11, .

+4

All Articles