Re: Can't use is expression on nested type

2025-03-13 Thread Ali Çehreli via Digitalmars-d-learn
On 3/13/25 5:14 PM, Emma wrote: > but the below fails with a “undefined identifier 'S'” error! [...] > bool foo(T)(T it) { > static if (is(T == X.Foo!S, string S)) { Here is another solution that uses std.traits: import std.traits; struct X { struct Foo(string S) {} } bool foo(T)(T i

Re: Can't use is expression on nested type

2025-03-13 Thread monkyyy via Digitalmars-d-learn
On Friday, 14 March 2025 at 00:14:35 UTC, Emma wrote: Hello, I was doing some template nonsense and came across this weird issue. This compiles fine: ```d struct Foo(string S) {} bool foo(T)(T it) { static if (is(T == Foo!S, string S)) { return true; } else { return fal

Can't use is expression on nested type

2025-03-13 Thread Emma via Digitalmars-d-learn
Hello, I was doing some template nonsense and came across this weird issue. This compiles fine: ```d struct Foo(string S) {} bool foo(T)(T it) { static if (is(T == Foo!S, string S)) { return true; } else { return false; } } void main() { foo(Foo!"x"()); } ``` b

Re: Can somebody give me an example of using an "open interval for the upper limit of a range"?

2025-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 12, 2025 12:07:04 PM MDT Manfred Nowak via Digitalmars-d-learn wrote: > On Tuesday, 11 March 2025 at 16:56:28 UTC, WhatMeWorry wrote: > [...] > > To include the upper bound value, use a square bracket "]" at > > the end of the range." > > [...] > > foreach( i, e; a[0..3] ) > >