I would like to create a template function taking an std::array<int, N> as a nontype template argument for any N (you can do that since C++20).

Explicitly I can do it like this:

#include <array>

template<int N, std::array<int, N> Arg>
void foo() {}

int main() {
    foo<2, {1, 2}>();
}

Can I make N be somehow deduced? For example, something like this:

#include <array>

template<std::array<int, N> Arg, int N>
void bar() {}

int main() {
    bar<{1, 2}>();
}

The above fails to compile, as N is used before it is declared.

-----

A bit broader context: I actually want a template taking two of such arrays, so that I can call it like this:

foo<{1, 2, 3}, {4, 5, 6, 7}>()

The split into two sets of numbers is significant. I could probably define a special break value and just use a variadic template:

constexpr int BREAK = -1;
foo<1, 2, 3, BREAK, 4, 5, 6, 7>()

But this looks like an ugly hack, not to mention the added complexity in the foo implementation, where it now needs to find the BREAK and derive the sizes of the two number sets.