Complicated Types: Prefer “alias this” Over “alias” For Easier-To-Read Error Messages
Paul Backus
snarwin at gmail.com
Mon May 21 17:30:23 UTC 2018
On Monday, 21 May 2018 at 14:48:23 UTC, Mike Parker wrote:
> Nick Sabaluasky's first post to the D Blog is a tip on how to
> create an aliased type that keeps its name in error messages.
I'm not sure making `_data` private is really a good idea. For
example, this only works if `_data` is public:
import std.algorithm;
import std.range;
import std.stdio;
struct MyType
{
auto _data = iota(10);
alias _data this;
}
void main()
{
MyType x;
x.each!writeln;
}
More information about the Digitalmars-d-announce
mailing list