How to assign a delegate to a var ?
bioinfornatics via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 2 15:18:38 PDT 2014
Hi,
I would like store the delegate to another var but when i try i
get:
testTraitsWithDelegate.d(13): Error: expression template
__lambda2 is void and has no value
I do not want to run it only to save the «function» somewhere.
----------- CODE ------------
import std.stdio;
import std.typecons : Tuple;
struct attribute( alias Pred )
{
alias Predicate = Pred;
}
struct Data
{
@attribute!( (a) => a == 42 )
int x;
}
void main()
{
bool delegate( int ) tmp;
pragma( msg, __traits(getAttributes, Data.x)[0].Predicate( 42
) );
tmp = __traits(getAttributes, Data.x)[0].Predicate;
}
----------- END CODE ------------
More information about the Digitalmars-d-learn
mailing list