
Mathias Gaunard wrote:
Edward Diener wrote:
I disagree with your analysis. The '26' value could be a run-time calculation and not just a compile-time constant. In which case you are saying that the assignment of a run-time calculation should assert only when run in debug mode and otherwise should be ignored. I can not agree with that idea.
I say it is up to the programmer to ensure valid values are provided. If the value is only known at runtime, there should be explicit checking in the code prior to assignment.
Suppose the value is provided by the end user of the program. Do you still feel such a value, when used in a constraint, should assert only in debug mode rather than throw an exception ? A large part of the constrained value concept is that the constraint provides the necessary checking, in the form of a policy, which alleviates specific pre-checking by the programmer. I like that, else the constraint library serves less purpose than it could.