|
Boost : |
Subject: Re: [boost] expected/result/etc
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-02-10 20:11:18
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.
You could assert *and* throw (or abort, if you don't know how to recover
from it), although arguably the assert is less useful if you're
repeating the same condition outside the assert anyway. But you can't
just slap an assert in and call it a day, at least not for this sort of
condition.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk