C++ Logo

std-proposals

Advanced search

[std-proposals] std::source_location::function_name returns more than bargained for

From: Alexander Christensen <alex_c007_at_[hidden]>
Date: Sun, 28 Jul 2024 11:06:13 +0000
Hello there,

On my Windows machine I input "std::source_location::current()" as a function parameter, and from that I extract its "function_name()" member function for logging purposes.
But it returns more than I would expect:

void __cdecl UTC_CommonGameViewportClient::Init(struct FWorldContext &,class UGameInstance *,bool)

I suppose for some purposes this is fine. But I am used to the "__FUNCTION__" macro which returns the name of the function.
Probably it's a good thing to not add too much to the "source_location" struct, but how about making a more nuanced distinction? Here's my idea:

source_location::function_name()
->
"UTC_CommonGameViewportClient::Init"

source_location::function_signature()
->
"void __cdecl UTC_CommonGameViewportClient::Init(struct FWorldContext &,class UGameInstance *,bool)"

For me personally this naming would be more intuitive. Any thoughts on this?

Best,
Alexander


Received on 2024-07-28 11:06:17