-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify feature-detection for
std::source_location
- Loading branch information
Showing
1 changed file
with
10 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
#ifndef INC_METTLE_DETAIL_SOURCE_LOCATION_HPP | ||
#define INC_METTLE_DETAIL_SOURCE_LOCATION_HPP | ||
|
||
#include <ciso646> | ||
#include <version> | ||
|
||
// Try to use `std::source_location`, except on Clang 15, where it's broken. | ||
// See <https://github.com/llvm/llvm-project/issues/56379>. | ||
#if __has_include(<source_location>) && \ | ||
#if defined(__cpp_lib_source_location) && \ | ||
__has_include(<source_location>) && \ | ||
(!defined(__clang__) || __clang_major__ >= 16) | ||
# include <source_location> | ||
# ifdef __cpp_lib_source_location | ||
# define METTLE_FOUND_SOURCE_LOCATION | ||
|
||
namespace mettle::detail { | ||
using source_location = std::source_location; | ||
} | ||
# endif | ||
#endif | ||
|
||
#if !defined(METTLE_FOUND_SOURCE_LOCATION) && \ | ||
__has_include(<experimental/source_location>) | ||
#elif !defined(METTLE_FOUND_SOURCE_LOCATION) && \ | ||
__has_include(<experimental/source_location>) | ||
# include <experimental/source_location> | ||
# define METTLE_FOUND_SOURCE_LOCATION | ||
|
||
namespace mettle::detail { | ||
using source_location = std::experimental::source_location; | ||
} | ||
#endif | ||
|
||
#ifndef METTLE_FOUND_SOURCE_LOCATION | ||
#else | ||
# include "source_location_shim.hpp" | ||
|
||
namespace mettle::detail { | ||
using source_location = source_location_shim; | ||
} | ||
#endif | ||
|
||
#undef METTLE_FOUND_SOURCE_LOCATION | ||
#endif | ||
|
||
#endif |