Quantcast
Viewing all articles
Browse latest Browse all 4

Answer by Benoît for C++ Queue Implementation

Please use std::vector instead of T* because you clearly don't know what you are doing (missing operator=, copy-constructor, etc). Better, make the underlying container a template parameter.

The std::queue is probably slower because it may free some memory when doing all these pop() while yours doest release anything.

About this:

    if (m_size == 0) {        throw;    }

what do you think you are throwing ? Please throw a proper exception (see http://en.cppreference.com/w/cpp/header/stdexcept for example).


Viewing all articles
Browse latest Browse all 4

Trending Articles