enum to int?

pok의 이미지

flag property 클래스를 하나 만들고 있습니다.

//! Flag property, none size limited version
template
<
	typename T_HasFlags,
	typename T_FlagProperty = typename T_HasFlags::E_FLAG_PROPERTY,
	int T_Size = typename T_HasFlags::E_FLAG_NUM
>
class EFlagPropertyEx
{
public:
 
	//! constructor
	EFlagPropertyEx(){}
 
	//! destructor
	~EFlagPropertyEx(){}
 
	//! sets property value (true or false)
	void set(T_FlagProperty _prop, bool _flag)
	{
		bitset_.set( (size_t)_prop, _flag);
	}
 
	//! tests property value
	bool test(T_FlagProperty _prop)
	{
		return bitset_.test( (size_t)_prop );
	}
 
private:
	std::bitset< T_Size > bitset_;
};

다음과 같이 쓰고 싶습니다.

class A
{
enum E_FLAG_PROPERTY
{
  E_SOSI_LOVE = 0,
  E_KARA_LOVE,
  E_FX_LOVE,
 
...
  E_FLAG_NUM
};
 
EFlagPropertyEx<A> properties;
};

그런데, 이게 vc9에서는 컴파일이 되는데 g++ 3.4.4 버전에는 컴파일이 안되네요. T_HasFlags::E_FLAG_NUM 이것이 int 형이 아니라서 생기는것 같은데, 좋은 방법 없을까요?
hys545의 이미지

즐린

컴파일러에 따라 암묵적 형변환이 되는 경우가 있지만
원래는 안되는게 정상입니다.

즐린