Skip to content

Replace function name string literals by 'std::source_location::function_name'

Summary

At the moment, many of our logging and exception string contain a literal sub-string with the function name. Some examples:

The problem with this approach is that it's very prone to errors. With simple changes, such as a copy-past of code, or a function name modification, we risk that the string will no longer match the function name. Some examples:

Instead, we should use std::source_location::function_name (C++20 standard replacement of __FUNCTION__/__func__).

What is the expected correct behaviour?

Instead of this, we should rely on std::source_location::function_name to always provide the correct function name.