endsWith() doesn't work with const(wchar[])s

%u wfunction at hotmail.com
Thu Jan 13 23:21:03 PST 2011


> Regardless, a fully const array is never going to work with a function like
endsWith() for the simple reason that such functions have to actually be able to
process the range that they're given, and if the range is const, you can't call
popFront() or popBack() on it, so it just isn't going to work.
> Now, if you take a _slice_ of a const array, it should work, because while the
elements of the array will remain const, the slice itself won't be, so endsWith()
can process it.

I see what's happening, but the problem with slicing is that it doesn't prevent a
resize of the array, which, if not allocated with GC memory, could break code. How
can you have a non-resizeable slice, while still maintaining the constness of an
array? Is that even possible?

Thank you!


More information about the Digitalmars-d mailing list