title: Constructing struct within union
body: <p>I have created a union comprising a uint64_t and a struct. I would like the union constructor to construct the inner struct but I can't seem to get it working. Here's a couple of variations I have tried:</p>
  
  <pre><code>union subid_u
  {
      inline subid_u(uint32_t gid_, uint32_t sid_)
          : detail.gid(gid_), detail.sid(sid_) {}
  
      struct detail_t
      {
          uint32_t gid;
          uint32_t sid;
      };
  
      detail_t    detail;
      uint64_t    subscriptionID;
  };
  //main.cpp: In constructor 'subid_u::subid_u(uint32_t, uint32_t)':
  //main.cpp:7: error: expected `(' before '.' token
  //main.cpp:7: error: expected `{' before '.' token
  
  
  union subid_u
  {
      inline subid_u(uint32_t gid_, uint32_t sid_)
          : detail(gid_, sid_) {}
  
      struct detail_t
      {
          inline detail_t(uint32_t g, uint32_t s)
              : gid(g), sid(s) {}
  
          uint32_t gid;
          uint32_t sid;
      };
  
      detail_t    detail;
      uint64_t    subscriptionID;
  };
  //main.cpp:18: error: member 'subid_u::detail_t subid_u::detail' with constructor not allowed in union
  </code></pre>