title: auto and static_casts - good practice
body: <p>In the Scott Meyer's book Effective Modern C++ we can read, that:</p>
  
  <pre><code>std::vector&lt;bool&gt; features(const Widget&amp; w);
  Widget w;
  …
  bool highPriority = features(w)[5];
  …
  processWidget(w, highPriority); 
  </code></pre>
  
  <p>and an option with auto</p>
  
  <pre><code>auto highPriority = features(w)[5];
  </code></pre>
  
  <p>which causes undefined behavior, because of the fact, that <code>features()</code> is returning <code>std::vector&lt;bool&gt;</code>, that uses proxy Object of type <code>std::vector&lt;bool&gt;::reference</code> when returning a value from <code>opearator[]</code>.</p>
  
  <p>As a solution to this is adviced not to stop using <code>auto</code>, but using <code>static_casts</code>.</p>
  
  <p>So Scott Meyers advice to use:</p>
  
  <pre><code>auto highPriority = static_cast&lt;bool&gt;(features(w)[5]);
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>bool highPriority = features(w)[5];
  </code></pre>
  
  <p>My question is:
  What is a real difference between those two? In my opinion both are the same, because both methods make refactoring harder in exactly the same way (changing return value type in the function features does not make variable highPriority a different type) and second one is shorter to write.</p>