On Sunday, 3 August 2014 at 21:47:06 UTC, Artur Skawina via
Digitalmars-d-learn wrote:
void sort (R, T = ElementType!R, alias compare = less_than)(R
range, T item)
[should work iff the sort implementation only calls the
predicate]
artur
This works! Thanks!
On 08/03/14 23:19, Vlad Levenfeld via Digitalmars-d-learn wrote:
>
> I made less_than to serve as a default sorting predicate, so in a few places
> there is something like this:
>
> void sort (R, T = ElementType!R, alias compare = less_than!T)(R range, T item)
> {...}
void sort (R, T = Element
On Sunday, 3 August 2014 at 21:24:03 UTC, Vlad Levenfeld wrote:
certain data structures I use are not intended to be copied,
.
although these cases are probably better off being compared by
some kind of key rather than directly... so, auto ref isn't
necessary here, it was just something I
On Sunday, 3 August 2014 at 20:10:39 UTC, Martijn Pot wrote:
What is the benefit of 'auto ref' over 'in' as you are changing
a nor b?
Because
less_than (T)(T a, T b)
(or in, or const T) will copy a and b on their way into the
function. Usually this is ok but certain data structures I use
On Sunday, 3 August 2014 at 19:43:53 UTC, anonymous wrote:
If this exact code errors for you, it ... uhh ... could be
platform specific? Are you on Windows?
Debian, and your code works for me. I figured out the problem - I
made less_than to serve as a default sorting predicate, so in a
few pl
On Sunday, 3 August 2014 at 19:25:32 UTC, Vlad Levenfeld wrote:
This would make the function always take its argument by
reference. I'm trying to use the feature here:
http://dlang.org/template.html
from the section Function Templates with Auto Ref Parameters
I thought I finally saw a questi
On Sunday, 3 August 2014 at 19:30:38 UTC, Vlad Levenfeld wrote:
On Sunday, 3 August 2014 at 19:26:28 UTC, anonymous wrote:
Works for me with dmd versions back to 2.060. What compiler are
you using?
dmd 2.065
Here's how I'm testing this:
$ dmd | head -n 1
DMD64 D Compiler v2.065
$ cat less_t
On Sunday, 3 August 2014 at 19:26:28 UTC, anonymous wrote:
Works for me with dmd versions back to 2.060. What compiler are
you using?
dmd 2.065
This would make the function always take its argument by
reference. I'm trying to use the feature here:
http://dlang.org/template.html
from the section Function Templates with Auto Ref Parameters
On Sunday, 3 August 2014 at 19:07:32 UTC, Vlad Levenfeld wrote:
bool less_than (T)(auto ref T a, auto ref T b)
{
return a < b;
}
Error: auto can only be used for template function parameters
Works for me with dmd versions back to 2.060. What compiler are
you using?
On Sunday, 3 August 2014 at 19:07:32 UTC, Vlad Levenfeld wrote:
This doesn't work:
bool less_than (T)(auto ref T a, auto ref T b)
{
return a < b;
}
Error: auto can only be used for template function parameters
What am I doing wrong? Is this not a template function?
I think you can ju
This doesn't work:
bool less_than (T)(auto ref T a, auto ref T b)
{
return a < b;
}
Error: auto can only be used for template function parameters
What am I doing wrong? Is this not a template function?
12 matches
Mail list logo