On Wed, Feb 10, 2016 at 5:11 PM, Gavin Lambert
On 11/02/2016 12:23, Emil Dotchevski wrote:
If you know that the queue is never supposed to be full, that is, if the full queue indicates a bug in your code, then you should assert rather than throw. Throwing is when you expect the program to successfully recover from an anticipated (by the programmer) failure.
Sorry, I missed responding to this part.
No, you should not assert in this case. Filling a queue is something that easily could happen at runtime in release mode (even if the programmer thinks it's not supposed to), where asserts are disabled and valueless.
Dereferencing a null shared_ptr is something that easily could happen at runtime. Are you saying that it shouldn't assert in this case? Are you saying that that assert is useless? Are you saying that the correct design is to throw? Or is the correct design to assert and throw? Emil