diff --git a/inc/hgl/TypeFunc.h b/inc/hgl/TypeFunc.h index 31c7e27..852b657 100644 --- a/inc/hgl/TypeFunc.h +++ b/inc/hgl/TypeFunc.h @@ -1,9 +1,9 @@ -#ifndef HGL_TYPE_FUNC_INCLUDE -#define HGL_TYPE_FUNC_INCLUDE +#pragma once #include #include #include + namespace hgl { #define HGL_OFFICAL_WEB "www.hyzgame.com" @@ -12,6 +12,11 @@ namespace hgl #define ENUM_CLASS_RANGE(begin,end) BEGIN_RANGE=begin,END_RANGE=end,RANGE_SIZE=(END_RANGE-BEGIN_RANGE)+1 + template constexpr const int ToInt(const T &ec){return (int)ec;} + template constexpr const T FromInt(int ec){return (enum class T)ec;} + + template constexpr const size_t RangeSize(){return T::RANGE_SIZE;} + template inline bool RangeCheck(const T &value) { @@ -493,4 +498,3 @@ namespace hgl hgl_free(items); } }//namespace hgl -#endif//HGL_TYPE_FUNC_INCLUDE