title: Can you create an opaque structure wrapper with no runtime penalties?
body: <p>I have an executable A that dynamically loads a shared library B.</p>
  <p>Within B there is a method that returns an object. For a variety of reasons the only thing that A can know at compile time about this object is its size in bytes. It doesn't know how many fields there are or even its type. However A is responsible of keeping this handle around.</p>
  <p>If the size of the object created by B is an int for example (e.g. a POD struct with 4 byte size fields).</p>
  <p>You can make this kind of wrapper:</p>
  <pre><code>struct ObjectHandle
  {
      uint64_t handle = 0;
      ObjectHandle() {}
      ObjectHandle(uint64_t h) : handle(h) {}
      operator uint64_t() {return handle;}
  };
  </code></pre>
  <p>You can now typecast the object to be represented into a uint64_t and A can keep it around even without knowing what it is, all it knows is that <code>ObjectHandle</code> is some data with some size.</p>
  <p>I need to accomplish the same for cases where the data doesn;t fit into a uint64_t.</p>
  <p>i.e. I want to create an object with a known byte size whose only purpose is to act as an opaque byte container for the relevant data.</p>
  <p>&quot;Why not pointers and keep it as void&quot;?</p>
  <p>Indirection, this is for a time critical system, the cache misses from doing this with pointers is too much a penalty. The type casting should have no runtime penalties.</p>
  <p>Is this achievable?</p>