digitalmars.D - Unqual doesn't remove qualifiers from pointers
- John Chapman (5/5) Nov 20 2018 Is std.traits.Unqual supposed to work on pointers?
- Stanislav Blinov (6/12) Nov 20 2018 It does work on pointers:
- Eugene Wissner (5/11) Nov 20 2018 Unqual removes qualifies only from the pointer itself, not the
- John Colvin (12/18) Nov 20 2018 No. Unqual only strips from a type, not from any other types
Is std.traits.Unqual supposed to work on pointers? const int x; static assert(Unqual!(typeof(&x)) == int*); Compiler says: static assert: `is(const(int)* == int*)` is false If it's a bug I'll report it.
Nov 20 2018
On Tuesday, 20 November 2018 at 17:44:02 UTC, John Chapman wrote:Is std.traits.Unqual supposed to work on pointers? const int x; static assert(Unqual!(typeof(&x)) == int*); Compiler says: static assert: `is(const(int)* == int*)` is false If it's a bug I'll report it.It does work on pointers: static assert(is(Unqual!(const(int*)) == const(int)*)); Technically there's nothing to Unqual from that typeof(&x): it's already a const(int)*, i.e. a mutable pointer. But it'd be nice to have some "strip'em all" equivalent.
Nov 20 2018
On Tuesday, 20 November 2018 at 17:44:02 UTC, John Chapman wrote:Is std.traits.Unqual supposed to work on pointers? const int x; static assert(Unqual!(typeof(&x)) == int*); Compiler says: static assert: `is(const(int)* == int*)` is false If it's a bug I'll report it.Unqual removes qualifies only from the pointer itself, not the type pointed by it. It is not a bug. You can use PointerTarget with Unqual to remove the qualifiers from the target type: static assert(is(Unqual!(PointerTarget!(typeof(&x)))* == int*));
Nov 20 2018
On Tuesday, 20 November 2018 at 17:44:02 UTC, John Chapman wrote:Is std.traits.Unqual supposed to work on pointers? const int x; static assert(Unqual!(typeof(&x)) == int*); Compiler says: static assert: `is(const(int)* == int*)` is false If it's a bug I'll report it.No. Unqual only strips from a type, not from any other types contained in that type. I.e. Unqual!string == string Unqual!const(int*) == const(int)* Unqual!const(int)* == const(int)* struct S { const int a; } typeof(Unqual!(const(S)).a) == const int typeof(Unqual!(S.a) == const int Please make a bug report to improve the documentation (and PR as well if you like :) )
Nov 20 2018