title: C++ Get class type inside static function
body: <p>Inside of a static member function I need to get the type.</p>
  
  <pre><code>class MyClass
  {
       public:
           static void myStaticFunc();
       ...
  };
  </code></pre>
  
  <p>And then in the implementation I want to have:</p>
  
  <pre><code>void MyClass::myStaticFunc()
  {
       // Get MyClass as a type so I can cast using it
       (get_type_from_static_function()*)someOtherVariable;
  }
  </code></pre>
  
  <p>Is this even possible? Normally I would use something from typeinfo on an object but I don't have <strong>this</strong> to work with.</p>
  
  <p>I do not want to just use <code>(MyClass*)</code> because this is going inside of a macro and I'd like to keep it as simple as possible so that it can be called without a class name.</p>
  
  <p>If it helps I am using QT but I couldn't find any macros to get the current class. It doesn't necessarily need to be programmatic - it can be a macro.</p>
  
  <p>Cheers!</p>
  
  <p>EDIT:
  Here is the actual macro function:</p>
  
  <pre><code>#define RPC_FUNCTION(funcName) \
  static void rpc_##funcName(void* oOwner, RpcManager::RpcParamsContainer params){ ((__class__*)oOwner)-&gt;funcName(params); }; \
  void funcName(RpcManager::RpcParamsContainer params);
  </code></pre>
  
  <p>I then call <code>RPC_FUNCTION(foo)</code> in a class declaration. I want <code>__class__</code> to be whatever class declaration I am in. I'm well aware I can just add className after funcName but I want to keep this as simple as possible when actually using it. My RPC manager calls <code>rpc_foo</code> and passes a pointer to an object of the class I declared it in. Essentially I need to know how to determine the actual class of that void* parameter.</p>