AttributedFunction

Entry point for funcattr API.

Helper struct that takes care of calling given Function in a such way that part of its arguments are evalutated by attached input attributes (see before) and output gets post-processed by output attribute (see after).

One such structure embeds single attributed function to call and specific argument type list that can be passed to attached functions.

Members

Functions

opCall
ReturnType!Function opCall(T args)

Convenience wrapper tha creates stub delegate for free functions.

opCall
ReturnType!Function opCall(FunctionDg dg, T args)

Used to invoke configured function/method with all attached attribute functions.

storeArgs
void storeArgs(StoredArgTypes.expand args)

Stores argument tuple for attached function calls

Parameters

Function

attributed function

StoredArgTypes

Group of argument types for attached functions

Examples

example

import std.conv;

static string evaluator(string left, string right)
{
	return left ~ right;
}

// all attribute function must accept same stored parameters
static int modificator(int result, string unused1, string unused2)
{
	return result * 2;
}

@before!evaluator("a") @before!evaluator("c") @after!modificator()
static int sum(string a, int b, string c, double d)
{
	return to!int(a) + to!int(b) + to!int(c) + to!int(d);
}

// ("10", "20") - stored arguments for evaluator()
auto funcattr = createAttributedFunction!sum("10", "20");

// `b` and `d` are unattributed, thus `42` and `13.5` will be
// used as their values
int result = funcattr(42, 13.5);

assert(result == (1020 + 42 + 1020 + to!int(13.5)) * 2);

Meta