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
On Thursday, 12 April 2018 at 00:05:26 UTC, Nicholas Wilson wrote:
There is, with template constraints:
class SortedList(T, alias comparer)
if(is(typeof(comparer(T.init) : int))
{
//...
}
If the function is declared with explicit parameter types:
```
auto list = new
On Wednesday, 11 April 2018 at 22:13:33 UTC, Sjoerd Nijboer wrote:
On Wednesday, 11 April 2018 at 21:29:27 UTC, Alex wrote:
I would say, alias template parameter is your friend.
https://dlang.org/spec/template.html#TemplateAliasParameter
class SortedList(T, alias comparer)
It works, thank
On Wednesday, 11 April 2018 at 21:29:27 UTC, Alex wrote:
I would say, alias template parameter is your friend.
https://dlang.org/spec/template.html#TemplateAliasParameter
class SortedList(T, alias comparer)
It works, thank you!
But just to be shure, there's no way to have this more strongly
On Wednesday, 11 April 2018 at 21:07:03 UTC, Sjoerd Nijboer wrote:
class SortedList(T, int function(T) comparer)
I would say, alias template parameter is your friend.
https://dlang.org/spec/template.html#TemplateAliasParameter
´´´
import std.stdio;
import std.range;
void main()
{
I am trying to do a binary insert into my sorted array.
To sort classes and structs I would like to give a delegate `(t)
=> t.myValue` to sort on that value whitout having to implement
an interface or specifically declare opCmp for every class I want
to have sorted.
After all, I might want one