D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2512 - ParameterTypeTuple do not support opCall
Summary: ParameterTypeTuple do not support opCall
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-13 13:54 UTC by Haruki Shigemori
Modified: 2015-06-09 01:20 UTC (History)
0 users

See Also:


Attachments
patch for ParameterTypeTuple (488 bytes, patch)
2008-12-13 13:58 UTC, Haruki Shigemori
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Haruki Shigemori 2008-12-13 13:54:24 UTC
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 Haruki Shigemori 2008-12-13 13:58:20 UTC
Created attachment 282 [details]
patch for ParameterTypeTuple
Comment 2 Haruki Shigemori 2010-05-19 09:08:52 UTC
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));
}