- gcc/clang didn't like having this in a class

This commit is contained in:
Magnus Norddahl 2018-12-03 23:39:03 +01:00
parent ae44b936eb
commit 14919f49ec
1 changed files with 14 additions and 11 deletions

View File

@ -561,6 +561,19 @@ struct FieldDesc
int BitValue;
};
namespace
{
// Traits for the types we are interested in
template<typename T> struct native_is_valid { static const bool value = false; };
template<typename T> struct native_is_valid<T*> { static const bool value = true; };
template<typename T> struct native_is_valid<T&> { static const bool value = true; };
template<> struct native_is_valid<void> { static const bool value = true; };
template<> struct native_is_valid<int> { static const bool value = true; };
template<> struct native_is_valid<unsigned int> { static const bool value = true; };
template<> struct native_is_valid<double> { static const bool value = true; };
template<> struct native_is_valid<bool> { static const bool value = true; };
}
// Compile time validation of direct native functions
struct DirectNativeDesc
{
@ -582,17 +595,7 @@ struct DirectNativeDesc
#undef TP
#undef VP
template<typename T> void ValidateType() { static_assert(is_valid<T>::value, "Argument type is not valid as a direct native parameter or return type"); }
// Traits for the types we are interested in
template<typename T> struct is_valid { static const bool value = false; };
template<typename T> struct is_valid<T*> { static const bool value = true; };
template<typename T> struct is_valid<T&> { static const bool value = true; };
template<> struct is_valid<void> { static const bool value = true; };
template<> struct is_valid<int> { static const bool value = true; };
template<> struct is_valid<unsigned int> { static const bool value = true; };
template<> struct is_valid<double> { static const bool value = true; };
template<> struct is_valid<bool> { static const bool value = true; };
template<typename T> void ValidateType() { static_assert(native_is_valid<T>::value, "Argument type is not valid as a direct native parameter or return type"); }
operator void *() const { return Ptr; }