Templated static opCall in non-templated struct
Frustrated
c1514843 at drdrb.com
Tue Feb 11 17:59:53 PST 2014
On Tuesday, 11 February 2014 at 00:00:06 UTC, Matthew Dudley
wrote:
> Here's the gist of what I'm trying to do:
>
> struct Foo
> {
> public:
> int i;
> int j;
>
> static opCall(int i)(int j, int k)
> {
> return Foo(i+j,i+k);
> }
> }
>
> void main()
> {
> auto bob = Foo!(1)(2,3); //Error: template instance Foo!1 Foo
> is not a template declaration, it is a struct
> }
>
>
> I'm trying to template the static opCall function, not the
> struct. Is there a way to do disambiguate between the two?
You can't do this! you are calling Foo as if it is a template...
hence the error!
Maybe the only solution is a new symbol such as
Foo!!(1)(2,3)
where !! tells the compiler that you are referencing an implicit
function call and not a template. Would be an easy solution.
More information about the Digitalmars-d-learn
mailing list