NcEngine
SourceLocation.h
Go to the documentation of this file.
1
5#pragma once
6
7#if __has_include(<source_location>)
8 #include <source_location>
9 #define NC_SOURCE_LOCATION std::source_location
10#elif __has_include(<experimental/source_location>)
11 #include <experimental/source_location>
12 #define NC_SOURCE_LOCATION std::experimental::source_location
13#else
14 namespace nc::detail
15 {
17 {
18 static constexpr auto msg = "source_location not implemented on this compiler";
19 static constexpr auto current() noexcept { return PlaceholderSourceLocation{}; }
20 constexpr auto file_name() const noexcept { return msg; }
21 constexpr auto function_name() const noexcept { return msg; }
22 constexpr auto line() const noexcept { return 0; }
23 constexpr auto column() const noexcept { return 0; }
24 };
25 } // namespace nc::detail
26
27 #define NC_SOURCE_LOCATION nc::detail::PlaceholderSourceLocation
28#endif
29
30#define NC_SOURCE_LOCATION_CURRENT NC_SOURCE_LOCATION::current()
31#define NC_SOURCE_FILE NC_SOURCE_LOCATION_CURRENT.file_name()
32#define NC_SOURCE_FUNCTION NC_SOURCE_LOCATION_CURRENT.function_name()
33#define NC_SOURCE_LINE NC_SOURCE_LOCATION_CURRENT.line()
34#define NC_SOURCE_COLUMN NC_SOURCE_LOCATION_CURRENT.column()
Definition: SourceLocation.h:17