diff --git a/GaudiPluginService/include/Gaudi/PluginServiceV2.h b/GaudiPluginService/include/Gaudi/PluginServiceV2.h index 88a93f487456bd6056308eaea6961bfab120f8ee..254125989f3bab15e82a822fe056542dc81b059c 100644 --- a/GaudiPluginService/include/Gaudi/PluginServiceV2.h +++ b/GaudiPluginService/include/Gaudi/PluginServiceV2.h @@ -23,24 +23,56 @@ #include <type_traits> #include <typeinfo> #include <utility> +#include <cstdint> #if __cplusplus > 201703L && __has_include( <source_location> ) # include <source_location> namespace Gaudi::PluginService::Details { using std::source_location; } -#elif __cplusplus >= 201402L && __has_include( <experimental/source_location> ) && false + +#elif __cplusplus >= 201402L && __has_include( <experimental/source_location> ) && false //TODO: false for debugging, turn on again # include <experimental/source_location> namespace Gaudi::PluginService::Details { using std::experimental::source_location; } #else namespace Gaudi::PluginService::Details { - struct source_location { - std::string file_name() {return "";}; - std::string line() {return "";} - static constexpr source_location current() { return source_location();} - }; + +struct source_location { + + // 14.1.2, source_location creation + static constexpr source_location + current(const char* __file = __builtin_FILE(), + const char* __func = __builtin_FUNCTION(), + int __line = __builtin_LINE(), + int __col = 0) noexcept + { + source_location __loc; + __loc._M_file = __file; + __loc._M_func = __func; + __loc._M_line = __line; + __loc._M_col = __col; + return __loc; + } + + constexpr source_location() noexcept + : _M_file("unknown"), _M_func(_M_file), _M_line(0), _M_col(0) + { } + + // 14.1.3, source_location field access + constexpr uint_least32_t line() const noexcept { return _M_line; } + constexpr uint_least32_t column() const noexcept { return _M_col; } + constexpr const char* file_name() const noexcept { return _M_file; } + constexpr const char* function_name() const noexcept { return _M_func; } + +private: + const char* _M_file; + const char* _M_func; + uint_least32_t _M_line; + uint_least32_t _M_col; +}; + } #endif