8#ifndef _CGP_STD_ARRAY_OPERATIONS_HPP
9#define _CGP_STD_ARRAY_OPERATIONS_HPP
21 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
22 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
23 std::tuple_size_v<std::remove_cvref_t<RightType>>) &&
24 (cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
25 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) ||
26 (cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
27 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) &&
28 cgt::common_std_array_c<LeftType, RightType>
31 using container_t_a = std::remove_cvref_t<LeftType>;
32 using container_t_b = std::remove_cvref_t<RightType>;
34 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
36 if constexpr(std::same_as<container_t_a, container_t_b> &&
37 std::is_rvalue_reference_v<
decltype(
A)>)
39 for(std::size_t i{}; i < N; ++i)
44 else if constexpr(std::same_as<container_t_a, container_t_b> &&
45 std::is_rvalue_reference_v<
decltype(
B)>)
47 for(std::size_t i{}; i < N; ++i)
56 for(std::size_t i=0; i < N; ++i)
63 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
64 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
65 std::tuple_size_v<std::remove_cvref_t<RightType>>) &&
66 (cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
67 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) ||
68 (cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
69 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) &&
70 cgt::common_std_array_c<LeftType, RightType>
73 using container_t_a = std::remove_cvref_t<LeftType>;
74 using container_t_b = std::remove_cvref_t<RightType>;
76 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
78 if constexpr(std::same_as<container_t_a, container_t_b> &&
79 std::is_rvalue_reference_v<
decltype(
A)>)
81 for(std::size_t i{}; i < N; ++i)
86 else if constexpr(std::same_as<container_t_a, container_t_b> &&
87 std::is_rvalue_reference_v<
decltype(
B)>)
89 for(std::size_t i{}; i < N; ++i)
98 for(std::size_t i=0; i < N; ++i)
105 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
106 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
107 std::tuple_size_v<std::remove_cvref_t<RightType>>) &&
108 (cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
109 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) ||
110 (cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
111 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) &&
112 cgt::common_std_array_c<LeftType, RightType>
115 using container_t_a = std::remove_cvref_t<LeftType>;
116 using container_t_b = std::remove_cvref_t<RightType>;
118 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
120 if constexpr(std::same_as<container_t_a, container_t_b> &&
121 std::is_rvalue_reference_v<
decltype(
A)>)
123 for(std::size_t i{}; i < N; ++i)
128 else if constexpr(std::same_as<container_t_a, container_t_b> &&
129 std::is_rvalue_reference_v<
decltype(
B)>)
131 for(std::size_t i{}; i < N; ++i)
140 for(std::size_t i=0; i < N; ++i)
147 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
148 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
149 std::tuple_size_v<std::remove_cvref_t<RightType>>) &&
150 (cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
151 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) ||
152 (cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
153 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>) &&
154 cgt::common_std_array_c<LeftType, RightType>
157 using container_t_a = std::remove_cvref_t<LeftType>;
158 using container_t_b = std::remove_cvref_t<RightType>;
160 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
162 if constexpr(std::same_as<container_t_a, container_t_b> &&
163 std::is_rvalue_reference_v<
decltype(
A)>)
165 for(std::size_t i{}; i < N; ++i)
170 else if constexpr(std::same_as<container_t_a, container_t_b> &&
171 std::is_rvalue_reference_v<
decltype(
B)>)
173 for(std::size_t i{}; i < N; ++i)
182 for(std::size_t i=0; i < N; ++i)
191 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
192 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
193 std::tuple_size_v<std::remove_cvref_t<RightType>>) &&
194 ( (
std::tuple_size_v<std::remove_cvref_t<LeftType>> == 3) || (std::tuple_size_v<std::remove_cvref_t<LeftType>> == 4))
195 && cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>>
196 && cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>
197 && cgt::common_std_array_c<LeftType, RightType>
200 using container_t_a = std::remove_cvref_t<LeftType>;
201 using container_t_b = std::remove_cvref_t<RightType>;
203 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
211 if constexpr(std::tuple_size_v<std::remove_cvref_t<LeftType>> == 4)
217 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
218 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
219 std::tuple_size_v<std::remove_cvref_t<RightType>>) &&
220 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
221 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
222 cgt::common_std_array_c<LeftType, RightType>
225 using container_t_a = std::remove_cvref_t<LeftType>;
226 using container_t_b = std::remove_cvref_t<RightType>;
228 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
230 if constexpr(std::same_as<container_t_a, container_t_b> &&
231 std::is_rvalue_reference_v<
decltype(
A)>)
233 for(std::size_t i{}; i < N; ++i)
238 else if constexpr(std::same_as<container_t_a, container_t_b> &&
239 std::is_rvalue_reference_v<
decltype(
B)>)
241 for(std::size_t i{}; i < N; ++i)
250 for(std::size_t i=0; i < N; ++i)
257 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
258 requires cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
259 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
260 cgt::common_std_array_c<LeftType, RightType>
263 using container_t_a = std::remove_cvref_t<LeftType>;
264 using container_t_b = std::remove_cvref_t<RightType>;
266 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
268 if constexpr(std::is_rvalue_reference_v<
decltype(
A)>)
270 for(std::size_t i{}; i < N; ++i)
279 for(std::size_t i=0; i < N; ++i)
286 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
287 requires cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
288 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
289 cgt::common_std_array_c<LeftType, RightType>
292 using container_t_a = std::remove_cvref_t<LeftType>;
293 using container_t_b = std::remove_cvref_t<RightType>;
295 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<RightType>>;
297 if constexpr(std::is_rvalue_reference_v<
decltype(
B)>)
299 for(std::size_t i{}; i < N; ++i)
312 for(std::size_t i=0; i < N; ++i)
321 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
322 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
323 std::tuple_size_v<std::remove_cvref_t<RightType>>)
324 && cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>>
325 && cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>
326 && cgt::common_std_array_c<LeftType, RightType>
329 using container_t_a = std::remove_cvref_t<LeftType>;
330 using container_t_b = std::remove_cvref_t<RightType>;
332 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
336 using element_t = std::tuple_element_t<0, c_t>;
340 for(std::size_t i=0; i < N; ++i)
346 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
347 requires (std::tuple_size_v<std::remove_cvref_t<LeftType>> ==
348 std::tuple_size_v<std::remove_cvref_t<RightType>>) &&
349 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
350 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
351 cgt::common_std_array_c<LeftType, RightType>
354 using container_t_a = std::remove_cvref_t<LeftType>;
355 using container_t_b = std::remove_cvref_t<RightType>;
357 constexpr std::size_t N =
358 std::tuple_size_v<std::remove_cvref_t<LeftType>>;
361 using element_t = std::tuple_element_t<0, std::tuple_element_t<0, c_t> >;
362 using array_t = std::array<element_t, N>;
366 for(std::size_t i=0; i < N; ++i)
372 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
373 requires cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
374 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>
377 using container_t_a = std::remove_cvref_t<LeftType>;
378 using a_t = std::tuple_element_t<0, std::tuple_element_t<0, container_t_a>>;
380 using container_t_b = std::remove_cvref_t<RightType>;
381 using b_t = std::tuple_element_t<0, container_t_b>;
383 constexpr std::size_t N = std::tuple_size_v<container_t_a>;
385 using c_t = std::array<cgt::common_signed_t<a_t, b_t>, N>; c_t C;
387 for(std::size_t i=0; i < N; ++i) C[i] =
A[i] &
B;
392 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
393 requires cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
394 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>>
397 using container_t_a = std::remove_cvref_t<LeftType>;
398 using a_t = std::tuple_element_t<0, container_t_a>;
400 using container_t_b = std::remove_cvref_t<RightType>;
401 using b_t = std::tuple_element_t<0, std::tuple_element_t<0, container_t_b>>;
403 constexpr std::size_t N = std::tuple_size_v<container_t_b>;
405 using c_t = std::array<cgt::common_signed_t<a_t, b_t>, N>; c_t C;
411 for(std::size_t i=0; i < N; ++i) C[i] =
A &
B[i];
417 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
418 requires cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
419 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
420 cgt::common_std_array_c<LeftType, RightType>
423 using container_t_a = std::remove_cvref_t<LeftType>;
424 using container_t_b = std::remove_cvref_t<RightType>;
426 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
428 if constexpr(std::is_rvalue_reference_v<
decltype(
A)>)
430 for(std::size_t i{}; i < N; ++i)
439 for(std::size_t i=0; i < N; ++i)
446 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
447 requires cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
448 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
449 cgt::common_std_array_c<LeftType, RightType>
452 using container_t_a = std::remove_cvref_t<LeftType>;
453 using container_t_b = std::remove_cvref_t<RightType>;
455 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<RightType>>;
457 if constexpr(std::is_rvalue_reference_v<
decltype(
B)>)
459 for(std::size_t i{}; i < N; ++i)
468 for(std::size_t i=0; i < N; ++i)
476 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
477 requires cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
478 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
479 cgt::common_std_array_c<LeftType, RightType>
482 using container_t_a = std::remove_cvref_t<LeftType>;
483 using container_t_b = std::remove_cvref_t<RightType>;
485 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
487 if constexpr(std::is_rvalue_reference_v<
decltype(
A)>)
489 for(std::size_t i{}; i < N; ++i)
498 for(std::size_t i=0; i < N; ++i)
505 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
506 requires cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
507 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
508 cgt::common_std_array_c<LeftType, RightType>
511 using container_t_a = std::remove_cvref_t<LeftType>;
512 using container_t_b = std::remove_cvref_t<RightType>;
514 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<RightType>>;
516 if constexpr(std::is_rvalue_reference_v<
decltype(
B)>)
518 for(std::size_t i{}; i < N; ++i)
527 for(std::size_t i=0; i < N; ++i)
534 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
535 requires cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
536 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
537 cgt::common_std_array_c<LeftType, RightType>
540 using container_t_a = std::remove_cvref_t<LeftType>;
541 using container_t_b = std::remove_cvref_t<RightType>;
543 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
545 if constexpr(std::is_rvalue_reference_v<
decltype(
A)>)
547 for(std::size_t i{}; i < N; ++i)
556 for(std::size_t i=0; i < N; ++i)
563 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
564 requires cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
565 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
566 cgt::common_std_array_c<LeftType, RightType>
569 using container_t_a = std::remove_cvref_t<LeftType>;
570 using container_t_b = std::remove_cvref_t<RightType>;
572 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<RightType>>;
574 if constexpr(std::is_rvalue_reference_v<
decltype(
B)>)
576 for(std::size_t i{}; i < N; ++i)
585 for(std::size_t i=0; i < N; ++i)
592 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
593 requires cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
594 cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
595 cgt::common_std_array_c<LeftType, RightType>
598 using container_t_a = std::remove_cvref_t<LeftType>;
599 using container_t_b = std::remove_cvref_t<RightType>;
601 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<LeftType>>;
603 if constexpr(std::is_rvalue_reference_v<
decltype(
A)>)
605 for(std::size_t i{}; i < N; ++i)
614 for(std::size_t i=0; i < N; ++i)
621 template<cgt::std_array_flat_c LeftType, cgt::std_array_flat_c RightType>
622 requires cgt::numerical_c<std::tuple_element_t<0, std::remove_cvref_t<LeftType>>> &&
623 cgt::std_array_c<std::tuple_element_t<0, std::remove_cvref_t<RightType>>> &&
624 cgt::common_std_array_c<LeftType, RightType>
627 using container_t_a = std::remove_cvref_t<LeftType>;
628 using container_t_b = std::remove_cvref_t<RightType>;
630 constexpr std::size_t N = std::tuple_size_v<std::remove_cvref_t<RightType>>;
632 if constexpr(std::is_rvalue_reference_v<
decltype(
B)>)
634 for(std::size_t i{}; i < N; ++i)
B[i] =
A /
B[i];
642 for(std::size_t i=0; i < N; ++i) C[i] =
A /
B[i];
649 template<cgt::std_array_flat_c ArrayType, cgt::numerical_c ScalarType>
652 constexpr std::size_t N =
653 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
657 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
658 std::is_rvalue_reference_v<
decltype(
A)>)
660 for(std::size_t i{}; i < N; ++i)
669 for(std::size_t i=0; i < N; ++i)
676 template<cgt::numerical_c ScalarType, cgt::std_array_flat_c ArrayType>
679 constexpr std::size_t N =
680 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
684 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
685 std::is_rvalue_reference_v<
decltype(
A)>)
687 for(std::size_t i{}; i < N; ++i)
696 for(std::size_t i=0; i < N; ++i)
703 template<cgt::std_array_flat_c ArrayType, cgt::numerical_c ScalarType>
706 constexpr std::size_t N =
707 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
711 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
712 std::is_rvalue_reference_v<
decltype(
A)>)
714 for(std::size_t i{}; i < N; ++i)
723 for(std::size_t i=0; i < N; ++i)
730 template<cgt::numerical_c ScalarType, cgt::std_array_flat_c ArrayType>
733 constexpr std::size_t N =
734 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
738 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
739 std::is_rvalue_reference_v<
decltype(
A)>)
741 for(std::size_t i{}; i < N; ++i)
750 for(std::size_t i=0; i < N; ++i)
757 template<cgt::std_array_flat_c ArrayType, cgt::numerical_c ScalarType>
760 constexpr std::size_t N =
761 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
765 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
766 std::is_rvalue_reference_v<
decltype(
A)>)
768 for(std::size_t i{}; i < N; ++i)
777 for(std::size_t i=0; i < N; ++i)
784 template<cgt::numerical_c ScalarType, cgt::std_array_flat_c ArrayType>
787 constexpr std::size_t N =
788 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
792 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
793 std::is_rvalue_reference_v<
decltype(
A)>)
795 for(std::size_t i{}; i < N; ++i)
804 for(std::size_t i=0; i < N; ++i)
811 template<cgt::std_array_flat_c ArrayType, cgt::numerical_c ScalarType>
814 constexpr std::size_t N =
815 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
819 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
820 std::is_rvalue_reference_v<
decltype(
A)>)
822 for(std::size_t i{}; i < N; ++i)
831 for(std::size_t i=0; i < N; ++i)
838 template<cgt::numerical_c ScalarType, cgt::std_array_flat_c ArrayType>
841 constexpr std::size_t N =
842 std::tuple_size_v<std::remove_cvref_t<ArrayType>>;
846 if constexpr(std::same_as<c_t, std::remove_cvref_t<ArrayType>> &&
847 std::is_rvalue_reference_v<
decltype(
A)>)
849 for(std::size_t i{}; i < N; ++i)
858 for(std::size_t i=0; i < N; ++i)
typename hidden::st_std_common_array< std::remove_cvref_t< A >, std::remove_cvref_t< B > >::type common_std_array_t
constexpr auto sbo(T &&value) noexcept(!cpg::bDetectOverFlow)
constexpr const bool bDetectOverFlow
auto operator-(const std::tuple< ArgTypes1... > &tuple_a, const std::tuple< ArgTypes2... > &tuple_b)
auto operator+(const std::tuple< ArgTypes1... > &tuple_a, const std::tuple< ArgTypes2... > &tuple_b)
auto operator/(const std::tuple< ArgTypes1... > &tuple_a, const std::tuple< ArgTypes2... > &tuple_b)
auto operator*(const std::tuple< ArgTypes1... > &tuple_a, const std::tuple< ArgTypes2... > &tuple_b)
constexpr decltype(auto) operator&(LeftType &&A, RightType &&B) noexcept(!cpg::bDetectOverFlow)
constexpr decltype(auto) operator%(LeftType &&A, RightType &&B) noexcept(!cpg::bDetectOverFlow)
constexpr auto tuple_size_v