parse

Parses one character from a character range.

Parameters

Target

the type to convert to

s Source

the lvalue of an input range

doCount

the flag for deciding to report the number of consumed characters

Return Value

Type: auto
  • A character of type Target if doCount is set to No.doCount
  • A tuple containing a character of type Target and a size_t if doCount is set to Yes.doCount

Throws

A ConvException if the range is empty.

Examples

import std.typecons : Flag, Yes, No;
auto s = "Hello, World!";
char first = parse!char(s);
assert(first == 'H');
assert(s == "ello, World!");
char second = parse!(char, string, No.doCount)(s);
assert(second == 'e');
assert(s == "llo, World!");
auto third = parse!(char, string, Yes.doCount)(s);
assert(third.data == 'l' && third.count == 1);
assert(s == "lo, World!");

Meta