Bug 2512 – ParameterTypeTuple do not support opCall

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2008-12-13T13:54:00Z
Last change time
2015-06-09T01:20:45Z
Assigned to
nobody
Creator
rayerd.wiz

Attachments

IDFilenameSummaryContent-TypeSize
282patch.std.traits.dmd2021.txtpatch for ParameterTypeTupletext/plain488

Comments

Comment #0 by rayerd.wiz — 2008-12-13T13:54:24Z
The std.traits.ParameterTypeTuple do not support a class object/type and a struct object/type within opCall. The ParameterTypeTuple is recommended to be changed like this. >>>>>>>>>>>>>>>>>>>>>> --- traits.d Tue Nov 25 00:24:50 2008 +++ traits.d.new Sun Dec 14 04:28:31 2008 @@ -93,7 +93,12 @@ */ template ParameterTypeTuple(alias dg) { - alias ParameterTypeTuple!(typeof(dg)) ParameterTypeTuple; + static if (is(dg == class)) + alias ParameterTypeTuple!(dg.opCall) ParameterTypeTuple; + else static if (is(dg == struct)) + alias ParameterTypeTuple!(dg.opCall) ParameterTypeTuple; + else + alias ParameterTypeTuple!(typeof(dg)) ParameterTypeTuple; } /** ditto */ <<<<<<<<<<<<<<<<<<<<<< import std.traits; class C { int opCall(int,double){return 1;} } struct S { int opCall(int,long){return 1;} } void main() { static assert(is(ParameterTypeTuple!(C)[0] == int)); static assert(is(ParameterTypeTuple!(S)[1] == long)); C c; static assert(is(ParameterTypeTuple!(c)[1] == double)); S s; static assert(is(ParameterTypeTuple!(s)[0] == int)); }
Comment #1 by rayerd.wiz — 2008-12-13T13:58:20Z
Created attachment 282 patch for ParameterTypeTuple
Comment #2 by rayerd.wiz — 2010-05-19T09:08:52Z
ParameterTypeTuple supported opCall already. This code compiles and runs fine on dmd v.2.046. import std.traits; class C { int opCall(int,double){return 1;} } struct S { int opCall(int,long){return 1;} } void main() { static assert(is(ParameterTypeTuple!(C)[0] == int)); static assert(is(ParameterTypeTuple!(S)[1] == long)); C c; static assert(is(ParameterTypeTuple!(c)[1] == double)); S s; static assert(is(ParameterTypeTuple!(s)[0] == int)); }