title: Is it legal to derive from std::initializer_list?
body: <p>Can I use <code>std::initializer_list</code> list as a base class?</p>
  <pre><code>template &lt;typename T&gt;
  struct il : std::initializer_list&lt;T&gt;
  {
      using base = std::initializer_list&lt;T&gt;;
  
      il(base list): base(list) {}
  
      const T &amp;operator[](size_t i) const
          { return *(base::begin()+i); }
  };
  
  void print2(il&lt;int&gt; list)
  {
      for (size_t i = 0; i &lt; list.size(); i += 2)
          { std::cerr &lt;&lt; list[i] &lt;&lt; &quot;; &quot;; }
  
      std::cerr &lt;&lt; std::endl;
  }
  
  int main()
  {
      print2({0, 1, 2, 3, 4, 5, 6});
  }
  
  // The output: 0; 2; 4; 6; 
  </code></pre>
  <p>The code above works in both <a href="https://coliru.stacked-crooked.com/a/bdc8ae2146baab1b" rel="nofollow noreferrer">GCC</a> and <a href="https://coliru.stacked-crooked.com/a/d7c92c302f967ac4" rel="nofollow noreferrer">Clang</a>. But is it actually valid?</p>
  <p>The <a href="https://en.cppreference.com/w/cpp/utility/initializer_list" rel="nofollow noreferrer">cppreference.com</a> defines <code>std::initializer_list</code> as follows:</p>
  <pre><code>template&lt; class T &gt;
  class initializer_list;
  </code></pre>
  <p>But does this mean that <code>std::initializer_list</code> is an ordinary class like any other? I thought it is kind of special object in C++.</p>