digitalmars.D.bugs - Alias template parameters do not allow plain old data types
- Cabal (18/18) Jul 15 2004 You cannot specify a primitive data type for a template parameter which ...
- Andrew Edwards (18/40) Jul 15 2004 That's not a bug, just improper usage.
- Cabal (5/26) Jul 16 2004 The spec states 'type names'. 'int' is a type name - afaiks there is not...
- Bent Rasmussen (18/44) Jul 16 2004 The spec. example that proves this interpretation correct:
- Walter (7/11) Jul 20 2004 nothing
You cannot specify a primitive data type for a template parameter which is defined as an alias. Thanks to Bent Rasmussen for the simplified example case and reference to the D spec. I cut down Bent's simplified version even more. Error at the bottom. Spec: "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." Test: ,----[ ] | | template Test(alias T) {} | alias Test!(bit) x; | `---- Error: template instance Test!(int) does not match any template declaration
Jul 15 2004
Cabal wrote:You cannot specify a primitive data type for a template parameter which is defined as an alias. Thanks to Bent Rasmussen for the simplified example case and reference to the D spec. I cut down Bent's simplified version even more. Error at the bottom. Spec: "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." Test: ,----[ ] | | template Test(alias T) {} | alias Test!(bit) x; | `---- Error: template instance Test!(int) does not match any template declarationThat's not a bug, just improper usage. should be: ,----[ ] | | template Test(alias T) {} | int x; // variable can be of any type (structs and classes included) | alias Test!(x) aint; | `---- or: ,----[ ] | | template Test(T) {} | alias Test!(int) x; | `---- Andrew
Jul 15 2004
The spec states 'type names'. 'int' is a type name - afaiks there is nothing that specifies the the parameter must be an instance of a type for alias to work as you have said. Class and template type name specifiers work just fine with alias parameters - only primitive type typenames fail. Andrew Edwards wrote:That's not a bug, just improper usage. should be: ,----[ ] | | template Test(alias T) {} | int x; // variable can be of any type (structs and classes included) | alias Test!(x) aint; | `---- or: ,----[ ] | | template Test(T) {} | alias Test!(int) x; | `---- Andrew
Jul 16 2004
The spec states 'type names'. 'int' is a type name - afaiks there isnothingthat specifies the the parameter must be an instance of a type for aliastowork as you have said. Class and template type name specifiers work just fine with alias parameters - only primitive type typenames fail.The spec. example that proves this interpretation correct: class Foo { static int p; } template Bar(alias T) { alias T.p q; } void test() { alias Bar!(Foo) bar; bar.q = 3; // sets Foo.p to 3 } I thought I had misinterpreted that first paragraph in the alias section of the spec.Andrew Edwards wrote:That's not a bug, just improper usage. should be: ,----[ ] | | template Test(alias T) {} | int x; // variable can be of any type (structs and classes included) | alias Test!(x) aint; | `---- or: ,----[ ] | | template Test(T) {} | alias Test!(int) x; | `---- Andrew
Jul 16 2004
"Cabal" <cabalN05P4M myrealbox.com> wrote in message news:cd83h9$31fl$1 digitaldaemon.com...The spec states 'type names'. 'int' is a type name - afaiks there isnothingthat specifies the the parameter must be an instance of a type for aliastowork as you have said. Class and template type name specifiers work just fine with alias parameters - only primitive type typenames fail.Sorry for the confusion. 'bit' is not a type name, but a keyword. A type name would be a typedef'd name, an alias name for a type, a class name, a struct name, etc.
Jul 20 2004