ParameterTypeTuple should return an empty TypeTuple for parameterless functions.
Why would this not cause problems with existing code? Well, assert(false) always immediately stops compilation. Nobody can possibly use ParameterTypeTuple on a parameterless function, not even to check if it's void, unless they mean to do so manually, in which case they might as well crack open the code in a text editor and check.
However, all the invalid cases, such as:
---
void foo() {}
ParameterTypeTuple!(foo)[0] x;
---
These are still caught at compile time with a relevant warning.
Note that library writers currently have to duplicate the template in order to provide this basic functionality. Also note that this behavior is undocumented.
Patch:
--- traits.d 2007-07-01 08:50:00.000000000 -0400
+++ traits.d 2007-07-01 08:31:34.000000000 -0400
@@ -18,6 +18,7 @@
*/
module std.traits;
+private import std.typetuple;
/***
* Get the type of the return value from a function,
@@ -69,7 +70,7 @@
else static if (is(dg P == P*))
alias ParameterTypeTuple!(P) ParameterTypeTuple;
else
- static assert(false, "parameter required");
+ alias TypeTuple!() ParameterTypeTuple;
}
Comment #1 by dhasenan — 2007-07-01T08:01:18Z
Created attachment 149
lets ParameterTypeTuple handle parameterless funcs
Botched the in-text patch (linebreak issue); this should work.
Comment #2 by bugzilla — 2008-12-09T16:47:46Z
This seems to work fine on parameterless functions.