Re: How to check if string is available at compile time

2017-09-22 Thread B4s1L3 via Digitalmars-d-learn
On Thursday, 21 September 2017 at 11:42:36 UTC, David Bennett wrote: Hi Guys, Is there an easy way to check if the value of string passed to a template is available at compile time? Yeah , sure and I have such a template in my library: https://github.com/BBasile/iz/blob/master/import/iz/ty

Re: How to check if string is available at compile time

2017-09-21 Thread David Bennett via Digitalmars-d-learn
On Thursday, 21 September 2017 at 13:52:25 UTC, Meta wrote: On Thursday, 21 September 2017 at 12:30:15 UTC, David Bennett wrote: On Thursday, 21 September 2017 at 11:42:36 UTC, David Bennett wrote: enum isCTstring(alias arg) = (!isAssignable!(typeof(arg)) || __traits(compiles, mixin(` "foo" ~

Re: How to check if string is available at compile time

2017-09-21 Thread Meta via Digitalmars-d-learn
On Thursday, 21 September 2017 at 12:30:15 UTC, David Bennett wrote: On Thursday, 21 September 2017 at 11:42:36 UTC, David Bennett wrote: [snip] ``` string[] escapeCTFE(Args...)(){ static foreach (arg; Args){ static if(__traits(compiles, ###WHATDOIPUTHERE###)){ [snip] So far the

Re: How to check if string is available at compile time

2017-09-21 Thread David Bennett via Digitalmars-d-learn
On Thursday, 21 September 2017 at 11:42:36 UTC, David Bennett wrote: [snip] ``` string[] escapeCTFE(Args...)(){ static foreach (arg; Args){ static if(__traits(compiles, ###WHATDOIPUTHERE###)){ [snip] So far the best I've come up with is : ``` enum isCTstring(alias arg) = (!isAs

How to check if string is available at compile time

2017-09-21 Thread David Bennett via Digitalmars-d-learn
Hi Guys, Is there an easy way to check if the value of string passed to a template is available at compile time? Here is a cut down example of that I'm doing: ``` string[] escapeCTFE(Args...)(){ static foreach (arg; Args){ static if(__traits(compiles, ###WHATDOIPUTHERE###)){