Re: Using C++ enums like C# enums

I found out that only the Microsoft allows you to forward declare enums, but standard compliant compilers do not allow it since its size is not yet known.

I could use an int rather than the enum variable to get around the problem, but I prefer to be able to see what the enum is set to, so here is the macro to make the code work in non-Microsoft compilers.

#define ATHENA_START_CSHARP_ENUM( x )	 \
struct x	 			 \
{	 			 \
public:				 \
	enum EnumType
 
#define ATHENA_END_CSHARP_ENUM( x )	 \
	;			 \
				 \
 	inline x()		 \
	{			 \
	}			 \
					 \
	template<typename T>	 \
	inline x( const T & inValue )	 \
		:	 \
		value( (EnumType)inValue )	 \
	{	 \
	}	 \
		\
	inline x( const EnumType inValue )	 \
		:	 \
		value( inValue )	 \
	{	 \
	}	 \
		\
	inline void operator = ( const EnumType inValue )	 \
	{	 \
		value = inValue;	 \
	}	 \
\
	inline EnumType operator ~ () const	 \
	{	 \
		return (EnumType)~value;	 \
	}	 \
\
	inline EnumType operator & ( const EnumType inValue ) const	\
	{	 \
		return (EnumType)( value & inValue );	 \
	}	 \
\
	inline operator EnumType () const	 \
	{	 \
		return value;	 \
	}	 \
\
private:	 \
	EnumType value;	 \
}