parse

The parse family of functions works quite like the to family, except that:

  1. It only works with character ranges as input.
  2. It takes the input by reference. (This means that rvalues - such as string literals - are not accepted: use to instead.)
  3. It advances the input to the position following the conversion.
  4. It does not throw if it could not convert the entire input.

This overload converts a character input range to a bool.

Parameters

Target

the type to convert to

source Source

the lvalue of an input range

Return Value

Type: Target

A bool

Throws

A ConvException if the range does not represent a bool.

Note: All character input range conversions using to are forwarded to parse and do not require lvalues.

Examples

auto s = "true";
bool b = parse!bool(s);
assert(b);

Meta

Suggestion Box / Bug Report