| Thread overview | |||||
|---|---|---|---|---|---|
|
June 16, 2011 templated overloaded operator problem.. :~ | ||||
|---|---|---|---|---|
| ||||
I have 2 overload of the opCall() in one of my class.
They cause a compile time error / conflict... any idea on how to solve it?
=====
class MemberDesc
{
Variant opCall(Object target)
{
return getter(target);
}
void opCall(T)(Object target, T value)
{
setter(target, Variant(value));
}
const string name;
const TypeInfo type;
const Variant function(Object target) getter;
const void function(Object target, Variant value) setter;
this(
string name, TypeInfo type,
Variant function(Object target) getter, void function(Object target, Variant value) setter = null)
{
this.name = name;
this.type = type;
this.getter = getter;
this.setter = setter;
}
}
=====
| ||||
June 16, 2011 Re: templated overloaded operator problem.. :~ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Lloyd Dupont | Add a pair of parentheses to the first overload to add an empty template argument list – currently, template and non-template functions can't be overloaded.
David
On 6/16/11 2:59 PM, Lloyd Dupont wrote:
> I have 2 overload of the opCall() in one of my class.
> They cause a compile time error / conflict... any idea on how to solve it?
> =====
> class MemberDesc
> {
> Variant opCall(Object target)
> {
> return getter(target);
> }
> void opCall(T)(Object target, T value)
> {
> setter(target, Variant(value));
> }
>
> const string name;
> const TypeInfo type;
> const Variant function(Object target) getter;
> const void function(Object target, Variant value) setter;
> this(
> string name, TypeInfo type,
> Variant function(Object target) getter, void function(Object target,
> Variant value) setter = null)
> {
> this.name = name;
> this.type = type;
> this.getter = getter;
> this.setter = setter;
> }
> }
> =====
>
| |||
June 16, 2011 Re: templated overloaded operator problem.. :~ | ||||
|---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | Ho thanks, even better than the work around I just found! :) "David Nadlinger" wrote in message news:itcvbj$1td2$1@digitalmars.com... Add a pair of parentheses to the first overload to add an empty template argument list – currently, template and non-template functions can't be overloaded. David | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply