Opaque structs
Brad Anderson
eco at gnuk.net
Thu Jun 27 19:16:57 PDT 2013
On Friday, 28 June 2013 at 01:40:44 UTC, Andrej Mitrovic wrote:
> Note that if we implement Issue 8728[1], we could even create a
> better
> error message via:
>
> -----
> struct S
> {
> @disable("S is an opaque C type and must only be used as a
> pointer")
> this();
>
> @disable("S is an opaque C type and must only be used as a
> pointer")
> this(this);
> }
>
> void main()
> {
> S* s1; // ok
> S s2; // user error
> }
> -----
>
> [1] : http://d.puremagic.com/issues/show_bug.cgi?id=8728
+1. Anything that makes error messages clearer is a win in my
book and there is precedents for it in @deprecate(msg) which was
a clear win.
More information about the Digitalmars-d-learn
mailing list