the type to convert to
the lvalue of an input range
the flag for deciding to report the number of consumed characters
A ConvException if the range doesn't represent null.
import std.exception : assertThrown; import std.typecons : Flag, Yes, No; alias NullType = typeof(null); auto s1 = "null"; assert(parse!NullType(s1) is null); assert(s1 == ""); auto s2 = "NUll"d; assert(parse!NullType(s2) is null); assert(s2 == ""); auto s3 = "nuLlNULl"; assert(parse!(NullType, string, No.doCount)(s3) is null); auto r = parse!(NullType, string, Yes.doCount)(s3); assert(r.data is null && r.count == 4); auto m = "maybe"; assertThrown!ConvException(parse!NullType(m)); assertThrown!ConvException(parse!(NullType, string, Yes.doCount)(m)); assert(m == "maybe"); // m shouldn't change on failure auto s = "NULL"; assert(parse!(const NullType)(s) is null);
Parses typeof(null) from a character range if the range spells "null". This function is case insensitive.