Skip to content

Commit

Permalink
Simplify feature-detection for std::source_location
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter committed Aug 16, 2024
1 parent 0b31d82 commit 7373056
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions include/mettle/detail/source_location.hpp
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

0 comments on commit 7373056

Please sign in to comment.