title: Static constexpr array of class objects inside the class itself
body: <p>Is it possible to have something like this in C++:</p>
  
  <pre><code>struct Foo
  {
      int x;
      constexpr Foo(int x) : x(x) {}
  
      static constexpr Foo table[] =
      {
          Foo(0),
          Foo(1),
          Foo(2),
      };
  };
  </code></pre>
  
  <p>I have tried several combination, but none work. It works if table is not part of Foo class, however I would really like it to be part of the Foo namespace.</p>
  
  <hr>
  
  <p><strong>Edit:</strong> </p>
  
  <p>The reason I want this is so I can access the table as <code>Foo::table</code>. I have several classes like this in a namespace and it is really convenient if I can import the class I am using by writing <code>using someNamespace::Foo</code> and then access the table as <code>Foo::table</code>. If the table is outside the class I have to always access it by writing <code>someNamespace::fooTable</code>.</p>