digitalmars.D.learn - Weird template error in Phobos (after editing) that I can't quite get.
- Atila Neves (34/34) Mar 22 2017 isInputRange looks like this:
- Atila Neves (6/19) Mar 22 2017 Got the same error when I changed it to:
isInputRange looks like this: template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if (r.empty) {} // can test for empty r.popFront; // can invoke popFront() auto h = r.front; // can get the front of the range })); } If I change the `enum bool` line to `enum bool isInputRange = true && is(typeof(`, all is fine. If instead I: enum foo = true; enum bool isInputRange = foo && is(typeof( Then: std/range/primitives.d(352): Error: static assert "Cannot put a char[] into a Appender!string." std/format.d(1877): instantiated from here: put!(Appender!string, char[]) std/format.d(1784): instantiated from here: formatUnsigned!(Appender!string, ulong, char) std/format.d(1755): instantiated from here: formatIntegral!(Appender!string, ulong, char) std/format.d(3778): ... (3 instantiations, -v to show) ... std/typecons.d(421): instantiated from here: format!(char, ulong, ulong) std/encoding.d(3468): instantiated from here: Tuple!(BOM, "schema", ubyte[], "sequence") Surely they should be identical? Obviously I was trying to do something else with an enum, but this is the reduced sample. Atila
Mar 22 2017
On Wednesday, 22 March 2017 at 14:06:56 UTC, Atila Neves wrote:isInputRange looks like this: template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if (r.empty) {} // can test for empty r.popFront; // can invoke popFront() auto h = r.front; // can get the front of the range })); } [...]Got the same error when I changed it to: enum isInputRange(R) = is(typeof({...})); Which might explain why it's still inside an explicit template declaration. Or not, this whole thing is weird to me. Atila
Mar 22 2017