[Issue 19518] std.range.front() returns a dchar when applied to char[]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 14 09:54:39 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19518

--- Comment #6 from Vijay Nayar <madric at gmail.com> ---
I think the tricky case is not so much when one begins and ends thinking of
character processing, but when one is writing a generic algorithm using
templates that makes use of std.range.front.

A template that takes a range type and an element and works with them will
function fine in most cases for most types when they make use of ".front()" in
their algorithms.

But as it stands right now, if anyone attempts to use said template with a
`char` type, the template will no longer compile, because '.front()' returns a
different element type than the range.

This means that either '.front()' shouldn't be used in generic algorithms that
need to pull an element out of the range, in favor or something like '[0]', or
it means that algorithm writers need to make `char` a special case in any
algorithm they write.

I don't actually have a good answer for what approach is best.

--


More information about the Digitalmars-d-bugs mailing list