digitalmars.D.learn - I just discovered an alternative use of the `in`-operator
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (9/9) Aug 06 2020 I just discovered that the is-operator can be used as in
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/5) Aug 06 2020 Doh, title should of course be
- Paul Backus (3/15) Aug 06 2020 [1] https://dlang.org/spec/expression.html#is_expression
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/3) Aug 07 2020 Thanks
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/4) Aug 07 2020 I bet there a several places in Phobos where this feature isn't
- aberba (3/7) Aug 07 2020 I feel same. That there's a clever use of certain D features
- H. S. Teoh (6/11) Aug 07 2020 Perhaps. But as I recall, it's widely used throughout Phobos, so it
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/3) Aug 09 2020 Thanks
I just discovered that the is-operator can be used as in template ElementType(R) { static if (is(typeof(R.init.front.init) T)) alias ElementType = T; else alias ElementType = void; } . Very powerful. Is this documented?
Aug 06 2020
On Thursday, 6 August 2020 at 21:50:06 UTC, Per Nordlöw wrote:I just discovered that the is-operator can be used as in ...Doh, title should of course be I just discovered an alternative use of `is`-expressions.
Aug 06 2020
On Thursday, 6 August 2020 at 21:50:06 UTC, Per Nordlöw wrote:I just discovered that the is-operator can be used as in template ElementType(R) { static if (is(typeof(R.init.front.init) T)) alias ElementType = T; else alias ElementType = void; } . Very powerful. Is this documented?Yes, in the following paragraph under "IsExpression" [1]:Identifier is declared to be an alias of the resulting type if the condition is satisfied. The Identifier forms can only be used if the IsExpression appears in a StaticIfCondition.[1] https://dlang.org/spec/expression.html#is_expression
Aug 06 2020
On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:[1] https://dlang.org/spec/expression.html#is_expressionThanks
Aug 07 2020
On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:[1] https://dlang.org/spec/expression.html#is_expressionI bet there a several places in Phobos where this feature isn't but could be used.
Aug 07 2020
On Friday, 7 August 2020 at 21:02:03 UTC, Per Nordlöw wrote:On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:I feel same. That there's a clever use of certain D features waiting to be discovered.[1] https://dlang.org/spec/expression.html#is_expressionI bet there a several places in Phobos where this feature isn't but could be used.
Aug 07 2020
On Fri, Aug 07, 2020 at 09:02:03PM +0000, Per Nordlöw via Digitalmars-d-learn wrote:On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:Perhaps. But as I recall, it's widely used throughout Phobos, so it probably won't be easy to find a place where it could be used but isn't. T -- Written on the window of a clothing store: No shirt, no shoes, no service.[1] https://dlang.org/spec/expression.html#is_expressionI bet there a several places in Phobos where this feature isn't but could be used.
Aug 07 2020
On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:[1] https://dlang.org/spec/expression.html#is_expressionThanks
Aug 09 2020