diff --git a/core/src/Cabana_AoSoA.hpp b/core/src/Cabana_AoSoA.hpp index 985c411b2..78b93f10a 100644 --- a/core/src/Cabana_AoSoA.hpp +++ b/core/src/Cabana_AoSoA.hpp @@ -118,6 +118,8 @@ class AoSoA // Member data types. static_assert( is_member_types::value, "AoSoA data types must be member types" ); + static_assert( CheckMemberTypes::value, + "AoSoA data type failure" ); using member_types = DataTypes; // Device type. diff --git a/core/src/Cabana_MemberTypes.hpp b/core/src/Cabana_MemberTypes.hpp index c19eae625..0c26974ec 100644 --- a/core/src/Cabana_MemberTypes.hpp +++ b/core/src/Cabana_MemberTypes.hpp @@ -74,6 +74,54 @@ struct MemberTypeAtIndex> using type = typename MemberTypeAtIndexImpl::type; }; +//---------------------------------------------------------------------------// +/*! + \class CheckMemberTypes + \brief Check that member types are valied. +*/ +template +struct CheckMemberTypesImpl; + +template +struct CheckMemberTypesImpl<0, T, Types...> +{ + using type = T; + static_assert( std::is_trivial::value, + "Member types must be trivial" ); + + using value_type = typename std::remove_all_extents::type; + static_assert( std::is_arithmetic::value, + "Member value types must be arithmetic" ); + + // Return true so we get the whole stack to evaluate all the assertions. + static constexpr bool value = true; +}; + +template +struct CheckMemberTypesImpl +{ + using type = T; + static_assert( std::is_trivial::value, + "Member types must be trivial" ); + + using value_type = typename std::remove_all_extents::type; + static_assert( std::is_arithmetic::value, + "Member value types must be arithmetic" ); + + static constexpr bool value = CheckMemberTypesImpl::value; +}; + +template +struct CheckMemberTypes; + +template +struct CheckMemberTypes> +{ + static constexpr int size = MemberTypes::size; + static constexpr bool value = + CheckMemberTypesImpl::value; +}; + //---------------------------------------------------------------------------// } // end namespace Cabana