- raise
void raise(IntFlags flags)
Undocumented in source. Be warned that the author may not have intended to support it.
- raise
void raise(IntFlag flag)
Undocumented in source. Be warned that the author may not have intended to support it.
- raise
void raise(IntFlags flags)
Undocumented in source. Be warned that the author may not have intended to support it.
- raise
void raise(IntFlag flag)
Undocumented in source. Be warned that the author may not have intended to support it.
- raise
void raise(IntFlags flags)
Undocumented in source. Be warned that the author may not have intended to support it.
- raise
void raise(IntFlag flag)
Undocumented in source. Be warned that the author may not have intended to support it.
- raise
void raise(IntFlags flags)
Undocumented in source. Be warned that the author may not have intended to support it.
- raise
void raise(IntFlag flag)
Undocumented in source. Be warned that the author may not have intended to support it.
import checkedint.throws : raise; // set IntFlagPolicy.throws
bool caught = false;
try
{
raise(IntFlag.div0);
}
catch (CheckedIntException e)
{
caught = (e.intFlags == IntFlag.div0);
}
assert(caught);
import checkedint.asserts : raise; // set IntFlagPolicy.asserts
bool caught = false;
try
{
raise(IntFlag.div0);
}
catch (Error e)
{
caught = (e.msg == "divide by zero");
}
assert(caught);
import checkedint.sticky : raise; // set IntFlagPolicy.sticky
raise(IntFlag.div0);
raise(IntFlag.posOver);
assert(IntFlags.local.clear() == (IntFlag.div0 | IntFlag.posOver));
// Multiple signaling strategies may be usefully mixed within the same program:
alias IFP = IntFlagPolicy;
static void fails() @safe nothrow
{
raise!(IFP.sticky)(IntFlag.negOver);
raise!(IFP.sticky)(IntFlag.imag);
}
bool caught = false;
try
{
fails();
// Flags that were raised by `nothrow` code can easily be turned into an exception by the caller.
raise!(IFP.throws)(IntFlags.local.clear());
}
catch (CheckedIntException e)
{
caught = (e.intFlags == (IntFlag.negOver | IntFlag.imag));
}
assert(caught);
Function used to signal a failure and its proximate cause from integer math code. Depending on the value of the policy parameter, raise() will either: