Safety/purity and assert/enforce error messages
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Thu Sep 12 11:13:37 PDT 2013
Hi all,
Suppose that I want to insert some variable values into an assert error message.
The easy way to do this is something like:
assert(someCondition, text("x = ", x, ", cannot blah blah blah"));
However, the use of text() prevents me from applying @safe and other such
attributes to the function containing this assert, even though text() will only
be called in the event of an assertion failure.
Is there any reliable way to include variable values in the error message that
doesn't interfere with @safe, pure, etc.? Using to!string has a similar problem.
Thanks & best wishes,
-- Joe
More information about the Digitalmars-d-learn
mailing list