digitalmars.D.learn - How to Unqual an array?
- James Blachly (8/8) Nov 16 2019 I am trying to write templated code that will take a character array --
- James Blachly (3/5) Nov 16 2019 I am aware of isSomeString, but I am still curious about Unqual array
- Anonymouse (5/10) Nov 16 2019 https://pastebin.com/f2FUAYQT is what I use, assuming I
- Steven Schveighoffer (8/14) Nov 16 2019 Unqual for the most port unqualifies the *head* of the type. This only
- James Blachly (6/14) Nov 17 2019 Thank you both Steve and Anonymouse!
I am trying to write templated code that will take a character array -- mutable, const, or immutable (string). static assert(is(Unqual!(const char) == char)); (Succeeds) static assert(is(Unqual!(const(char)[]) == char[])); Error: static assert: `is(const(char)[] == char[])` is false Is the template trying to strip the qualifier from the [] rather than the char?
Nov 16 2019
On 11/16/19 9:48 AM, James Blachly wrote:I am trying to write templated code that will take a character array -- mutable, const, or immutable (string).I am aware of isSomeString, but I am still curious about Unqual array from a learning perspective.
Nov 16 2019
On Saturday, 16 November 2019 at 15:20:26 UTC, James Blachly wrote:On 11/16/19 9:48 AM, James Blachly wrote:https://pastebin.com/f2FUAYQT is what I use, assuming I understand what you want. (run.dlang.io shortening seems to be down.)I am trying to write templated code that will take a character array -- mutable, const, or immutable (string).I am aware of isSomeString, but I am still curious about Unqual array from a learning perspective.
Nov 16 2019
On 11/16/19 10:20 AM, James Blachly wrote:On 11/16/19 9:48 AM, James Blachly wrote:Unqual for the most port unqualifies the *head* of the type. This only makes a difference in terms of pointers and arrays (where the tail can be qualified separately from the head). For all other types, the whole thing has it's qualifiers removed. This is not explicitly stated in the docs, and it may be an accidental result, but it's too late to change it now. It can be useful in some cases. -SteveI am trying to write templated code that will take a character array -- mutable, const, or immutable (string).I am aware of isSomeString, but I am still curious about Unqual array from a learning perspective.
Nov 16 2019
On 11/16/19 10:20 AM, James Blachly wrote:On 11/16/19 9:48 AM, James Blachly wrote:Thank you both Steve and Anonymouse! Regarding Steve's comment -- this should be made clear in documentation no? Regarding Anonymouse's code snippet, I've definitely saved that for future. thank you. JamesI am trying to write templated code that will take a character array -- mutable, const, or immutable (string).I am aware of isSomeString, but I am still curious about Unqual array from a learning perspective.
Nov 17 2019