[phobos] enforce() vs. assert() for range primitives
Jonathan M Davis
jmdavisprog at gmail.com
Wed Aug 18 17:10:55 PDT 2010
On Wednesday, August 18, 2010 16:36:07 David Simcha wrote:
> A valid criticism in general. However, all of the ranges in question
> are templates, so each instantiation is compiled in whatever mode your
> program is compiled in.
Ah good point. I missed that. That being the case, I'd probably lean towards
assertions. Ranges need to be high performance. They should have very clear
error messages with them rather than be bare assertions (so hopefully the
programmer will realize that it's _their_ bug and not Phobos'), but still
assertions. I think that ranges are too performance critical for enforce() if
assertions are actually useable (and as you point out, since they're templates,
assertions will be useable). So, I'd vote assertions.
- Jonathan M Davis
More information about the phobos
mailing list