digitalmars.D - Template specialisations and 'alias'
- Cabal (27/27) Jul 14 2004 The following code gives an error when trying to implement specialisatio...
- Cabal (3/3) Jul 14 2004 Come on guys n gals!
- Bent Rasmussen (10/10) Jul 15 2004 I'd post this as a bug, the case can be simplified even further
- Cabal (5/19) Jul 15 2004 Thanks Bent, I was beginning to wonder if anyone else was using template...
- Bent Rasmussen (3/7) Jul 15 2004 Well now I do, since I was wrong. :-)
The following code gives an error when trying to implement specialisation *** template instance SpecTest!(Dummy ,0) matches more than one template declaration ,----[ ] | | template SpecTest(alias T, int n) { | alias T X; | } | | template SpecTest(alias T, int n :0) { | alias T X; | } | | class Dummy {} | | void main() { | alias SpecTest!(Dummy, 0).X Y; | } | `---- If I remove the 'alias' keywords and substitute the Dummy class for 'int', it all compiles. Any ideas why this should be? Also, using 'alias' prevents using 'int' (and I presume other primitive types) as parameters to those templates. Is this intentional? The why's and wherefore's of using 'alias' in template parameter lists is not well defined. Cabal.
Jul 14 2004
Come on guys n gals! Someone must be using templates and specialisation. One of you must have a clue.
Jul 14 2004
I'd post this as a bug, the case can be simplified even further template Test(alias T, int n : 0) {} alias Test!(bit,0) x; The specification states "Alias parameters enable templates to be parameterized with any type of D symbol, including global names, type names, module names, template names, and template instance names." The test works if T is not an alias parameter and yet the description says that type names are valid arguments to alias parameters so I don't know what else to make of this, other than it is a bug.
Jul 15 2004
Thanks Bent, I was beginning to wonder if anyone else was using templates at all. Your test highlights my second query regarding primitive types not being able match alias parameters. If you don't mind I'll report 2 separate bugs with your example being one of them. Bent Rasmussen wrote:I'd post this as a bug, the case can be simplified even further template Test(alias T, int n : 0) {} alias Test!(bit,0) x; The specification states "Alias parameters enable templates to be parameterized with any type of D symbol, including global names, type names, module names, template names, and template instance names." The test works if T is not an alias parameter and yet the description says that type names are valid arguments to alias parameters so I don't know what else to make of this, other than it is a bug.
Jul 15 2004
Thanks Bent, I was beginning to wonder if anyone else was using templatesatall. Your test highlights my second query regarding primitive types not being able match alias parameters. If you don't mind I'll report 2separatebugs with your example being one of them.Well now I do, since I was wrong. :-)
Jul 15 2004