9template <
int I1,
int I2>
17template <std::size_t COL,
typename T, std::size_t rows, std::size_t cols,
19constexpr auto get_col(
const std::array<std::array<T, cols>, rows>& in,
20 std::index_sequence<row...>) -> std::array<T, rows> {
21 static_assert(rows ==
sizeof...(row),
"");
22 return {std::get<COL>(std::get<row>(in))...};
25template <
typename T, std::size_t rows, std::size_t cols, std::size_t... row,
28 const std::array<std::array<T, cols>, rows>& in,
29 std::index_sequence<col...>) -> std::array<std::array<T, rows>, cols> {
30 return {get_col<col>(in, std::make_index_sequence<rows>{})...};
33template <
typename T, std::
size_t rows, std::
size_t cols>
35 -> std::array<std::array<T, rows>, cols> {
49 std::array<std::array<int, 4>, 3> input{
50 {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}}};
51 std::array<std::array<int, 3>, 4> transposed{
52 {{0, 4, 8}, {1, 5, 9}, {2, 6, 10}, {3, 7, 11}}};
57template <
int I2,
int... Is1>
59 return {&multi_template<Is1, I2>...};
62template <
typename Tag1,
int... Is2>
64 std::array<std::array<int (*)(), 8>, 8> tmp = {gen_row<Is2>(Tag1{})...};
69 =
gen_dispatch_table<
tag<6, 13, 14, 19, 22, 22, 24, 27>, 1, 3, 5, 6, 18, 21,
73 constexpr std::array<int, 8> i1_lookup = {6, 13, 14, 19, 22, 22, 24, 27};
74 constexpr std::array<int, 8> i2_lookup = {1, 3, 5, 6, 18, 21, 25, 31};
75 auto find = [](
int v,
const std::array<int, 8>& arr) {
76 for (std::size_t i = 0; i != 8; ++i) {
88 for (
auto x : {6, 13, 14, 19, 22, 22, 24, 27}) {
89 for (
auto y : {1, 3, 5, 6, 18, 21, 25, 31}) {
constexpr std::array< std::array< int(*)(), 8 >, 8 > dispatch_table
auto multi_template() -> int
constexpr auto get_col(const std::array< std::array< T, cols >, rows > &in, std::index_sequence< row... >) -> std::array< T, rows >
constexpr auto gen_dispatch_table() -> std::array< std::array< int(*)(), 8 >, 8 >
auto multi_dispatcher(int i1, int i2) -> int
constexpr auto gen_row(tag< Is1... >) -> std::array< int(*)(), 8 >
constexpr auto transpose_arr_impl(const std::array< std::array< T, cols >, rows > &in, std::index_sequence< col... >) -> std::array< std::array< T, rows >, cols >
constexpr auto transpose_arr(std::array< std::array< T, cols >, rows > in) -> std::array< std::array< T, rows >, cols >
Provides basic compile-time logic operations.
auto to_string(Int num) -> std::string
constexpr auto find(ForwardIt begin, EndIt end, const Elem &value) noexcept(noexcept(*begin==value)) -> ForwardIt
Finds a value in range [begin, end). If not found, returns end. It also allows for a sentinel end ite...