KMT_EX_PP_MATH_VEC_MAKE_TYPE_TRAITS_VALUE
例によって、マクロを使用して、is_vec の自動生成を行います。
#include#include #include "vec/vec.hpp" #include "vec/type_traits/is_vec.hpp" #include "vec/preprocessor/make_type_traits_is_vec.hpp" /** D3DVECTOR の特殊化 */ KMT_EX_PP_MATH_VEC_MAKE_TYPE_TRAITS_IS_VEC(D3DVECTOR); #include "vec/preprocessor/undef_make_type_traits_is_vec.hpp" namespace vec = kmt_ex::math::vec; int main(){ typedef vec::vec<3, float> vec3; std::cout << vec::is_vec ::value << "\n"; // 1 std::cout << vec::is_vec ::value << "\n"; // 1 std::cout << vec::is_vec ::value << "\n"; // 0 }
#include "vec/preprocessor/make_type_traits_is_vec.hpp"
で、マクロを定義して、
#include "vec/preprocessor/undef_make_type_traits_is_vec.hpp"
で、#undef しています。
★追記
コピペミスでマクロ定義の引数が思いっきり間違っていたので修正。
/** vec::value のテンプレートの特殊化の簡易生成を行う ※内部で namespace でくくっているので、 グローバル空間での定義を行う */ #ifndef KMT_EX_PP_MATH_VEC_MAKE_TYPE_TRAITS_IS_VEC #define KMT_EX_PP_MATH_VEC_MAKE_TYPE_TRAITS_IS_VEC(class_t) \ namespace kmt_ex{ namespace math{ namespace vec{ \ \ template<> \ struct is_vec{ \ static const bool value = true; \ }; \ \