What is the current stage of @property ?

Paul Backus snarwin at gmail.com
Thu Jun 11 10:46:32 UTC 2020


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.


More information about the Digitalmars-d-learn mailing list