title: Is array loaded entirely if an element is read? (Am I basically flushing my cache?)
body: <p>I have an enum <code>EFoo</code> and want to use it as a key pointing to <code>static const Foo</code>s (or <code>constexpr</code> rather, but that's not really the point). Either way, <code>Foo</code> is bascially a bunch of parameters used by a large number of <code>Owner</code>s which have a list of <code>EFoo</code>s they can use. Since the list of active <code>Owner</code>s is large, I can't save <code>Foo</code> on each owner, so I'm using an enum like a pointer but it's easier to use as it's named (and as a bonus, smaller).</p>
  <p>I'm basically concerned would I be basically flushing cache on each use / read / conversion of key to object if the read is from an array.</p>
  <p>So, in regards to cache usage and supposing 80/20* use of objects, can the objects be laid out:</p>
  <ul>
  <li>option 1: in an array without polluting cache with the rest of array elements when read from; or</li>
  <li>option 2: to prevent cache pollution, each object must be defined separately?</li>
  <li>if same, option 1 is better because it doesn't require maintaining nor jumping through an additional switch list.</li>
  <li>by 80/20 I mean Pareto defined 80% of usage by 20% of sources.</li>
  </ul>
  <p>Storage:</p>
  <pre class="lang-cpp prettyprint-override"><code>// FooData.inl
  #include Foo.h
  
  // option 1: stored as array
  static const Foo Foos[256] {
    /* A */ {...},
    /* B */ {...},
  }
  
  // option 2: stored as separate
  namespace Foos {
    static const A { ... };
    ...
  }
  </code></pre>
  <p>Usage:</p>
  <pre class="lang-cpp prettyprint-override"><code>// Keys.h
  enum class EFoo : uint8 { A, B, ... }
  // Foo.h
  struct Foo { ... void operator= (EFoo Key); }
  
  // Foo.cpp
  #include Foo.h
  #include FooData.inl
  void Foo::operator= (EFoo Key) {
    // option 1: read from array
    *this = Foos[(uint8)Key];
    // option 2: read from separate
    switch (Key) {
      case EFoo::A: *this = Foos::A; ...
    }
  }
  </code></pre>