Foo!("a").????? == `Foo!("a")`

Bill Baxter wbaxter at gmail.com
Sat Dec 5 21:50:22 PST 2009


On Sat, Dec 5, 2009 at 5:36 PM, Nick Sabalausky <a at a.a> wrote:
> I don't suppose there's an easy general way to get the paramaters of a
> templated type just from the type itself? Ie, a way to get around this:
>
> class Foo(char[] str) {}
> static assert(Foo!("a").stringof != Foo!("b").stringof)
> // ^ fails because it evaluates to "Foo" != "Foo"
>
> I can probably work around it in my current case by sticking str into a
> const member of Foo and using that together with .stringof, but thought I'd
> see if there was a better way.

That should just be considered a bug I think.  I think what stringof
does is not detailed in the spec beyond "provides a string
representation".  Clearly just returning the base name of the template
is not the most useful representation of a template type.  Stringof
clearly needs to have more thought put into it (as has been brought up
many times in the past).

--bb


More information about the Digitalmars-d-learn mailing list