Hi Alexander,
- as function_name already exists, you better propose something in addition instead of changing the existing function, e.g. function_name_short() or short_function_name()
- the output is implementation defined, but it probably would guide implementers, if two functions would exist
- the signature is helping to uniquely identify the function. If you strip parameters, there could be two functions with the same output (never that there was such a uniqueness guarantee in the first place)
- source_location::current() and source_location::function_name() are consteval/constexpr functions. You could modify the returned string at compile time to your liking, e.g. searching for '(' and removing everything afterwards
Best,
Sebastian
-----Ursprüngliche Nachricht-----
Von: Alexander Christensen via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: So 28.07.2024 13:06
Betreff: [std-proposals] std::source_location::function_name returns more than bargained for
An: std-proposals@lists.isocpp.org;
CC: Alexander Christensen <alex_c007@hotmail.com>;
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-- Std-Proposals mailing list Std-Proposals@lists.isocpp.org https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals