Thread overview
[Issue 12043] New: opCall does not work as template
[Issue 12043] opCall can only be used with IFTI and cannot be explicitly instantiated
Jan 30, 2014
Andrej Mitrovic
Feb 01, 2014
Kenji Hara
January 30, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12043

           Summary: opCall does not work as template
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: rswhite4@googlemail.com


--- Comment #0 from rswhite4@googlemail.com 2014-01-30 09:54:33 PST ---
This fails with:
Error: template instance f!float f is not a template declaration,
it is a variable

----
import std.stdio;

struct F {
    T opCall(T = int)(int a, int b, int c) {
        return cast(T)(a * b * c);
    }
}

void main() {
    F f;
    int i = f(3,4,5);
    float f_ = f!float(6, 7, 8);
}
----

I don't see why it shouldn't work.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 30, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12043


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com
            Summary|opCall does not work as     |opCall can only be used
                   |template                    |with IFTI and cannot be
                   |                            |explicitly instantiated


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2014-01-30 10:00:00 PST ---
I've reworded the title a little bit.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 30, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12043



--- Comment #2 from rswhite4@googlemail.com 2014-01-30 10:02:55 PST ---
(In reply to comment #0)
> This fails with:
> Error: template instance f!float f is not a template declaration,
> it is a variable
> 
> ----
> import std.stdio;
> 
> struct F {
>     T opCall(T = int)(int a, int b, int c) {
>         return cast(T)(a * b * c);
>     }
> }
> 
> void main() {
>     F f;
>     int i = f(3,4,5);
>     float f_ = f!float(6, 7, 8);
> }
> ----
> 
> I don't see why it shouldn't work.

Thanks, my english is limited... :)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 30, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12043



--- Comment #3 from rswhite4@googlemail.com 2014-01-30 13:31:03 PST ---
(In reply to comment #0)
> This fails with:
> Error: template instance f!float f is not a template declaration,
> it is a variable
> 
> ----
> import std.stdio;
> 
> struct F {
>     T opCall(T = int)(int a, int b, int c) {
>         return cast(T)(a * b * c);
>     }
> }
> 
> void main() {
>     F f;
>     int i = f(3,4,5);
>     float f_ = f!float(6, 7, 8);
> }
> ----
> 
> I don't see why it shouldn't work.

It also applies to opIndex and so probably to all op* methods:
----
struct F {
   T opIndex(T = int)(int index) {
       return cast(T) 0;
   }
}

void main() {
    F f;
    f[42];
    f!int[42]; /// fails
}
----

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12043


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------