diff --git a/Reflection/Struct.cpp b/Reflection/Struct.cpp index 0c175c431..2a2d80736 100644 --- a/Reflection/Struct.cpp +++ b/Reflection/Struct.cpp @@ -11,6 +11,7 @@ #include #include #include +#include // MARK: - Setters @@ -113,11 +114,20 @@ template bool Reflection::get(const Struct &target, const std::s const auto target_type = target.type_of(name); if(!target_type) return false; + // If type is a direct match, copy. if(*target_type == typeid(Type)) { memcpy(&value, target.get(name), sizeof(Type)); return true; } + // If the type is a registered enum and the value type is int, copy. + if constexpr (std::is_integral::value && sizeof(Type) == sizeof(int)) { + if(!Enum::name(*target_type).empty()) { + memcpy(&value, target.get(name), sizeof(int)); + return true; + } + } + return false; }