title: C++ separate structs in to "groups" but allow `std::variant` to see all structs across the "groups"
body: <p>Please see code below.</p>
  <p>I have 3 <code>struct</code>s (<code>A</code>, <code>B</code> and <code>C</code>) defined across 2 groups (in reality I have many more). The groups are to provide context within the real-world domain i'm modelling. These groups are implemented via two <code>std::variant</code>s (<code>Group1</code> and <code>Group2</code>).</p>
  <p>I have a function which can return any of the underlying <code>struct</code>s.</p>
  <p>To provide a single return type for the function I create a third <code>std::variant</code> (<code>AllGroups</code>) from my initial two variants (<code>Group1</code> and <code>Group2</code>).</p>
  <p>However, my problem is <code>AllGroups</code> cannot see <code>A</code>, <code>B</code> or <code>C</code>, only <code>Group1</code> and <code>Group2</code>.</p>
  <p>Is there a way to keep the structs defined with some sort of group but also collapse them in to one <code>std::variant</code> for the function return type?</p>
  <pre><code>#include &lt;variant&gt;
  #include &lt;iostream&gt;
  
  struct A{}; struct B{};
  using Group1 = std::variant&lt;A, B&gt;;
  
  struct C{};
  using Group2 = std::variant&lt;C&gt;;
  
  using AllGroups = std::variant&lt;Group1, Group2&gt;;
  
  AllGroups getObject()
  {
      A a;     // Simple logic for the general question
      AllGroups ret(a);
      return ret;
  }
  
  int main()
  {
      AllGroups ret = getObject();
  
      // Here i'd like to check for the individual structs, not Group1 and Group2
      // However I get a compiler error because the AllVariant can only see Group1 and Group2
  
      std::cout &lt;&lt; std::holds_alternative&lt;A&gt;(ret) &lt;&lt; std::endl;
  }
  </code></pre>