require

Similar to enforce, except it can take a formatting string as the second argument. Note: Until Issue 8687 is fixed, file and line have to be compile-time arguments, which might create template bloat.

T
require
(
string file = __FILE__
size_t line = __LINE__
T
Args...
)
(,
Args args
)

Examples

require(1 == 2).getExceptionMsg.assertEqual("requirement failed.");
require(1 == 2, "%s is not true").getExceptionMsg.assertEqual("%s is not true");
require(1 == 2, "%s is not true", "1 == 2").getExceptionMsg.assertEqual("1 == 2 is not true");

Meta