diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 943290bb..9571e56a 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -134,6 +134,12 @@ namespace glm template GLM_FUNC_DECL GLM_EXPLICIT tvec1(tvec1 const & v); + /// Extra helper constructors for metaprogramming +# ifdef GLM_META_PROG_HELPERS + template + GLM_FUNC_DECL tvec1(X const& x, Y const&, Z const& = Z(0), W const& = W(0)); +# endif + // -- Swizzle constructors -- # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index 39485782..26c6f04f 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -93,6 +93,15 @@ namespace glm : x(static_cast(v.x)) {} + // -- Metaprogramming helper constructors -- +# ifdef GLM_META_PROG_HELPERS + template + template + GLM_FUNC_QUALIFIER tvec1::tvec1(X const& x, Y const&, Z const&, W const&) + : x(static_cast(x)) + {} +# endif + // -- Component accesses -- # ifdef GLM_FORCE_SIZE_FUNC diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 711a16a6..02443d89 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -80,6 +80,17 @@ int test_vec1_ctor() Error += std::is_copy_constructible::value ? 0 : 1; # endif +# ifdef GLM_META_PROG_HELPERS + { + glm::vec1 a(1), b(1, 2), c(1, 2, 3), d(1, 2, 3, 4); + + Error += (a == b) ? 0 : 1; + Error += (b == c) ? 0 : 1; + Error += (c == d) ? 0 : 1; + Error += (d == a) ? 0 : 1; + } +# endif + /* #if GLM_HAS_INITIALIZER_LISTS {