Fixed a bug that might invoke undefined behavior

Calling front() on an empty container would invoke undefined behavior