Simple implementation of __FUNCTION

Rob T rob at ucora.com
Fri Nov 2 14:00:00 PDT 2012


On Friday, 2 November 2012 at 17:55:33 UTC, Adam D. Ruppe wrote:
>> The ONLY thing left that I would like to have, is ability to 
>> display the function signature along with the name.
>
> template __FUNCTION_SIGNATURE() { const char[] 
> __FUNCTION_SIGNATURE = "typeof(__traits(parent, {})).stringof"; 
> }
>
> int main(string[] args) {
>         assert(0, mixin(__FUNCTION_SIGNATURE!()));
> }
>
> core.exception.AssertError at test4.d(7): int(string[] args)

That was fast, thanks!

template __PRETTY_FUNCTION()
{
	const char[] __PRETTY_FUNCTION = "__traits(identifier, 
__traits(parent, {})) ~ " ~ __FUNCTION_SIGNATURE!();
}


--rt


More information about the Digitalmars-d mailing list