← Back to index
|
Original Bugzilla link
Bug 18302 – Add std.traits.Noqual
Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2018-01-26T13:54:21Z
Last change time
2024-12-01T16:32:13Z
Assigned to
No Owner
Creator
Simen Kjaeraas
Moved to GitHub: phobos#10298 →
Comments
Comment #0
by simen.kjaras — 2018-01-26T13:54:21Z
As pointed out in bug 8338, Unqual only removes top-level qualifiers, leaving Unqual!(const(int*)) as const(int)*. A desire has been expressed for a template that does what Unqual does, but recursively applying itself to element- and pointed-to types. POC: template Noqual(T, size_t levels = size_t.max) { static if (levels == 0) { alias Noqual = T; } else static if (is(T == U[], U)) { alias Noqual = Noqual!(U, levels-1)[]; } else static if (is(T == U[N], U, size_t N)) { alias Noqual = Noqual!(U, levels-1)[N]; } else static if (is(T == U[K], U, K)) { alias Noqual = Noqual!(U, levels-1)[Noqual!(K, levels-1)]; } else static if (is(T == U*, U)) { alias Noqual = Noqual!(U, levels-1)*; } else { alias Noqual = Unqual!T; } } unittest { assert(is(Noqual!(const(int*)) == int*)); assert(is(Noqual!(const(int****)) == int****)); assert(is(Noqual!(const(int****), 2) == const(int**)**)); assert(is(Noqual!(const(int[int])) == int[int])); assert(is(Noqual!(const(int[int])*) == int[int]*)); assert(is(Noqual!(const(int[const(int*)])*, 2) == const(int)[const(int)*]*)); assert(is(Noqual!(const(int[3])) == int[3])); }
Comment #1
by robert.schadek — 2024-12-01T16:32:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/phobos/issues/10298
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB