diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 521e8ccc..1650a9c5 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -140,6 +140,12 @@ namespace glm template GLM_FUNC_DECL GLM_EXPLICIT tvec2(tvec2 const & v); + /// Extra helper constructors for metaprogramming +# ifdef GLM_META_PROG_HELPERS + template + GLM_FUNC_DECL tvec2(X const& x, Y const& y, Z const& z, W const& w = W(0)); +# endif + // -- Swizzle constructors -- # if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 39d0549e..daa43f6c 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -107,6 +107,15 @@ namespace glm , y(static_cast(v.y)) {} + // -- Metaprogramming helper constructors -- +# ifdef GLM_META_PROG_HELPERS + template + template + GLM_FUNC_QUALIFIER tvec2::tvec2(X const& x, Y const& y, Z const&, W const&) + : x(static_cast(x)), y(static_cast(y)) + {} +# endif + // -- Component accesses -- # ifdef GLM_FORCE_SIZE_FUNC diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 69b5957e..a4821bc0 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -235,6 +235,16 @@ int test_vec2_ctor() Error += A == B ? 0 : 1; } +# ifdef GLM_META_PROG_HELPERS + { + glm::vec2 a(1, 2), b(1, 2, 3), c(1, 2, 3, 4); + + Error += (a == b) ? 0 : 1; + Error += (b == c) ? 0 : 1; + Error += (c == a) ? 0 : 1; + } +# endif + # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1;