[Issue 19710] template parameters not deduced when one is is a supplied string, and the other inferred.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 4 00:54:12 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19710

--- Comment #2 from Alex <alex at sunopti.com> ---
The solution I found was to make two versions of this attribute function with
different names.
One for structs and one for classes.

The ref is necessary to have it work for structs.

The ref fails when used with 'this' in classes.

I think the underlying problem is that in the class version, the ref refers to
the object reference (pointer), not the object pointed to, so the ref is
unnecessary, and in the case where this is passed, illegal.

In the struct version, the ref refers to the object itself, and is necessary to
prevent it being copied and operations happening to a local version.

This is a bit unfortunate, it would be nice to have a template that could work
with either.

--


More information about the Digitalmars-d-bugs mailing list