On Wed, Feb 22, 2017 at 11:43:00AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > import std.range.primitives; > > bool isAsciiOnly(R)(R input) > if (isInputRange!R && is(ElementType!R : dchar)) > { > import std.algorithm.iteration : fold; > return input.fold!((a, b) => a && b < 0x80)(true); > } > > unittest > { > assert(isAsciiOnly("abcdefg")); > assert(!isAsciiOnly("abcбвг")); > } [...]
Ah, missing the Exception part: void foo(string input) { if (!input.isAsciiOnly) throw new Exception("..."); } T -- Why are you blatanly misspelling "blatant"? -- Branden Robinson