http://d.puremagic.com/issues/show_bug.cgi?id=10576
Andrej Mitrovic <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Andrej Mitrovic <[email protected]> 2013-07-08 18:09:20 PDT --- What David means is he wants the ability to both return the value and throw if that value is invalid, however simply using (!value) as enforceEx currently does will not work properly with e.g. signed integers. For example: ----- import std.exception; int returnValid() { return 5; } int returnInvalid() { return -1; } void main() { int x = enforceEx!Exception(returnValid()); assert(x == 5); // ok // this doesn't throw, but we want -1 to signal failure enforceEx!Exception(returnInvalid()); // so as a workaround we use the check inline, however.. int y = enforceEx!Exception(returnInvalid() != -1); // .. it is not useful for the return value since the value becomes a bool int z = enforceEx!Exception(returnValid() != -1); assert(z == 5); // now this fails } ----- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
