title: Initializer list in a range for loop
body: <p>I have objects of different types derived from a single super-type. I wonder if there are any disadvantages in using <code>std::initializer</code> list in a range for loop like this:</p>
  
  <pre><code>for(auto object: std::initializer_list&lt;Object *&gt;{object1, object2, object3}) {
  }
  </code></pre>
  
  <p>Is it completely OK and efficient or would it be better to use an array? To me the <code>std::array</code> solution seems to be more restrictive for the compiler and there is a disadvantage of explicitly stating the size:</p>
  
  <pre><code>for(auto object: std::array&lt;Object*, 3&gt;{object1, object2, object3}) {
  }
  </code></pre>
  
  <p>Is there any other or nicer way of iterating over an explicitly given list of objects?</p>