title: Repeat n times with C++ ranges without dummy variable
body: <p>I am trying to implement repeat n times using C++20 ranges.
  It <a href="https://godbolt.org/z/155TvY5hM" rel="nofollow noreferrer">works</a>, but all approaches I can think of need a dummy variable (one for the <code>for</code> loop variable, other for arity of lambda).</p>
  <pre><code>static constexpr int kIterations = 3;
  
  void f1(){
      auto c = '.';
      for (const auto _ :std::views::iota(0)| std::views::take(kIterations) ) {
          std::cout &lt;&lt; c;
      }
      std::cout &lt;&lt; std::endl;
  }
  
  void f2(){
      auto c = '.';
      std::ranges::for_each(std::views::iota(0)| std::views::take(kIterations), [&amp;c](const auto _) {
          std::cout &lt;&lt; c;
      });
      std::cout &lt;&lt; std::endl;
  }
  </code></pre>
  <p>Is there a way to do this with C++20 ranges without the need for dummy variable (<code>_</code> in my case, but even unnamed requires const? auto).</p>
  <p>notes:</p>
  <ul>
  <li>I know I can use C for loop, I am interested in doing this in C++20 ranges way.</li>
  <li>I guess I can implement this in an algorithm myself, but I wonder if I can do it &quot;inline&quot; without me implementing <code>repeat_n</code></li>
  <li>I know <code>iota</code> has version that takes 2 integers, it might be more readable, but still does not fix the problem with dummy variables.</li>
  <li>logic is simplified, just to show capture</li>
  </ul>