When passing forward declared struct or a class, one has to pass it to a function through a reference or a pointer.
But, what can be done with a forward declared enum? Does it also have to be passed through a reference or a pointer? Or, can it be passed with a value?
Next example compiles fine using g++ 4.6.1 :
#include <iostream>
enum class E;
void foo( const E e );
enum class E
{
V1,
V2
};
void foo( const E e )
{
switch ( e )
{
case E::V1 :
std::cout << "V1"<<std::endl;
break;
case E::V2 :
std::cout << "V2"<<std::endl;
break;
default:
;
}
}
int main()
{
foo( E::V1);
foo( E::V2);
}
To build :
g++ gy.cpp -Wall -Wextra -pedantic -std=c++0x -O3
Is the above standard compliant, or is it using an extension?