Index: /trunk/nv/flags.hh
===================================================================
--- /trunk/nv/flags.hh	(revision 177)
+++ /trunk/nv/flags.hh	(revision 178)
@@ -20,4 +20,22 @@
 namespace nv
 {
+	template< typename T, typename IS_ENUM >
+	struct base_underlying_type_helper
+	{
+		typedef T type;
+	};
+
+	template< typename T >
+	struct base_underlying_type_helper< T, std::true_type >
+	{
+		typedef typename std::underlying_type<T>::type type;
+	};
+
+
+	template< typename T >
+	struct base_underlying_type
+	{
+		typedef typename base_underlying_type_helper< T, typename std::is_enum<T>::type >::type type;
+	};
 
 	template < uint32 SIZE, typename T = uint32 >
@@ -65,5 +83,5 @@
 		typedef T      index_type;
 		typedef uint32 size_type;
-		typedef typename std::underlying_type<T>::type raw_index_type;
+		typedef typename base_underlying_type<T>::type raw_index_type;
 
 		static const size_type data_type_size = sizeof( data_type ) * 8;
