I have a problem similar to
Generating a sequence of zeros at compile time
However, in my case I have no pack to expand. The situation is like this:
template<size_t N>
void foo()
{ bar(T{}, ..., static_cast<T>(1)); }
There are N - 1
T{}:s followed by a one.
It may happen that T
is not usable as a non-type template parameter. There are two differences compared to the linked post
I may use a solution that require C++20
you generate the sequence yourself
#include <utility>
template<std::size_t N>
void foo(){
[&]<std::size_t...I>(std::index_sequence<I...>){
bar((I,T{}) ... , static_cast<T>(1));
}(std::make_index_sequence<N-1>());
}