Skip to content
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

Enable C++23, fix gcc-14 and clang-18 builds #347

Merged
merged 4 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
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
Next Next commit
Remove formatter for std::optional
fmt now ships its own.
frankosterfeld committed Apr 26, 2024

Unverified

No user is associated with the committer email.
commit 43058c4c2ed2b15e3dffa9955ebab10440ef2ddc
24 changes: 3 additions & 21 deletions src/core/include/URI.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef OPENCMW_CPP_URI_HPP
#define OPENCMW_CPP_URI_HPP
#include <algorithm>
#include <fmt/format.h>
#include <cassert>
#include <iomanip>
#include <ios>
#include <optional>
@@ -10,7 +10,8 @@
#include <string_view>
#include <unordered_map>

#include <cassert>
#include <fmt/format.h>
#include <fmt/std.h>

namespace opencmw {

@@ -476,25 +477,6 @@ struct std::hash<opencmw::URI<check>> {

// fmt::format and std::ostream helper output

// fmt::format and std::ostream helper output for std::optional
template<typename T> // TODO: move to utils class
struct fmt::formatter<std::optional<T>> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) {
return ctx.begin(); // not (yet) implemented
}

template<typename FormatContext>
auto format(std::optional<T> const &v, FormatContext &ctx) const {
return v ? fmt::format_to(ctx.out(), "'{}'", v.value()) : fmt::format_to(ctx.out(), "{{}}");
}
};

template<typename T>
inline std::ostream &operator<<(std::ostream &os, const std::optional<T> &v) {
return os << fmt::format("{}", v);
}

template<opencmw::uri_check check>
struct fmt::formatter<opencmw::URI<check>> {
template<typename ParseContext>
3 changes: 0 additions & 3 deletions src/core/test/URI_tests.cpp
Original file line number Diff line number Diff line change
@@ -268,9 +268,6 @@ TEST_CASE("helper methods", "[URI]") {
dummyStream << fmt::format("test std::optional fmt::print: '{}'\n", optional);
REQUIRE(dummyStream.str().size() != 0);
resetStream();
dummyStream << "std::cout std::optional print: " << optional << std::endl;
REQUIRE(dummyStream.str().size() != 0);
resetStream();
}

TEST_CASE("lifetime", "[URI]") {