www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why does this not pass

reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
Why does all these pass:
     static assert(is(ElementEncodingType!(char[]) == char));
     static assert(is(ElementEncodingType!(wstring) == 
immutable(wchar)));
     static assert(is(ElementEncodingType!(byte[]) == byte));
     static assert(is(ElementEncodingType!(ubyte[]) == ubyte));

     auto range = iota(0, 10);
     static assert(is(ElementEncodingType!(typeof(range)) == int));
     static assert(is(ElementEncodingType!(immutable(ubyte)[]) == 
immutable(ubyte)));

But not this:
     static assert(is(ElementEncodingType!(AsciiChar[]) == 
AsciiChar));
Feb 23 2021
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Tuesday, 23 February 2021 at 09:21:44 UTC, Imperatorn wrote:
 Why does all these pass:
     static assert(is(ElementEncodingType!(char[]) == char));
     static assert(is(ElementEncodingType!(wstring) == 
 immutable(wchar)));
     static assert(is(ElementEncodingType!(byte[]) == byte));
     static assert(is(ElementEncodingType!(ubyte[]) == ubyte));

     auto range = iota(0, 10);
     static assert(is(ElementEncodingType!(typeof(range)) == 
 int));
     static assert(is(ElementEncodingType!(immutable(ubyte)[]) 
 == immutable(ubyte)));

 But not this:
     static assert(is(ElementEncodingType!(AsciiChar[]) == 
 AsciiChar));
omg forgot to import std.range 🙄 But the question is kinda still valid, like in the case of std.array.appender. The original poster: "Appender defines its element type with ElementEncodingType which only passes immutability through for built-in string types"
Feb 23 2021