The usual.
template<size_t...Is>
std::array<foo_t, sizeof...(Is)> make_foos(std::index_sequence<Is...>) {
return { ((void)Is, make_foo())... };
}
template<size_t N>
std::array<foo_t, N> make_foos() {
return make_foos(std::make_index_sequence<N>());
}
More Related Contents:
- Why is list initialization (using curly braces) better than the alternatives?
- How to emulate C array initialization “int arr[] = { e1, e2, e3, … }” behaviour with std::array?
- What are the differences between C-like, constructor, and uniform initialization?
- Does the default constructor initialize built-in types?
- How is “=default” different from “{}” for default constructor and destructor?
- Why can’t simple initialize (with braces) 2D std::array? [duplicate]
- What are the advantages of list initialization (using curly braces)?
- C++11 allows in-class initialization of non-static and non-const members. What changed?
- When is a private constructor not a private constructor?
- std::array vs array performance
- How to initialize std::array elegantly if T is not default constructible?
- Default initialization of std::array?
- C++11: Correct std::array initialization?
- Passing a std::array of unknown size to a function
- Why does std::array not have an constructor that takes a value for the array to be filled with?
- Now that we have std::array what uses are left for C-style arrays?
- C++11 member initializer list vs in-class initializer?
- Initializing container of unique_ptrs from initializer list fails with GCC 4.7
- too many initializers for ‘int [0]’ c++
- Has the new C++11 member initialization feature at declaration made initialization lists obsolete?
- Different ways of initializing an object in c++
- What’s the difference between parentheses and braces in c++ when constructing objects
- How to create std::array with initialization list without providing size directly [duplicate]
- Initialization difference with or without curly braces in C++
- Is there a way to statically-initialize a dynamically-allocated array in C++?
- Is it possible to print a variable’s type in standard C++?
- What does T&& (double ampersand) mean in C++11?
- Variadic template pack expansion
- order of evaluation of operands
- What is “->” after function declaration?