|
16 | 16 | #include <ranges> |
17 | 17 | namespace glm |
18 | 18 | { |
| 19 | +#ifdef __clang__ |
| 20 | +#define GLM_TRIVIAL __attribute__((trivial_abi)) |
| 21 | +#else |
| 22 | +#define GLM_TRIVIAL |
| 23 | +#endif |
19 | 24 | template <length_t L> |
20 | 25 | concept NotVec1 = !std::is_same_v<std::integral_constant<length_t, L>, std::integral_constant<length_t, 1>>; |
21 | 26 | template <qualifier Q> |
@@ -119,7 +124,7 @@ namespace glm |
119 | 124 | template <length_t L, typename T, qualifier Q> |
120 | 125 | using EC = detail::ElementCollection<Q, T, L>; |
121 | 126 | template<length_t L, typename T, qualifier Q> |
122 | | - struct vec : detail::ElementCollection<Q, T, L> |
| 127 | + struct vec GLM_TRIVIAL : detail::ElementCollection<Q, T, L> |
123 | 128 | { |
124 | 129 | // -- Data -- |
125 | 130 | using detail::ElementCollection<Q, T, L>::x; |
@@ -282,7 +287,7 @@ namespace glm |
282 | 287 | } |
283 | 288 | } |
284 | 289 | template <length_t len> |
285 | | - using RetArr = T[len]; |
| 290 | + using RetArr = std::array<T, len>; |
286 | 291 |
|
287 | 292 | template <typename Vs0> |
288 | 293 | static constexpr length_t ctor_mixed_constexpr_single_get_length() |
@@ -353,19 +358,16 @@ namespace glm |
353 | 358 | const auto params = std::tuple{vecOrScalar...}; |
354 | 359 |
|
355 | 360 | const auto arr = ctor_mixed_constexpr_single(std::get<0>(params)); |
356 | | - if (arr) [[likely]] |
357 | | - std::memcpy(aa.a.p.begin()+i, arr, sizeof(T)*lengths[0]); |
| 361 | + std::ranges::copy(arr.cbegin(), aa.a.p.begin()+i, aa.a.p.begin()+i + sizeof(T)*lengths[0]); |
358 | 362 | constexpr auto i2 = i + lengths[0]; |
359 | 363 |
|
360 | 364 | if constexpr (sizeof...(VecOrScalar) > 1) { |
361 | 365 | const auto arr2 = ctor_mixed_constexpr_single(std::get<1>(params)); |
362 | | - if (arr2) [[likely]] |
363 | | - std::memcpy(aa.a.p.begin()+i2, arr2, sizeof(T)*lengths[1]); |
| 366 | + std::ranges::copy(arr2.cbegin(), aa.a.p.begin()+i2, aa.a.p.begin()+i2 + sizeof(T)*lengths[1]); |
364 | 367 | constexpr auto i3 = i2 + lengths[1]; |
365 | 368 | if constexpr (sizeof...(VecOrScalar) > 2) { |
366 | 369 | const auto arr3 = ctor_mixed_constexpr_single(std::get<2>(params)); |
367 | | - if (arr3) [[likely]] |
368 | | - std::memcpy(aa.a.p.begin()+i3, arr3, sizeof(T)*lengths[2]); |
| 370 | + std::ranges::copy(arr3.cbegin(), aa.a.p.begin()+i3, aa.a.p.begin()+i3 + sizeof(T)*lengths[2]); |
369 | 371 | } |
370 | 372 | } |
371 | 373 |
|
@@ -460,7 +462,7 @@ namespace glm |
460 | 462 | } |
461 | 463 |
|
462 | 464 | template<typename Tx> |
463 | | - inline GLM_CONSTEXPR vec<L, T, Q> & operator*=(vec<L, Tx, Q> const& __restrict__ v) __restrict__ |
| 465 | + inline GLM_CONSTEXPR vec<L, T, Q> & operator*=(vec<L, Tx, Q> const& __restrict__ v) |
464 | 466 | { |
465 | 467 | if constexpr (L < 3) { |
466 | 468 | this->data *= v.data; |
|
0 commit comments