digitalmars.D.learn - Template Tuple Defaults
- Peter Neubauer (13/13) Mar 29 2008 Is there a way to give default types to template tuple parameters?
- Simen Kjaeraas (13/26) Mar 30 2008 This oughtta work (does on my confuser).
- Peter Neubauer (9/49) Mar 30 2008 Strange, all I get is this:
- Simen Kjaeraas (9/51) Mar 30 2008 Tested it again. Appears I did get part of it wrong.
Is there a way to give default types to template tuple parameters? Like this: class Test (TTuple ... = [char, int] ) { // ... } void main () { Test t; // Equivalent to Test !(char, int) t; } Obviously, that does not compile. Thanks in advance, -Peter
Mar 29 2008
On Sun, 30 Mar 2008 06:06:00 +0200, Peter Neubauer = <peterneubauer2 gmail.com> wrote:Is there a way to give default types to template tuple parameters? Like this: class Test (TTuple ... =3D [char, int] ) { // ... } void main () { Test t; // Equivalent to Test !(char, int) t; } Obviously, that does not compile. Thanks in advance, -PeterThis oughtta work (does on my confuser). import std.typetuple; class Test (TTuple ... =3D TypeTuple!(char, int) ) { // ... } void main () { Test t; // Equivalent to Test !(char, int) t; } -- Simen
Mar 30 2008
Simen Kjaeraas schrieb:On Sun, 30 Mar 2008 06:06:00 +0200, Peter Neubauer <peterneubauer2 gmail.com> wrote:Strange, all I get is this: test.d(3): found '=' when expecting ')' test.d(3): { } expected following aggregate declaration test.d(3): no identifier for declarator TypeTuple!(char,int) test.d(3): semicolon expected, not ')' test.d(3): Declaration expected, not ')' Maybe this is a difference between D 1.0 and 2.0? (I'm using 1.0) -PeterIs there a way to give default types to template tuple parameters? Like this: class Test (TTuple ... = [char, int] ) { // ... } void main () { Test t; // Equivalent to Test !(char, int) t; } Obviously, that does not compile. Thanks in advance, -PeterThis oughtta work (does on my confuser). import std.typetuple; class Test (TTuple ... = TypeTuple!(char, int) ) { // ... } void main () { Test t; // Equivalent to Test !(char, int) t; } -- Simen
Mar 30 2008
On Mon, 31 Mar 2008 01:29:10 +0200, Peter Neubauer = <peterneubauer2 gmail.com> wrote:Simen Kjaeraas schrieb:On Sun, 30 Mar 2008 06:06:00 +0200, Peter Neubauer =Tested it again. Appears I did get part of it wrong. class test(TTuple =3D TypeTuple!(char, int)) That works. Without the ellipsis. However, that is of course not what yo= u = wanted. I do agree it should, though. --Simen<peterneubauer2 gmail.com> wrote:Strange, all I get is this: test.d(3): found '=3D' when expecting ')' test.d(3): { } expected following aggregate declaration test.d(3): no identifier for declarator TypeTuple!(char,int) test.d(3): semicolon expected, not ')' test.d(3): Declaration expected, not ')' Maybe this is a difference between D 1.0 and 2.0? (I'm using 1.0) -PeterIs there a way to give default types to template tuple parameters? Like this: class Test (TTuple ... =3D [char, int] ) { // ... } void main () { Test t; // Equivalent to Test !(char, int) t; } Obviously, that does not compile. Thanks in advance, -PeterThis oughtta work (does on my confuser). import std.typetuple; class Test (TTuple ... =3D TypeTuple!(char, int) ) { // ... } void main () { Test t; // Equivalent to Test !(char, int) t; } -- Simen
Mar 30 2008