title: Elegant way of implementing call multiplexing in a C++ aggregate class?
body: <p>When multiplexing calls to many sub-objects, what is an elegant way of preventing looping-boilerplate code?</p>
  
  <p>Problem description by example:</p>
  
  <pre><code>struct Foo {
    void Boo();
    void Hoo();
    bool IsActivated();
  };
  
  struct FooAggregator {
    ...
    void Boo();
    void Hoo();
    ...
    std::vector&lt;Foo&gt; m_foos;
  };
  
  FooAggregator::Boo() {
    for(size_t i=0, e=m_foos.size(); i!=e; ++i) {
      if(m_foos[i].IsActivated()) {
        m_foos[i].Boo();
      }
    }
  }
  
  FooAggregator::Hoo() {
    for(size_t i=0, e=m_foos.size(); i!=e; ++i) {
      if(m_foos[i].IsActivated()) {
        m_foos[i].Hoo();
      }
    }
  }
  </code></pre>
  
  <p>As you can see, the FooAggregator implements the same (similar) interface as a single Foo, iterating over all Foo objects calling their respective member functions.</p>
  
  <p>As you also can see, the iteration loop is complete boilerplate, repeated for every member function of FooAggregator.</p>
  
  <p><em>What is an elegant way of removing the boilerplate from the implementation of FooAggregators member functions</em></p>