Property discussion wrap-up
TommiT
tommitissari at hotmail.com
Thu Jan 31 06:47:16 PST 2013
On Thursday, 31 January 2013 at 12:58:13 UTC, TommiT wrote:
> [..] So, it might be just as well to just disallow copying of
> 'properties' except when it happens as a part of copying the
> enclosing object.
Or... maybe not, because disallowing making a copy of a property
variable makes it illegal to pass it by value as a templated
argument:
struct S
{
int n;
property Prop
{
@property int get() { return outer.n; }
alias this = get;
}
Prop prop;
}
void foo(int v) {}
void bar(T)(T t)
if (isImplicitlyConvertible!(T,int))
{
int v = t;
}
...
S s;
foo(s.prop); // ok: calling foo(s.prop.get)
bar(s.prop); // error: cannot make a copy of a
// property variable of type S.Prop
More information about the Digitalmars-d
mailing list