Restrict Class Properties?

Manfred Nowak svv1999 at hotmail.com
Fri Feb 23 15:08:55 PST 2007


Jarrett Billingsley wrote

> No, I mean with the current "properties" it's not possible to use
> template functions as properties

I do not see the general usability if such would be enabled. Under
which circumstances are untemplated classes useful, that contain
templated functions? 


> Uhh... "buy"?  I don't know what you're trying to say, and I don't
> know how this is at all possible (unless you mean that "trick"
> that you posted involving using an extra dummy index). 

"Buy" means, that it is somehow costly.

For a class C one has to define an inner class I that implements the
required op=, ++, and -- operators; has to declare within Class C
the property as approximately "I property;"; has to extend the
constructor of Class C by a "property= new I;". 

Then one can code:
  auto c= new C;
  c.property <op>= ...

The specs
| Note: Properties currently cannot be the lvalue of an op=, ++, or
| -- operator.
do not hold for class properties.

-manfred 



More information about the Digitalmars-d mailing list