title: Reset an element in a circular buffer
body: <p>I was asked to implement a circular buffer that takes <strong>an unspecified type</strong> in C++. I assume the generic type to be of <strong>primitive type</strong>. (or should it consider non-primitive types?) For the buffer, I am using a <strong>basic array, e.g. T[]</strong> with <strong>new</strong> and <strong>delete</strong> to initialize and destroy it. </p>
  
  <p>I have implemented the buffer class and tested it on integers with the expected output. But it does not work on <code>std::string</code>. The problem is that, when I pop the buffer, I clear the element by setting it to zero, and the compiler complains that doing so is ambiguous. As such, I need a generic way to clear an element, and I thought the <code>std::array</code> might support this feature, but I cannot find it in the documentation.</p>
  
  <p>Is there a generic way to clear an element in a std::array or basic array, or is std::allocator my only option? Or, if I am completely in the wrong direction, How should I implement the pop method to <strong>reset the first element and increment the front index to that of the next element</strong>?</p>
  
  <p>Thanks in advance!</p>
  
  <p>In case it helps, below is my related code:</p>
  
  <pre><code>template&lt;class T&gt; T CircularBuffer&lt;T&gt;::pop_front()
  {
      if (_size == 0)
          return 0;
      T value = buffer[_front];
      buffer[_front] = 0;
      if (--_size == 0)
      {
          _front = -1;
          _back = -1;
      }
      else
      {
          _front = (_front + 1) % _capacity;
      }
      return value;
  }
  </code></pre>