- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
#include <iostream>
#include <functional>
#include <array>
template<typename F, int... I>
std::array<int, sizeof...(I)> materializeImpl(const F & f, std::integer_sequence<int, I...>)
{
return { (f(), I)... };
}
template<size_t N, typename F, typename I = std::make_integer_sequence<int, N>>
auto materialize(const F & f)
{
return materializeImpl(f, I{});
}
template<size_t N, typename F>
void times(const F & f)
{
(void)materialize<N>([&f]() { f(); return 0; });
}
int main()
{
times<22>([]() { std::cout << "Hello There." << std::endl; });
return EXIT_SUCCESS;
}