Yume
source_location.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5// Commented out due to libstdc++ bug 105128
6
7// if __has_include(<source_location>) && __has_builtin(__builtin_source_location)
8// #include <source_location>
9// #define yume_has_source_location 1
10// #elif __has_include(<experimental/source_location>)
11
12#if __has_include(<experimental/source_location>)
13#include <experimental/source_location>
14#define yume_has_source_location -1
15#else
16#define yume_has_source_location 0
17#endif
18
19namespace yume {
20#if yume_has_source_location == 1
21using std::source_location;
22#elif yume_has_source_location == -1
23using std::experimental::source_location;
24#else
26 constexpr inline auto file_name() const { return "??"; } // NOLINT
27 constexpr inline auto function_name() const { return "??"; } // NOLINT
28 constexpr inline auto line() const { return -1; } // NOLINT
29 constexpr inline auto column() const { return -1; } // NOLINT
30 static inline constexpr auto current() { return source_location{}; }
31};
32#endif
33
34inline auto at(const source_location location = source_location::current()) -> std::string {
35 return std::string(location.file_name()) + ":" + std::to_string(location.line()) + ":" +
36 std::to_string(location.column()) + " in " + location.function_name();
37}
38} // namespace yume
Definition: ast.cpp:8
auto at(const source_location location=source_location::current()) -> std::string
constexpr auto file_name() const
constexpr auto column() const
constexpr auto line() const
static constexpr auto current()
constexpr auto function_name() const