try/catch idiom in std.datetime
Michel Fortin
michel.fortin at michelf.ca
Mon Nov 18 19:29:48 PST 2013
On 2013-11-18 23:42:13 +0000, "Jonathan M Davis" <jmdavisProg at gmx.com> said:
> I understand this. The problem is that in some cases, in order to do the
> check, you have to do all of the work that the function you're trying to
> protect bad input from has to do anyway - even without it asserting anything.
> So, having a separate function do the checking would just be extra overhead.
Very true.
I'll just point out now that you could actually have only one function
that does one or the other or both depending on template parameters.
One template parameter is the output sink, which could be a dummy type
that does nothing or an actual type that saves the data somewhere.
Another parameter is the error handler, which can be a dummy type that
does nothing, or it could assert or throw when an error is found. Let
the optimizer remove the do-nothing code paths that will result.
Now, I really have no idea but that could be overkill in this situation.
--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca
More information about the Digitalmars-d
mailing list