79650442

Date: 2025-06-02 23:28:02
Score: 1.5
Natty:
Report link

In C++20 or higher, the following macro implements the desired behavior.

It's a single line of code and works the same way that __FILE__ does.

#define __FILENAME__ std::string_view(__FILE__).substr(std::string_view(__FILE__).find_last_of("/\\") + 1).data()
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Samuel Wenker