On Sunday, 18 August 2013 at 01:52:50 UTC, Timothee Cour wrote:
Is there any way to get the enclosing function as symbol ?
I'd like something like that:
alternative names would be:
__function__
__context__
----
auto fun(alias caller=__function__)(){
//caller represents fun1!double
return ReturnType!caller.init;
}
T fun1(T)(T x){
assert(__function__.stringof==__FUNCTION__);
alias fun=__function__;
assert( is(ReturnType! __function__) == T);
return fun();
}
void main(){fun1!double();}
----
I don't think you can pass it in to the function, but you can use
__traits(parent) on a variable within the function to get the
function.