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

--- Comment #2 from Vijay Nayar <[email protected]> ---
That makes sense for character processing. Perhaps my understanding of what
.front() and .popFront() do is incorrect then. I had assumed that they were
general purpose range methods that could also be used on arrays to treat them
like ranges as well.

In this particular case, I was implementing a DenseHashSet algorithm, optimized
for low memory overhead, when during my unittests, I discovered that they were
failing when I made a set of characters. The reason was that my template code
was using .front() to manage an internal array.

That may be the dilemma. What does the user have in mind when they use 'char'?
Is it strictly for unicode text processing, or is it piece of data with a well
defined size? Is it incumbent upon those who use templates to not use 'char'
for data in templates (and type-cast bytes), or is it incumbent upon template
writers to always consider this special case?

Or is this just the wrong usage of .front(), and array indexing, like data[0],
should be preferred?

--

Reply via email to