Fixed array with configurable bounds A interesting challenge was brought to my attention: to "flip" an array. I thought it might be more convenient if its bounds were symmetrical, say [-N..N] instead of [0 .. 2N + 1].

Now I'm curious about what could be done to make this Array more mature. Say, like a Boost component.

#include &lt;cassert&gt;
#include &lt;iostream&gt;
#include &lt;algorithm&gt;

template &lt;typename T, int LoBound, int HiBound&gt; class Array {
  T arr_[HiBound - LoBound + 1];
public:
  Array()
  {
    std::fill(arr_, arr_ + sizeof(arr_) / sizeof(arr_[0]), T{});
  }
  Array(const Array&amp; other)
    :arr_(other.arr_)
  {}
  Array(std::initializer_list&lt;T&gt; initList)
  {
    std::copy(initList.begin(), initList.end(), arr_);
  }
  T&amp; operator[](int ix)
  {
    assert(ix &gt;= LoBound &amp;&amp; ix &lt;= HiBound);
    return arr_[ix - LoBound];
  }
  const T&amp; operator[](int ix) const
  {
    assert(ix &gt;= LoBound &amp;&amp; ix &lt;= HiBound);
    return arr_[ix - LoBound];
  }
};

int main()
{
  enum {LoBound = -2, HiBound = 2};
  using A1D = Array&lt;int, LoBound, HiBound&gt;;
  Array&lt;A1D, LoBound, HiBound&gt; arr =
   { A1D{ 1,  2,  3,  4,  5},
     A1D{ 6,  7,  8,  9, 10},
    A1D{11, 12, 13, 14, 15},
    A1D{16, 17, 18, 19, 20},
    A1D{21, 22, 23, 24, 25} };
  for (int i = LoBound; i &lt;= HiBound; ++i) {
    for (int j = LoBound; j &lt;= HiBound; ++j) {
      std::cout &lt;&lt; arr[-i][-j] &lt;&lt; " ";
    }
    std::cout &lt;&lt; "\n";
  }
  return 0;
}
It looks pretty clean to me.


The copy constructor doesn't have to be explicitly declared, you could = default it or just omit.
You shouldn't fill() the array. It is already default constructed, so that's just duplicated work. The default constructor again could be = default or omitted. 
Actually, maybe could provide an explicit constructor that takes a fill value. That can be handy.
A size() method to return sizeof(arr_) / sizeof(arr_[0]) should be useful, for both internal and external uses.
Mark the class final? I'd probably do it, but that's probably a matter of personal preference.
If you're interested in making this class Standard compliant, well, there's a long road ahead ;). It needs iterators and several other methods ([c]begin/[c]end/front/back/at...). Look into std::array for the details.