| |
 | Posted by d-bugmail | Permalink Reply |
|
d-bugmail 
| http://d.puremagic.com/issues/show_bug.cgi?id=1303
Summary: ParameterTypeTuple asserts false on parameterless
function
Product: D
Version: 2.000
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: patch
Severity: normal
Priority: P4
Component: Phobos
AssignedTo: bugzilla@digitalmars.com
ReportedBy: dhasenan@gmail.com
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;
}
--
|