[Issue 14269] Enum is not implicitly converted to base type when using ref
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Mar 12 12:12:01 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14269
--- Comment #28 from Steven Schveighoffer <schveiguy at yahoo.com> ---
The Object contents are passed by ref, just like the enum contents are.
The difference is that the ref is implicit for the object. In other words, a
ref to a C object is implicitly passable as a ref to a base Object. A ref to a
C object *reference* is not passable as a ref to a base Object reference for
correct reasons.
The equivalent to your code for enums would be:
void foo (int *o) {
o = new int;
}
enum E : int;
void main () {
E *c = new E;
auto n = c;
foo(c);
assert(c == n); // assertion passed
}
--
More information about the Digitalmars-d-bugs
mailing list