Fixed defaulted operator= and constructors #791

This commit is contained in:
Groove 2018-07-28 22:53:57 +02:00
parent 8e8d046587
commit 5df76e830d
3 changed files with 146 additions and 0 deletions

View file

@ -72,6 +72,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
- Fixed ortho #790
- Fixed Visual C++ 2013 warnings in vector relational code #782
- Fixed ICC build errors with constexpr #704
- Fixed defaulted operator= and constructors #791
### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22
#### Features:

View file

@ -1,3 +1,4 @@
glmCreateTestGTC(core_cpp_defaulted_ctor)
glmCreateTestGTC(core_force_aligned_gentypes)
glmCreateTestGTC(core_force_ctor_init)
glmCreateTestGTC(core_force_explicit_ctor)

View file

@ -0,0 +1,144 @@
#include <glm/glm.hpp>
#if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
#include <glm/gtc/constants.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/ext/vector_relational.hpp>
#include <glm/ext/vec1.hpp>
#include <cstring>
static int test_vec_memcpy()
{
int Error = 0;
{
glm::ivec1 const A = glm::ivec1(76);
glm::ivec1 B;
std::memcpy(&B, &A, sizeof(glm::ivec1));
Error += B == A ? 0 : 1;
}
{
glm::ivec2 const A = glm::ivec2(76);
glm::ivec2 B;
std::memcpy(&B, &A, sizeof(glm::ivec2));
Error += B == A ? 0 : 1;
}
{
glm::ivec3 const A = glm::ivec3(76);
glm::ivec3 B;
std::memcpy(&B, &A, sizeof(glm::ivec3));
Error += B == A ? 0 : 1;
}
{
glm::ivec4 const A = glm::ivec4(76);
glm::ivec4 B;
std::memcpy(&B, &A, sizeof(glm::ivec4));
Error += B == A ? 0 : 1;
}
return Error;
}
static int test_mat_memcpy()
{
int Error = 0;
{
glm::mat2x2 const A = glm::mat2x2(76);
glm::mat2x2 B;
std::memcpy(&B, &A, sizeof(glm::mat2x2));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat2x3 const A = glm::mat2x3(76);
glm::mat2x3 B;
std::memcpy(&B, &A, sizeof(glm::mat2x3));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat2x4 const A = glm::mat2x4(76);
glm::mat2x4 B;
std::memcpy(&B, &A, sizeof(glm::mat2x4));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat3x2 const A = glm::mat3x2(76);
glm::mat3x2 B;
std::memcpy(&B, &A, sizeof(glm::mat3x2));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat3x3 const A = glm::mat3x3(76);
glm::mat3x3 B;
std::memcpy(&B, &A, sizeof(glm::mat3x3));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat3x4 const A = glm::mat3x4(76);
glm::mat3x4 B;
std::memcpy(&B, &A, sizeof(glm::mat3x4));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat4x2 const A = glm::mat4x2(76);
glm::mat4x2 B;
std::memcpy(&B, &A, sizeof(glm::mat4x2));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat4x3 const A = glm::mat4x3(76);
glm::mat4x3 B;
std::memcpy(&B, &A, sizeof(glm::mat4x3));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
{
glm::mat4x4 const A = glm::mat4x4(76);
glm::mat4x4 B;
std::memcpy(&B, &A, sizeof(glm::mat4x4));
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
}
return Error;
}
static int test_quat_memcpy()
{
int Error = 0;
{
glm::quat const A = glm::quat(1, 0, 0, 0);
glm::quat B;
std::memcpy(&B, &A, sizeof(glm::quat));
Error += B == A ? 0 : 1;
}
return Error;
}
#endif//GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
int main()
{
int Error = 0;
# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
Error += test_vec_memcpy();
Error += test_mat_memcpy();
Error += test_quat_memcpy();
# endif//GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE
return Error;
}