title: C++ Mixins of 2 functional types
body: <p>I'm trying to write code that is effectively:</p>
  
  <pre><code>template &lt;typename... Mixins&gt;
  class Checker : public Mixins... {
  public:
      template&lt;typename... Args&gt;
      Checker(Args&amp;&amp;... args) : Mixins(std::forward&lt;Args&gt;(args))... { }
  
      bool check(void) {
          bool tests = true;
          // TODO: for each Mixins that has Mixin::check
          {
              tests = tests &amp;&amp; Mixin::check();
          }
  
          if (!tests) {
              // TODO: for each Mixin that has Mixin::handle
              {
                  Mixin::handle()
              }
          }
  
          return tests
      }    
  };
  </code></pre>
  
  <p>I just don't know how to do the loops over just those Mixins satisfying the member conditions specified.  I've tried various solutions for iteration and for enable_if type semantics but nothing seems to compile.</p>
  
  <p><strong>Additional</strong></p>
  
  <p>So, what I've tried so far visa vi for-each base recursion and SFINAE function elimination is the following, which doesn't compile:</p>
  
  <pre><code>template &lt;typename C, typename... Mx&gt;
  struct do_checks;
  
  template &lt;typename C&gt;
  struct do_checks&lt;C&gt; {
      static bool check(C *) {
          return true;
      }
  };
  
  
  template &lt;typename C, typename E, typename... Mx&gt;
  struct do_checks&lt;C, E, Mx...&gt; {
      struct general_ { };
      struct special_ : general_ { };
      template &lt;typename&gt; struct int_ { typedef int type; };
  
      template &lt;typename F, typename int_&lt;decltype(F::check)&gt;::type = 0&gt;
      static bool check(C *ptr, special_) {
          if (!ptr-&gt;F::check()) {
              return false;
          }
          return do_checks&lt;C, Mx...&gt;::check(ptr);
      }
      template &lt;typename F&gt;
      static bool check(C *ptr, general_) {
          return do_checks&lt;C, Mx...&gt;::check(ptr);
      }
  };
  </code></pre>
  
  <p>Where F should be E.  I don't know how to tell the compiler to compile the first "check" if the int_ has a type and the second if it doesn't.</p>