How to pass an InputRange of dchars to a function that wants an Input range of chars?
monkyyy
crazymonkyyy at gmail.com
Thu Feb 20 03:05:55 UTC 2025
On Wednesday, 19 February 2025 at 20:46:24 UTC, realhet wrote:
> On Wednesday, 19 February 2025 at 19:08:07 UTC, bauss wrote:
>> On Wednesday, 19 February 2025 at 18:13:24 UTC, realhet wrote:
>>>
>>> ...
>>>
>>
>> std.conv.to can convert for you.
>
> Thx!
>
> I tried .map!(to!dchar) instead of .byChar and it still failed.
>
> But then I deleted the constraints where I detect if the
> parameter is an input range of a char, and it suddenly worked.
>
> So this
> ```
> if(isInputRange!(R, immutable char))
> ```
> wont let through obvious ranges that are input ranges and
> contain chars...
>
> Anyone have a clue why?
>
> What constraint should I use then?
import std;
auto fixstring(string s)=>(cast(ubyte[])s).map!(a=>cast(char)a);
void main(){
"hello
world".fixstring.map!(a=>std.ascii.toUpper(a)).each!write;
}
More information about the Digitalmars-d-learn
mailing list