problem with custom predicate

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 27 13:12:37 PDT 2015


On Wednesday, 27 May 2015 at 17:56:27 UTC, Steven Schveighoffer 
wrote:
> On 5/27/15 9:59 AM, Meta wrote:
>>
>> I thought unaryFun *does* work with all callables, including
>> structs/classes with opCall?
>
> It (binaryFun actually) declares an alias. But you need an 
> actual instance to use in this case. You simply can't declare 
> that in a type definition, and it won't be set up properly in 
> the constructor even if you could. You need an instance in 
> order to use an alias to that instance.
>
> What likely would happen is if the functor is a callable type, 
> and that type is not a functor itself (i.e. doesn't define 
> static opCall), is that RedBlackTree would then require an 
> instance of that type as part of the constructor.
>
> -Steve

Yes, sorry, I meant binaryFun. I remember having a similar 
problem with tee, and decided to just disallow passing in the 
name of a struct/class with opCall as a template argument, and 
instead require that an instance is passed at runtime.


More information about the Digitalmars-d-learn mailing list