File: core_cpp_defaulted_ctor.cpp

package info (click to toggle)
glm 1.0.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,252 kB
  • sloc: cpp: 41,050; sh: 31; makefile: 23
file content (145 lines) | stat: -rw-r--r-- 3,086 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <glm/glm.hpp>

#if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE

#include <glm/gtc/constants.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/ext/matrix_relational.hpp>
#include <glm/ext/vector_relational.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 += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
	}

	return Error;
}

#endif//GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE

int main()
{
	int Error = 0;

#	if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
		Error += test_vec_memcpy();
		Error += test_mat_memcpy();
		Error += test_quat_memcpy();
#	endif//GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE

	return Error;
}