casting & templates
Chris Wright via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jan 31 11:49:37 PST 2016
On Sun, 31 Jan 2016 19:59:01 +0100, Robert M. Münch wrote:
> I have:
>
> class OperatorV(T) : Value {
> T impl;
>
> this(T impl) {
> this.impl = impl;
> }
> ...
This expands to:
template OperatorV(T) {
class OperatorV {
...
}
}
If you're just typing `OperatorV` with no template arguments, you're
referring to the template itself.
There's not necessarily any relationship between two instantiations of a
template with different arguments. You could write it so that OperatorV!
int and OperatorV!string have entirely different sets of methods,
constructors, and fields.
Because of that, the compiler doesn't create a base class for you
automatically. But you can do it yourself:
class BaseOperator {} // or interface, or abstract class
class OperatorV(T) : BaseOperator {}
More information about the Digitalmars-d-learn
mailing list