title: has_member_of_type - template metaprogramming in C++
body: <p>I suspect this is not possible under the current C++ standards but I'll ask anyway.</p>
  
  <p>What I'm trying to achieve is to get the compiler to figure out during compile time if a class contains any member variable of type Base (along with its derivations).</p>
  
  <p>e.g.</p>
  
  <pre><code>struct Base
  {
  };
  
  struct Derived : public Base
  {
  };
  
  struct Foo
  {
      int x;
      Derived a;
      Derived b;
  };
  
  struct Bar
  {
      int x;
  };
  </code></pre>
  
  <p>I want something along the line of,</p>
  
  <pre><code>has_member_of_type&lt;Base, Foo&gt;::value
  </code></pre>
  
  <p>in which case would be true (one or more member vars have a base type of Base), while anything else (including fundamental types) would eval to false.</p>
  
  <p>e.g.</p>
  
  <pre><code>has_member_of_type&lt;Base, char&gt;::value = false
  has_member_of_type&lt;Base, Bar&gt;::value = false
  </code></pre>
  
  <p>Note that I'm trying to use has_member_of_type in my library to detect and use different code branch if user class has a member variable of a certain type.</p>