Templated static opCall in non-templated struct

Matthew Dudley pontifechs at gmail.com
Tue Feb 11 11:13:06 PST 2014


I'm not sure that the same ambiguity is here in this case. Since 
the opCall is static, the only other thing that the template 
could apply to is the struct, which you can check that it doesn't 
from the struct definition.

On Tuesday, 11 February 2014 at 00:05:08 UTC, Namespace wrote:
> 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?
>
> Welcome to my world ;)
> http://forum.dlang.org/thread/hdocnxglxmfpacnpmouh@forum.dlang.org



More information about the Digitalmars-d-learn mailing list