Bug 18303 – Unqual gives weird results for const types
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-26T13:58:04Z
Last change time
2020-03-21T03:56:38Z
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2018-01-26T13:58:04Z
When a type T is declared as const, Unqual!T is not T, or perhaps more correctly, T is not T, but const(T). Confusing enough yet? Have a look-see:
import std.traits : Unqual;
const struct T { }
pragma(msg, T); // const(T)
pragma(msg, Unqual!T); // T
static assert(!is(T == Unqual!T));
Comment #1 by b2.temp — 2018-05-18T18:53:31Z
I don't see any issue here because
static assert(is(T == const) && !is(T == Unqual!T));
is perfectly logic.