Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion include/spdlog/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
#include <string>
#include <type_traits>

#ifdef __has_include
#if __has_include(<version>)
#include <version>
#endif
#endif

#ifdef SPDLOG_USE_STD_FORMAT
#include <version>
#if __cpp_lib_format >= 202207L
#include <format>
#else
Expand Down Expand Up @@ -100,6 +105,12 @@
#endif
#endif

// Add constructor to spdlog::source_loc using std::source_location
#if __cpp_lib_source_location >= 201907L
#define SPDLOG_STD_SOURCE_LOCATION
#include <source_location>
#endif

#ifndef SPDLOG_FUNCTION
#define SPDLOG_FUNCTION static_cast<const char *>(__FUNCTION__)
#endif
Expand Down Expand Up @@ -319,6 +330,13 @@ struct source_loc {
line{line_in},
funcname{funcname_in} {}

#ifdef SPDLOG_STD_SOURCE_LOCATION
SPDLOG_CONSTEXPR source_loc(const std::source_location& loc)
: filename{loc.file_name()},
line{static_cast<int>(loc.line())},
funcname{loc.function_name()} {}
#endif

SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT { return line == 0; }
const char *filename{nullptr};
int line{0};
Expand Down