Skip to content

Fmt spdlog update #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cmake/fmt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(FMT_INSTALL YES)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG 10.1.1
GIT_TAG 11.2.0
)
FetchContent_MakeAvailable(fmt)
target_link_libraries(${SVS_LIB} INTERFACE fmt::fmt)
2 changes: 1 addition & 1 deletion cmake/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set(SPDLOG_FMT_EXTERNAL YES CACHE BOOL "" FORCE)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG v1.13.0
GIT_TAG v1.15.3
)
FetchContent_MakeAvailable(spdlog)
target_link_libraries(${SVS_LIB} INTERFACE spdlog::spdlog)
Expand Down
22 changes: 13 additions & 9 deletions include/svs/lib/threads/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,16 @@ DynamicPartition(const R&, size_t) -> DynamicPartition<typename R::const_iterato
} // namespace threads
} // namespace svs

///// Formatting
template <typename T>
struct fmt::formatter<svs::threads::UnitRange<T>> : svs::format_empty {
auto format(const svs::threads::UnitRange<T>& x, auto& ctx) const {
return fmt::format_to(
ctx.out(), "UnitRange<{}>({}, {})", svs::datatype_v<T>, x.start(), x.stop()
);
}
};
// Clang-18+ fails to compile the following code.
// The related fmt issue can be found here: https://github.com/gabime/spdlog/issues/3333
// Comment out the code until the issue is resolved in an upcoming fmt update
// Related test: tests/svs/lib/threads/types.cpp::printing
// Formatting
//template <typename T>
//struct fmt::formatter<svs::threads::UnitRange<T>> : svs::format_empty {
//auto format(const svs::threads::UnitRange<T>& x, auto& ctx) const {
//return fmt::format_to(
//ctx.out(), "UnitRange<{}>({}, {})", svs::datatype_v<T>, x.start(), x.stop()
//);
//}
//};
1 change: 1 addition & 0 deletions include/svs/third-party/fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "fmt/core.h"
#include "fmt/format.h"
#include "fmt/std.h"
#include "fmt/ranges.h"

// stl
#include <string_view>
Expand Down
10 changes: 5 additions & 5 deletions tests/svs/lib/threads/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ CATCH_TEST_CASE("Thread Helper Types", "[core][threads]") {
CATCH_REQUIRE(*(r.end() - 1) == 99);
}

CATCH_SECTION("Printing") {
auto range = svs::threads::UnitRange<size_t>(100, 200);
auto repr = fmt::format("{}", range);
CATCH_REQUIRE(repr == "UnitRange<uint64>(100, 200)");
}
//CATCH_SECTION("Printing") {
//auto range = svs::threads::UnitRange<size_t>(100, 200);
//auto repr = fmt::format("{}", range);
//CATCH_REQUIRE(repr == "UnitRange<uint64>(100, 200)");
//}

CATCH_SECTION("Indexing") {
auto range = svs::threads::UnitRange(100, 200);
Expand Down
Loading