1234567891011121314151617181920212223242526272829303132333435 |
- // // ******************************************************************
- // // /\ /| @File CommonHelper.h
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-05-16
- // // / \\ @Modified 2024-05-16
- // // *(__\_\
- // // ******************************************************************
- #pragma once
- #include <type_traits>
- #include <typeinfo>
- namespace Protocol
- {
- class CommonHelper
- {
- public:
- template <typename EnumType>
- static bool EnumIsDefined(int value)
- {
- static_assert(std::is_enum_v<EnumType>, "EnumType must be an enumeration type");
- return std::underlying_type_t<EnumType>(value) >= 0;
- }
- template <typename EnumType>
- struct EnumTypeInfo
- {
- static const std::type_info& GetTypeInfo()
- {
- return typeid(EnumType);
- }
- };
- };
- }
|