On Thursday, 12 April 2018 at 11:53:21 UTC, Alex wrote:
On Thursday, 12 April 2018 at 11:17:01 UTC, Laurent Tréguier
wrote:
If the function is declared with explicit parameter types:
There are cool things possible, if the param type is explicitly
typed :)
´´´
import std.traits;
void main()
{
auto list = new SortedList!((Vector3 v) => v.y)();
list.foo(Vector3.init);
}
struct Vector3 { float x, y, z; }
class SortedList(alias comparer) if(is(ReturnType!comparer :
float))
{
alias T = Parameters!comparer[0];
T[] array;
auto foo(T t)
{
// do stuff
}
}
´´´
Getting rid of redundancy. Now that's nice !