Open Orvid opened 10 years ago
So.. Type induction? I kinda thought about this earlier, but yeah, I guess this should be realizable. In..some ways I don't even know yet :D
yep :D
I guess this simply can't be induced in any way and thus must be hardcoded or so:
template isOutputRange(R, E)
{
enum bool isOutputRange = is(typeof(
(inout int = 0)
{
R r = R.init;
E e = E.init;
put(r, e);
}));
}
Really gotta wonder why they all won't use normal OOP to make their lifes easier...
Gosh, editing std.range sucks..but which benefits coming from an IDE are there anyway for handcrafted code like this.
The feature I'm suggesting isn't intended for editing code that defines a range; rather, it's for code that uses ranges either as input or output to the function.
Hold on, I've got a better idea: I won't deduce isOutputRange!... but only resolve the primary symbol isOutputRange. Then I look around for symbol definitions that have isOutputRange in their constraints as well, so I could build up an artificial type declaration.
Yep, that would be perfect.
To reduce the amount of hard-coding required, it should be possible to extract the information you need by parsing std.range.dummyRanges and instantiating it for the particular uses.
It would be nice if with the following code,
wtr
was typed such that it had the members expected of an output range ofchar
s:This would make writing range-based code much easier.