title: How to check whether a class has specified nested class definition or typedef in C++ 11?
body: <p>In my project, I want to implement a template proxy class of some existing bigger classes. The existing classes are library classes, so they can not be modified. In most cases, the clients do not know the objects are instances of proxy class or bigger class. In some cases, however, the clients MUST know the detailed class information. Since the proxy class is itself a template class, I do not think simple function overloading by class name could solve this problem. The possible solution I thought is to add an internal nested class or typedef inside the proxy class, and the client check whether this class/typedef exists to get the class information. My question is: how to check whether a class has specified nested class definition or typedef in C++ 11 ?</p>
  
  <p>The following codes show an example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;type_traits&gt;
  
  typedef std::string CBig1;  //  use string for demonstration
  typedef std::string CBig2;  //  use string for demonstration
  
  //class CBig1;   // the bigger class 1, codes of which can not be changed
  //class CBig2;   // the bigger class 2, codes of which can not be changed
  
  template &lt;typename _Big, typename _Other&gt;
  class CProxy
  {
  public:
      struct proxy_tag { };
  };
  
  //  how to implement this ?
  //  the proxy traits class, if defined _T::proxy_tag, the ``type'' will be std::true_type, otherwise the ``type'' will be std::false_type
  template &lt;typename _T&gt;
  struct is_proxy
  {
      //typedef std::true_type type;
      //typedef std::false_type type;
  };
  
  template &lt;typename _T&gt;
  void ClientHelp(const _T&amp; t, std::false_type)
  {
      //  process real class
      std::cerr &lt;&lt; "real class" &lt;&lt; std::endl;
  }
  
  template &lt;typename _T&gt;
  void ClientHelp(const _T&amp; t, std::true_type)
  {
      //  process proxy class
      std::cerr &lt;&lt; "proxy class" &lt;&lt; std::endl;
  }
  
  template &lt;typename _T&gt;
  void Client(const _T&amp; t)
  {
      ClientHelp(t, typename is_proxy&lt;_T&gt;::type());
  }
  
  int main(int argc, char* argv[])
  {
      CBig1 b;
      CProxy&lt;CBig1, int&gt; p;
      Client(b);
      Client(p);
      return 0;
  }
  </code></pre>
  
  <p>How to implement the traits class <code>is_proxy</code>?</p>