On Apr 24, 11:53 pm, "Bo Persson" <b...@gmb.dk> wrote:
osama...@gmail.com wrote:
[...]
Does that mean references and templates are not to be mixed?
No, they work very well together. I think the void* is the
problem here, and that you are trying too hard to optimize the
code.
I would trust my compiler here, and just write
template<class T>
class GenericQueue
{
bool Pop(T&);
};
Given that he requires pointer semantics, and copying a pointer
cannot throw, there's no reason not to just use
T* pop() ;
in the generic interface.
if that is the interface needed (it probably is not - take a
look at std::queue and std::stack).
There's a slight difference. The standard containers are
designed to store values, not (only) pointers. So the
alternatives are:
-- return a T, but not be thread safe,
[...]
Globally, I think the first alternative was dismissed because of
the lack of thread safety (although I think it was what was used
in the original STL); of the latter two, the last seems to offer
the most flexibility, and was chosen.
has already been removed from the internal queue). There is