What is the current stage of @property ?
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Jun 12 21:58:00 UTC 2020
On Thu, Jun 11, 2020 at 10:46:32AM +0000, Paul Backus via Digitalmars-d-learn wrote:
> On Thursday, 11 June 2020 at 05:41:25 UTC, H. S. Teoh wrote:
> >
> > Ironically, just today I ran into this corner case where @property
> > actually became a solution to a real problem:
> >
> > //-----module1.d------
> > auto someGenericFunc(T)(T t) {
> > ...
> > static if (is(typeof(T.init.method) : T)) {
> > R someRange = ...; // ElementType!R == T
> > auto value = someRange.map!(e => e.method);
> > }
> > ...
> > }
>
> Personally I like the way Phobos does it:
>
> ReturnType!((T t) => t.method)
>
> This works for both @property and non- at property methods.
Mmm, very nice! I'll keep this in mind for next time!
T
--
The two rules of success: 1. Don't tell everything you know. -- YHL
More information about the Digitalmars-d-learn
mailing list