core_cpp_constexpr.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. #include <glm/glm.hpp>
  2. #if GLM_CONFIG_CONSTEXP == GLM_ENABLE
  3. #include <glm/gtc/constants.hpp>
  4. #include <glm/gtc/quaternion.hpp>
  5. #include <glm/ext/vector_relational.hpp>
  6. #include <glm/ext/vector_int1.hpp>
  7. #include <glm/ext/vector_bool1.hpp>
  8. #include <glm/ext/vector_float1.hpp>
  9. static int test_vec1()
  10. {
  11. int Error = 0;
  12. {
  13. constexpr glm::ivec1 O(glm::ivec1(1));
  14. static_assert(glm::ivec1(1) == O, "GLM: Failed constexpr");
  15. constexpr glm::ivec1 P(1);
  16. static_assert(glm::ivec1(1) == P, "GLM: Failed constexpr");
  17. }
  18. {
  19. constexpr glm::ivec1 L(glm::ivec2(1, 2));
  20. static_assert(glm::ivec1(1) == L, "GLM: Failed constexpr");
  21. constexpr glm::ivec1 M(glm::ivec3(1, 2, 3));
  22. static_assert(glm::ivec1(1) == M, "GLM: Failed constexpr");
  23. constexpr glm::ivec1 N(glm::ivec4(1, 2, 3, 4));
  24. static_assert(glm::ivec1(1) == N, "GLM: Failed constexpr");
  25. }
  26. {
  27. constexpr glm::ivec1 A(1);
  28. static_assert(A[0] == 1, "GLM: Failed constexpr");
  29. static_assert(glm::vec1(1.0f).x > 0.0f, "GLM: Failed constexpr");
  30. static_assert(glm::vec1::length() == 1, "GLM: Failed constexpr");
  31. }
  32. {
  33. constexpr glm::bvec1 A1(true);
  34. constexpr glm::bvec1 A2(true);
  35. constexpr glm::bvec1 B1(false);
  36. constexpr glm::bvec1 B2(false);
  37. static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
  38. static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
  39. }
  40. {
  41. constexpr glm::ivec1 A(1);
  42. constexpr glm::ivec1 B = A + 1;
  43. constexpr glm::ivec1 C(3);
  44. static_assert(A + B == C, "GLM: Failed constexpr");
  45. constexpr glm::ivec1 D = +A;
  46. static_assert(D == A, "GLM: Failed constexpr");
  47. }
  48. {
  49. constexpr glm::ivec1 A(3);
  50. constexpr glm::ivec1 B = A - 1;
  51. constexpr glm::ivec1 C(1);
  52. static_assert(A - B == C, "GLM: Failed constexpr");
  53. constexpr glm::ivec1 D = -A;
  54. static_assert(-D == A, "GLM: Failed constexpr");
  55. }
  56. {
  57. constexpr glm::ivec1 A(3);
  58. constexpr glm::ivec1 B = A * 1;
  59. static_assert(A == B, "GLM: Failed constexpr");
  60. constexpr glm::ivec1 C(1);
  61. static_assert(B * C == A, "GLM: Failed constexpr");
  62. }
  63. {
  64. constexpr glm::ivec1 A(3);
  65. constexpr glm::ivec1 B = A / 1;
  66. static_assert(A == B, "GLM: Failed constexpr");
  67. constexpr glm::ivec1 C(1);
  68. static_assert(B / C == A, "GLM: Failed constexpr");
  69. }
  70. {
  71. constexpr glm::ivec1 A(3);
  72. constexpr glm::ivec1 B = A % 2;
  73. constexpr glm::ivec1 C(1);
  74. static_assert(B == C, "GLM: Failed constexpr");
  75. constexpr glm::ivec1 D(2);
  76. static_assert(A % D == C, "GLM: Failed constexpr");
  77. }
  78. {
  79. constexpr glm::ivec1 A(1);
  80. constexpr glm::ivec1 B = A & 1;
  81. static_assert(A == B, "GLM: Failed constexpr");
  82. constexpr glm::ivec1 C(1);
  83. static_assert(A == (A & C), "GLM: Failed constexpr");
  84. }
  85. {
  86. constexpr glm::ivec1 A(1);
  87. constexpr glm::ivec1 B = A | 1;
  88. static_assert(A == B, "GLM: Failed constexpr");
  89. constexpr glm::ivec1 C(1);
  90. static_assert(A == (A | C), "GLM: Failed constexpr");
  91. }
  92. {
  93. constexpr glm::ivec1 A(1);
  94. constexpr glm::ivec1 B = A ^ 0;
  95. static_assert(A == B, "GLM: Failed constexpr");
  96. constexpr glm::ivec1 C(0);
  97. static_assert(A == (A ^ C), "GLM: Failed constexpr");
  98. }
  99. {
  100. constexpr glm::ivec1 A(1);
  101. constexpr glm::ivec1 B = A << 1;
  102. static_assert(B == glm::ivec1(2), "GLM: Failed constexpr");
  103. constexpr glm::ivec1 C(1);
  104. static_assert(B == (A << C), "GLM: Failed constexpr");
  105. }
  106. {
  107. constexpr glm::ivec1 A(2);
  108. constexpr glm::ivec1 B = A >> 1;
  109. static_assert(B == glm::ivec1(1), "GLM: Failed constexpr");
  110. constexpr glm::ivec1 C(1);
  111. static_assert(B == A >> C, "GLM: Failed constexpr");
  112. }
  113. {
  114. constexpr glm::ivec1 A(~0);
  115. constexpr glm::ivec1 B = ~A;
  116. static_assert(A == ~B, "GLM: Failed constexpr");
  117. }
  118. return Error;
  119. }
  120. static int test_vec2()
  121. {
  122. int Error = 0;
  123. {
  124. constexpr glm::ivec2 O(glm::ivec1(1));
  125. static_assert(glm::ivec2(1) == O, "GLM: Failed constexpr");
  126. constexpr glm::ivec2 A(1);
  127. static_assert(glm::ivec2(1) == A, "GLM: Failed constexpr");
  128. }
  129. {
  130. constexpr glm::ivec2 F(glm::ivec1(1), glm::ivec1(2));
  131. static_assert(glm::ivec2(1, 2) == F, "GLM: Failed constexpr");
  132. constexpr glm::ivec2 G(1, glm::ivec1(2));
  133. static_assert(glm::ivec2(1, 2) == G, "GLM: Failed constexpr");
  134. constexpr glm::ivec2 H(glm::ivec1(1), 2);
  135. static_assert(glm::ivec2(1, 2) == H, "GLM: Failed constexpr");
  136. constexpr glm::ivec2 I(1, 2);
  137. static_assert(glm::ivec2(1, 2) == I, "GLM: Failed constexpr");
  138. }
  139. {
  140. constexpr glm::ivec2 L(glm::ivec2(1, 2));
  141. static_assert(glm::ivec2(1, 2) == L, "GLM: Failed constexpr");
  142. constexpr glm::ivec2 M(glm::ivec3(1, 2, 3));
  143. static_assert(glm::ivec2(1, 2) == M, "GLM: Failed constexpr");
  144. constexpr glm::ivec2 N(glm::ivec4(1, 2, 3, 4));
  145. static_assert(glm::ivec2(1, 2) == N, "GLM: Failed constexpr");
  146. }
  147. {
  148. constexpr glm::ivec2 A(1);
  149. static_assert(A[0] == 1, "GLM: Failed constexpr");
  150. static_assert(glm::vec2(1.0f).x > 0.0f, "GLM: Failed constexpr");
  151. static_assert(glm::vec2(1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
  152. static_assert(glm::vec2(1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
  153. static_assert(glm::vec2::length() == 2, "GLM: Failed constexpr");
  154. }
  155. {
  156. constexpr glm::bvec2 A1(true);
  157. constexpr glm::bvec2 A2(true);
  158. constexpr glm::bvec2 B1(false);
  159. constexpr glm::bvec2 B2(false);
  160. static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
  161. static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
  162. }
  163. {
  164. constexpr glm::ivec2 A(1);
  165. constexpr glm::ivec2 B = A + 1;
  166. constexpr glm::ivec2 C(3);
  167. static_assert(A + B == C, "GLM: Failed constexpr");
  168. constexpr glm::ivec2 D = +A;
  169. static_assert(D == A, "GLM: Failed constexpr");
  170. }
  171. {
  172. constexpr glm::ivec2 A(3);
  173. constexpr glm::ivec2 B = A - 1;
  174. constexpr glm::ivec2 C(1);
  175. static_assert(A - B == C, "GLM: Failed constexpr");
  176. constexpr glm::ivec2 D = -A;
  177. static_assert(-D == A, "GLM: Failed constexpr");
  178. }
  179. {
  180. constexpr glm::ivec2 A(3);
  181. constexpr glm::ivec2 B = A * 1;
  182. static_assert(A == B, "GLM: Failed constexpr");
  183. constexpr glm::ivec2 C(1);
  184. static_assert(B * C == A, "GLM: Failed constexpr");
  185. }
  186. {
  187. constexpr glm::ivec2 A(3);
  188. constexpr glm::ivec2 B = A / 1;
  189. static_assert(A == B, "GLM: Failed constexpr");
  190. constexpr glm::ivec2 C(1);
  191. static_assert(B / C == A, "GLM: Failed constexpr");
  192. }
  193. {
  194. constexpr glm::ivec2 A(3);
  195. constexpr glm::ivec2 B = A % 2;
  196. constexpr glm::ivec2 C(1);
  197. static_assert(B == C, "GLM: Failed constexpr");
  198. constexpr glm::ivec1 D(2);
  199. static_assert(A % D == C, "GLM: Failed constexpr");
  200. }
  201. {
  202. constexpr glm::ivec2 A(1);
  203. constexpr glm::ivec2 B = A & 1;
  204. static_assert(A == B, "GLM: Failed constexpr");
  205. constexpr glm::ivec1 C(1);
  206. static_assert(A == (A & C), "GLM: Failed constexpr");
  207. }
  208. {
  209. constexpr glm::ivec2 A(1);
  210. constexpr glm::ivec2 B = A | 1;
  211. static_assert(A == B, "GLM: Failed constexpr");
  212. constexpr glm::ivec1 C(1);
  213. static_assert(A == (A | C), "GLM: Failed constexpr");
  214. }
  215. {
  216. constexpr glm::ivec2 A(1);
  217. constexpr glm::ivec2 B = A ^ 0;
  218. static_assert(A == B, "GLM: Failed constexpr");
  219. constexpr glm::ivec1 C(0);
  220. static_assert(A == (A ^ C), "GLM: Failed constexpr");
  221. }
  222. {
  223. constexpr glm::ivec2 A(1);
  224. constexpr glm::ivec2 B = A << 1;
  225. static_assert(B == glm::ivec2(2), "GLM: Failed constexpr");
  226. constexpr glm::ivec1 C(1);
  227. static_assert(B == (A << C), "GLM: Failed constexpr");
  228. }
  229. {
  230. constexpr glm::ivec2 A(2);
  231. constexpr glm::ivec2 B = A >> 1;
  232. static_assert(B == glm::ivec2(1), "GLM: Failed constexpr");
  233. constexpr glm::ivec1 C(1);
  234. static_assert(B == A >> C, "GLM: Failed constexpr");
  235. }
  236. {
  237. constexpr glm::ivec2 A(~0);
  238. constexpr glm::ivec2 B = ~A;
  239. static_assert(A == ~B, "GLM: Failed constexpr");
  240. }
  241. return Error;
  242. }
  243. static int test_vec3()
  244. {
  245. int Error = 0;
  246. {
  247. constexpr glm::ivec3 O(glm::ivec1(1));
  248. static_assert(glm::ivec3(1) == O, "GLM: Failed constexpr");
  249. constexpr glm::ivec3 A(1);
  250. static_assert(glm::ivec3(1) == A, "GLM: Failed constexpr");
  251. }
  252. {
  253. constexpr glm::ivec3 B(glm::ivec2(1, 2), 3);
  254. static_assert(glm::ivec3(1, 2, 3) == B, "GLM: Failed constexpr");
  255. constexpr glm::ivec3 C(1, glm::ivec2(2, 3));
  256. static_assert(glm::ivec3(1, 2, 3) == C, "GLM: Failed constexpr");
  257. constexpr glm::ivec3 D(glm::ivec1(1), glm::ivec2(2, 3));
  258. static_assert(glm::ivec3(1, 2, 3) == D, "GLM: Failed constexpr");
  259. constexpr glm::ivec3 E(glm::ivec2(1, 2), glm::ivec1(3));
  260. static_assert(glm::ivec3(1, 2, 3) == E, "GLM: Failed constexpr");
  261. }
  262. {
  263. constexpr glm::ivec3 F(glm::ivec1(1), glm::ivec1(2), glm::ivec1(3));
  264. static_assert(glm::ivec3(1, 2, 3) == F, "GLM: Failed constexpr");
  265. constexpr glm::ivec3 G(1, glm::ivec1(2), glm::ivec1(3));
  266. static_assert(glm::ivec3(1, 2, 3) == G, "GLM: Failed constexpr");
  267. constexpr glm::ivec3 H(glm::ivec1(1), 2, glm::ivec1(3));
  268. static_assert(glm::ivec3(1, 2, 3) == H, "GLM: Failed constexpr");
  269. constexpr glm::ivec3 I(1, 2, glm::ivec1(3));
  270. static_assert(glm::ivec3(1, 2, 3) == I, "GLM: Failed constexpr");
  271. constexpr glm::ivec3 J(glm::ivec1(1), glm::ivec1(2), 3);
  272. static_assert(glm::ivec3(1, 2, 3) == J, "GLM: Failed constexpr");
  273. constexpr glm::ivec3 K(1, glm::ivec1(2), 3);
  274. static_assert(glm::ivec3(1, 2, 3) == K, "GLM: Failed constexpr");
  275. constexpr glm::ivec3 L(glm::ivec1(1), 2, 3);
  276. static_assert(glm::ivec3(1, 2, 3) == L, "GLM: Failed constexpr");
  277. constexpr glm::ivec3 M(1, 2, 3);
  278. static_assert(glm::ivec3(1, 2, 3) == M, "GLM: Failed constexpr");
  279. }
  280. {
  281. constexpr glm::ivec3 N(glm::ivec4(1, 2, 3, 4));
  282. static_assert(glm::ivec3(1, 2, 3) == N, "GLM: Failed constexpr");
  283. }
  284. {
  285. constexpr glm::ivec3 const A(1);
  286. static_assert(A[0] == 1, "GLM: Failed constexpr");
  287. static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr");
  288. static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
  289. static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
  290. static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr");
  291. }
  292. {
  293. constexpr glm::bvec3 A1(true);
  294. constexpr glm::bvec3 A2(true);
  295. constexpr glm::bvec3 B1(false);
  296. constexpr glm::bvec3 B2(false);
  297. static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
  298. static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
  299. }
  300. {
  301. constexpr glm::ivec3 A(1);
  302. constexpr glm::ivec3 B = A + 1;
  303. constexpr glm::ivec3 C(3);
  304. static_assert(A + B == C, "GLM: Failed constexpr");
  305. constexpr glm::ivec3 D = +A;
  306. static_assert(D == A, "GLM: Failed constexpr");
  307. }
  308. {
  309. constexpr glm::ivec3 A(3);
  310. constexpr glm::ivec3 B = A - 1;
  311. constexpr glm::ivec3 C(1);
  312. static_assert(A - B == C, "GLM: Failed constexpr");
  313. constexpr glm::ivec3 D = -A;
  314. static_assert(-D == A, "GLM: Failed constexpr");
  315. }
  316. {
  317. constexpr glm::ivec3 A(3);
  318. constexpr glm::ivec3 B = A * 1;
  319. static_assert(A == B, "GLM: Failed constexpr");
  320. constexpr glm::ivec3 C(1);
  321. static_assert(B * C == A, "GLM: Failed constexpr");
  322. }
  323. {
  324. constexpr glm::ivec3 A(3);
  325. constexpr glm::ivec3 B = A / 1;
  326. static_assert(A == B, "GLM: Failed constexpr");
  327. constexpr glm::ivec3 C(1);
  328. static_assert(B / C == A, "GLM: Failed constexpr");
  329. }
  330. {
  331. constexpr glm::ivec3 A(3);
  332. constexpr glm::ivec3 B = A % 2;
  333. constexpr glm::ivec3 C(1);
  334. static_assert(B == C, "GLM: Failed constexpr");
  335. constexpr glm::ivec1 D(2);
  336. static_assert(A % D == C, "GLM: Failed constexpr");
  337. }
  338. {
  339. constexpr glm::ivec3 A(1);
  340. constexpr glm::ivec3 B = A & 1;
  341. static_assert(A == B, "GLM: Failed constexpr");
  342. constexpr glm::ivec1 C(1);
  343. static_assert(A == (A & C), "GLM: Failed constexpr");
  344. }
  345. {
  346. constexpr glm::ivec3 A(1);
  347. constexpr glm::ivec3 B = A | 1;
  348. static_assert(A == B, "GLM: Failed constexpr");
  349. constexpr glm::ivec1 C(1);
  350. static_assert(A == (A | C), "GLM: Failed constexpr");
  351. }
  352. {
  353. constexpr glm::ivec3 A(1);
  354. constexpr glm::ivec3 B = A ^ 0;
  355. static_assert(A == B, "GLM: Failed constexpr");
  356. constexpr glm::ivec1 C(0);
  357. static_assert(A == (A ^ C), "GLM: Failed constexpr");
  358. }
  359. {
  360. constexpr glm::ivec3 A(1);
  361. constexpr glm::ivec3 B = A << 1;
  362. static_assert(B == glm::ivec3(2), "GLM: Failed constexpr");
  363. constexpr glm::ivec1 C(1);
  364. static_assert(B == (A << C), "GLM: Failed constexpr");
  365. }
  366. {
  367. constexpr glm::ivec3 A(2);
  368. constexpr glm::ivec3 B = A >> 1;
  369. static_assert(B == glm::ivec3(1), "GLM: Failed constexpr");
  370. constexpr glm::ivec1 C(1);
  371. static_assert(B == A >> C, "GLM: Failed constexpr");
  372. }
  373. {
  374. constexpr glm::ivec3 A(~0);
  375. constexpr glm::ivec3 B = ~A;
  376. static_assert(A == ~B, "GLM: Failed constexpr");
  377. }
  378. return Error;
  379. }
  380. static int test_vec4()
  381. {
  382. int Error = 0;
  383. {
  384. constexpr glm::ivec4 O(glm::ivec4(1));
  385. static_assert(glm::ivec4(1) == O, "GLM: Failed constexpr");
  386. constexpr glm::ivec4 A(1);
  387. static_assert(glm::ivec4(1) == A, "GLM: Failed constexpr");
  388. constexpr glm::ivec4 N(glm::ivec4(1, 2, 3, 4));
  389. static_assert(glm::ivec4(1, 2, 3, 4) == N, "GLM: Failed constexpr");
  390. }
  391. {
  392. constexpr glm::ivec4 A(glm::ivec3(1, 2, 3), 4);
  393. static_assert(glm::ivec4(1, 2, 3, 4) == A, "GLM: Failed constexpr");
  394. constexpr glm::ivec4 B(glm::ivec2(1, 2), glm::ivec2(3, 4));
  395. static_assert(glm::ivec4(1, 2, 3, 4) == B, "GLM: Failed constexpr");
  396. constexpr glm::ivec4 C(1, glm::ivec3(2, 3, 4));
  397. static_assert(glm::ivec4(1, 2, 3, 4) == C, "GLM: Failed constexpr");
  398. constexpr glm::ivec4 D(glm::ivec1(1), glm::ivec2(2, 3), glm::ivec1(4));
  399. static_assert(glm::ivec4(1, 2, 3, 4) == D, "GLM: Failed constexpr");
  400. constexpr glm::ivec4 E(glm::ivec2(1, 2), glm::ivec1(3), glm::ivec1(4));
  401. static_assert(glm::ivec4(1, 2, 3, 4) == E, "GLM: Failed constexpr");
  402. constexpr glm::ivec4 F(glm::ivec1(1), glm::ivec1(2), glm::ivec2(3, 4));
  403. static_assert(glm::ivec4(1, 2, 3, 4) == F, "GLM: Failed constexpr");
  404. }
  405. {
  406. constexpr glm::ivec4 A(1);
  407. static_assert(A[0] == 1, "GLM: Failed constexpr");
  408. static_assert(glm::ivec4(1).x > 0, "GLM: Failed constexpr");
  409. static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).x > 0, "GLM: Failed constexpr");
  410. static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).y < 0, "GLM: Failed constexpr");
  411. static_assert(glm::ivec4::length() == 4, "GLM: Failed constexpr");
  412. }
  413. {
  414. constexpr glm::bvec4 A1(true);
  415. constexpr glm::bvec4 A2(true);
  416. constexpr glm::bvec4 B1(false);
  417. constexpr glm::bvec4 B2(false);
  418. static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
  419. static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
  420. }
  421. {
  422. constexpr glm::ivec4 A(1);
  423. constexpr glm::ivec4 B = A + 1;
  424. constexpr glm::ivec4 C(3);
  425. static_assert(A + B == C, "GLM: Failed constexpr");
  426. constexpr glm::ivec4 D = +A;
  427. static_assert(D == A, "GLM: Failed constexpr");
  428. }
  429. {
  430. constexpr glm::ivec4 A(3);
  431. constexpr glm::ivec4 B = A - 1;
  432. constexpr glm::ivec4 C(1);
  433. static_assert(A - B == C, "GLM: Failed constexpr");
  434. constexpr glm::ivec4 D = -A;
  435. static_assert(-D == A, "GLM: Failed constexpr");
  436. }
  437. {
  438. constexpr glm::ivec4 A(3);
  439. constexpr glm::ivec4 B = A * 1;
  440. static_assert(A == B, "GLM: Failed constexpr");
  441. constexpr glm::ivec4 C(1);
  442. static_assert(B * C == A, "GLM: Failed constexpr");
  443. }
  444. {
  445. constexpr glm::ivec4 A(3);
  446. constexpr glm::ivec4 B = A / 1;
  447. static_assert(A == B, "GLM: Failed constexpr");
  448. constexpr glm::ivec4 C(1);
  449. static_assert(B / C == A, "GLM: Failed constexpr");
  450. }
  451. {
  452. constexpr glm::ivec4 A(3);
  453. constexpr glm::ivec4 B = A % 2;
  454. constexpr glm::ivec4 C(1);
  455. static_assert(B == C, "GLM: Failed constexpr");
  456. constexpr glm::ivec1 D(2);
  457. static_assert(A % D == C, "GLM: Failed constexpr");
  458. }
  459. {
  460. constexpr glm::ivec4 A(1);
  461. constexpr glm::ivec4 B = A & 1;
  462. static_assert(A == B, "GLM: Failed constexpr");
  463. constexpr glm::ivec1 C(1);
  464. static_assert(A == (A & C), "GLM: Failed constexpr");
  465. }
  466. {
  467. constexpr glm::ivec4 A(1);
  468. constexpr glm::ivec4 B = A | 1;
  469. static_assert(A == B, "GLM: Failed constexpr");
  470. constexpr glm::ivec1 C(1);
  471. static_assert(A == (A | C), "GLM: Failed constexpr");
  472. }
  473. {
  474. constexpr glm::ivec4 A(1);
  475. constexpr glm::ivec4 B = A ^ 0;
  476. static_assert(A == B, "GLM: Failed constexpr");
  477. constexpr glm::ivec1 C(0);
  478. static_assert(A == (A ^ C), "GLM: Failed constexpr");
  479. }
  480. {
  481. constexpr glm::ivec4 A(1);
  482. constexpr glm::ivec4 B = A << 1;
  483. static_assert(B == glm::ivec4(2), "GLM: Failed constexpr");
  484. constexpr glm::ivec1 C(1);
  485. static_assert(B == (A << C), "GLM: Failed constexpr");
  486. }
  487. {
  488. constexpr glm::ivec4 A(2);
  489. constexpr glm::ivec4 B = A >> 1;
  490. static_assert(B == glm::ivec4(1), "GLM: Failed constexpr");
  491. constexpr glm::ivec1 C(1);
  492. static_assert(B == A >> C, "GLM: Failed constexpr");
  493. }
  494. {
  495. constexpr glm::ivec4 A(~0);
  496. constexpr glm::ivec4 B = ~A;
  497. static_assert(A == ~B, "GLM: Failed constexpr");
  498. }
  499. return Error;
  500. }
  501. static int test_quat()
  502. {
  503. int Error = 0;
  504. {
  505. static_assert(glm::quat::length() == 4, "GLM: Failed constexpr");
  506. static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr");
  507. static_assert(glm::quat(1.0f, 0.0f, 0.0f, 0.0f).w > 0.0f, "GLM: Failed constexpr");
  508. glm::quat constexpr Q = glm::identity<glm::quat>();
  509. static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon<float>(), "GLM: Failed constexpr");
  510. static_assert(Q[0] == 0, "GLM: Failed constexpr");
  511. }
  512. return Error;
  513. }
  514. static int test_mat2x2()
  515. {
  516. int Error = 0;
  517. static_assert(glm::mat2x2::length() == 2, "GLM: Failed constexpr");
  518. return Error;
  519. }
  520. #endif//GLM_CONFIG_CONSTEXP == GLM_ENABLE
  521. int main()
  522. {
  523. int Error = 0;
  524. # if GLM_CONFIG_CONSTEXP == GLM_ENABLE
  525. Error += test_vec1();
  526. Error += test_vec2();
  527. Error += test_vec3();
  528. Error += test_vec4();
  529. Error += test_quat();
  530. Error += test_mat2x2();
  531. # endif//GLM_CONFIG_CONSTEXP == GLM_ENABLE
  532. return Error;
  533. }