Bug 1463 – __traits: indexed template parsed as type, not value
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-08-31T09:54:00Z
Last change time
2015-06-09T01:14:14Z
Keywords
rejects-valid
Assigned to
nobody
Creator
reiner.pope
Comments
Comment #0 by reiner.pope — 2007-08-31T09:54:01Z
The following code fails to compile, with error "GetMembers!() is used as a type". Replacing the instance of i with 0 fixes it.
template GetMembers()
{
const string[] GetMembers = ["hello", "bye"];
}
const i = 0;
class Foo
{
void hello() {}
}
const f = __traits( getVirtualFunctions, Foo, GetMembers!()[i] ).length;
Comment #1 by htvennik — 2008-02-20T15:46:20Z
writing GetMembers!()[(i)] seems to fix it too. I currently use that as a work-around.