title: Why isn't std::iota constexpr?
body: <p>The following program prints out a shuffled deck of cards (as integers):</p>
  
  <pre><code>#include &lt;array&gt;
  #include &lt;algorithm&gt;
  #include &lt;random&gt;
  #include &lt;iostream&gt;
  
  typedef unsigned int card;
  typedef std::array&lt;card, 52&gt; deck;
  auto shuffled_deck(){
      deck d = {};
      std::iota(d.begin(), d.end(), 0);
      std::shuffle(d.begin(), d.end(), std::default_random_engine());
      return d;
  }
  
  int main(){
      for(auto&amp; i: shuffled_deck()) std::cout &lt;&lt; i &lt;&lt; ", ";
  }
  </code></pre>
  
  <p>Compiled with <code>g++ -std=c++17</code> the program runs and prints:</p>
  
  <pre><code>18, 34, 27, 46, 11, 3, 12, 19, 33, 21, 41, 13, 36, 49, 40, 22, 8, 9, 28, 2, 6, 30, 50, 24, 37, 32, 35, 4, 15, 45, 47, 43, 14, 44, 20, 23, 29, 7, 31, 51, 26, 10, 42, 48, 0, 38, 5, 16, 17, 1, 25, 39,
  </code></pre>
  
  <p>This  is great, but intuition tells me that this deck could be created at compile-time, so I make the <code>shuffled_deck</code> method <code>constexpr</code></p>
  
  <pre><code>constexpr auto shuffled_deck(){
      deck d = {};
      std::iota(d.begin(), d.end(), 0); // Error! Iota isn't constexpr!
      std::shuffle(d.begin(), d.end(), std::default_random_engine());
      return d;
  }
  </code></pre>
  
  <p>Compiling with <code>g++ -std=c++17</code> gives you compilation error saying that <code>std::iota</code> is not <code>constexpr</code>. My question is why? Surely <code>std::iota</code> is determinable at compile-time. Is the standard library just lagging behind on this feature?</p>