title: Is it possible to initialize a vector with increasing values in a single line?
body: <p>Is it possible to merge the two initialization lines into a single statement with the help of initializer lists or other C++ features? The vector values always increment with one, but the size <code>n</code> is not fixed.</p>
  
  <pre><code>#include &lt;numeric&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      int n = 10;
  
      // Can the two lines below be combined into a single statement?
      std::vector&lt;int&gt; v(n);
      std::iota(v.begin(), v.end(), 1);
  
      for (int i : v)
          std::cout &lt;&lt; i &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>