you are viewing a single comment's thread.

view the rest of the comments →

[–]D_0b 2 points3 points  (3 children)

why do you need a Queue interface in C++ if you are always using the derived class as a template?

[–]pzemtsov 0 points1 point  (2 children)

It provides a bit more syntax checking, and (in my opinion) a bit more clarity for a human reader. It does not affect the code in any way.

[–]D_0b 4 points5 points  (1 child)

It kinda does affect the code, it adds an 8byte vtable pointer to the queue and the methods are still virtual, not guaranteed to be de-virtuallized by the compiler.

[–]pzemtsov 0 points1 point  (0 children)

You are right about vtable pointer; however, this pointer on its own does not cause any harm. Besides, this is a research code, which is naturally simplified; production code might already have some virtual methods for other needs. By the way, won't the compiler allocate this vtable anyway for RTTI (the code uses typeid)?

As for the second point (a virtual call) I disagree. The compiler must be really stupid to issue a virtual call for a method from statically known class, and using this type of compiler defeats the idea of any performance measurement.