Skip to content
Snippets Groups Projects
Commit 2bb5ff8c authored by Valentin Volkl's avatar Valentin Volkl
Browse files

use working source_location

parent 146f4171
No related branches found
No related tags found
1 merge request!1404Workaround for missing std::source_location in apple-clang
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment