C++ implementation of a gap buffer.