How to define and use a custom comparison function
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 17 00:53:50 PDT 2014
On Tuesday, 17 June 2014 at 04:32:20 UTC, Jakob Ovrum wrote:
> On Monday, 16 June 2014 at 20:49:29 UTC, monarch_dodra wrote:
>> MyCompare cmp(SortOrder.ASC, 10);
>
> This syntax is not valid D.
>
> It should be:
>
> auto cmp = MyCompare(SortOrder,ASC, 10);
Well, techincally, the *syntax* is valid. If "MyCompare" contains
a constructor, it's legit code to boot. It's part of the uniform
initialization syntax, and it's what allows things like:
BigInt b = 5;
or
BigInt b(5);
THAT said, yeah, the MyCompare I posted did not contain a
constructor. SO my code was wrong, guilty as charged.
More information about the Digitalmars-d-learn
mailing list