title: Zero cost abstraction for executing same statement on multiple objects
body: <p>Assume three objects <code>A a</code>, <code>B b</code> and <code>C c</code>. All three have a method with the signature <code>void foo(Bar&amp; bar)</code>. </p>
  
  <p>Sometimes I need to write the following code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>a.foo(bar);
  b.foo(bar);
  c.foo(bar);
  </code></pre>
  
  <p>Now that is a lot of code duplication, especially once the expression gets longer. </p>
  
  <p>So far, I have come up with </p>
  
  <pre class="lang-cpp prettyprint-override"><code>foreach (const auto&amp; value : { a, b, c}) value.foo(bar);
  </code></pre>
  
  <p>But that only works if <code>a</code>, <code>b</code> and <code>c</code> are of the same type, and <code>foo</code> is <code>const</code>. </p>
  
  <p><em>Is there an elegant zero-cost abstraction to abstract the free identical method calls at once, for different types and non-const functions?</em></p>
  
  <p>This would preferably work on arbitrary statements involving <code>value</code>.</p>