Template constraints and opAdd
anonymous
anonymous at example.com
Mon Jul 1 18:14:49 PDT 2013
On Monday, 1 July 2013 at 23:36:27 UTC, John wrote:
> struct Mass(T, S) {
> ...
>
> Mass!(T,S) opAdd(Mass!(T,S) other) {
You can't overload non-templates with templates, yet. It's
supposed to work, but not implemented. The workaround is simple
enough:
Mass!(T,S) opAdd()(Mass!(T,S) other) { // note the () after opAdd
> return op!"+"(other);
> }
>
> Mass!(O,S) opAdd(O)(Mass!(O,S) other) if (typeof(O) !=
> typeof(T)) {
That constraint should be: if (!is(O == T))
> return op!"+"(other);
> }
> ...
> }
More information about the Digitalmars-d-learn
mailing list