diff --git a/CMakeLists.txt b/CMakeLists.txt index f1706848..7a4dc80f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.19) project(opencmw-cpp CXX) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 23) # include(cmake/StandardProjectSettings.cmake) include(cmake/PreventInSourceBuilds.cmake) @@ -126,7 +126,10 @@ if(OPENCMW_ENABLE_TESTING) if(OPENCMW_ENABLE_COVERAGE) if(UNIX AND NOT APPLE - AND NOT CMAKE_CXX_COMPILER_ID MATCHES ".*Clang" + AND NOT + CMAKE_CXX_COMPILER_ID + MATCHES + ".*Clang" AND NOT EMSCRIPTEN) # Linux message("Coverage reporting enabled") include(cmake/CodeCoverage.cmake) # https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake # diff --git a/src/core/include/URI.hpp b/src/core/include/URI.hpp index 64f7c760..7bc2373b 100644 --- a/src/core/include/URI.hpp +++ b/src/core/include/URI.hpp @@ -1,7 +1,7 @@ #ifndef OPENCMW_CPP_URI_HPP #define OPENCMW_CPP_URI_HPP #include -#include +#include #include #include #include @@ -10,7 +10,8 @@ #include #include -#include +#include +#include namespace opencmw { @@ -476,25 +477,6 @@ struct std::hash> { // fmt::format and std::ostream helper output -// fmt::format and std::ostream helper output for std::optional -template // TODO: move to utils class -struct fmt::formatter> { - template - constexpr auto parse(ParseContext &ctx) { - return ctx.begin(); // not (yet) implemented - } - - template - auto format(std::optional const &v, FormatContext &ctx) const { - return v ? fmt::format_to(ctx.out(), "'{}'", v.value()) : fmt::format_to(ctx.out(), "{{}}"); - } -}; - -template -inline std::ostream &operator<<(std::ostream &os, const std::optional &v) { - return os << fmt::format("{}", v); -} - template struct fmt::formatter> { template diff --git a/src/core/include/opencmw.hpp b/src/core/include/opencmw.hpp index 9bf32298..3185a89e 100644 --- a/src/core/include/opencmw.hpp +++ b/src/core/include/opencmw.hpp @@ -44,8 +44,6 @@ constexpr bool always_false = false; using units::basic_fixed_string; using units::is_same_v; -constexpr auto &unmove(auto &&t) { return t; } // opposite of std::move(...) - template concept invocable_r = std::is_invocable_r_v; diff --git a/src/core/test/00_opencmw_basic_tests.cpp b/src/core/test/00_opencmw_basic_tests.cpp index 4ac0d58e..19f7e3d6 100644 --- a/src/core/test/00_opencmw_basic_tests.cpp +++ b/src/core/test/00_opencmw_basic_tests.cpp @@ -20,10 +20,6 @@ static_assert(no_fwd_wrapper(0) == 1, "r-value non-forwarding -> converted to lv static_assert(fwd_wrapper_verbose(0) == 2, "r-value forwarding"); static_assert(fwd_wrapper(0) == 2, "r-value forwarding"); -/**** unmove(..) tests ***/ -static_assert(fwd_wrapper(unmove(lvalue)) == 1, "l-value -> l-value forwarding (copy)"); -static_assert(fwd_wrapper(unmove(0)) == 1, "r-value -> lvalue forwarding (copy)"); - /**** power 2 and bit-magic tests ***/ static_assert(isPower2(1024U)); static_assert(is_power2_v<1024U>); diff --git a/src/core/test/URI_tests.cpp b/src/core/test/URI_tests.cpp index 46cd46d6..22008a52 100644 --- a/src/core/test/URI_tests.cpp +++ b/src/core/test/URI_tests.cpp @@ -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]") { diff --git a/src/serialiser/test/IoSerialiserYaS_tests.cpp b/src/serialiser/test/IoSerialiserYaS_tests.cpp index dc234e82..36b8ca4e 100644 --- a/src/serialiser/test/IoSerialiserYaS_tests.cpp +++ b/src/serialiser/test/IoSerialiserYaS_tests.cpp @@ -447,8 +447,10 @@ TEST_CASE("IoSerialiser basic syntax", "[IoSerialiser]") { REQUIRE(opencmw::is_annotated == true); std::cout << fmt::format("buffer size (before): {} bytes\n", buffer.size()); - opencmw::FieldHeaderWriter::template put(buffer, unmove(FieldDescriptionShort{ .fieldName = "fieldNameA" }), 43.0); - opencmw::FieldHeaderWriter::template put(buffer, unmove(FieldDescriptionShort{ .fieldName = "fieldNameB" }), data.value.value()); + auto fieldA = FieldDescriptionShort{ .fieldName = "fieldNameA" }; + opencmw::FieldHeaderWriter::template put(buffer, fieldA, 43.0); + auto fieldB = FieldDescriptionShort{ .fieldName = "fieldNameB" }; + opencmw::FieldHeaderWriter::template put(buffer, fieldB, data.value.value()); std::cout << fmt::format("buffer size (after): {} bytes\n", buffer.size()); } REQUIRE(opencmw::debug::dealloc == opencmw::debug::alloc); // a memory leak occurred diff --git a/src/zmq/include/zmq/ZmqUtils.hpp b/src/zmq/include/zmq/ZmqUtils.hpp index d48724fb..209bb369 100644 --- a/src/zmq/include/zmq/ZmqUtils.hpp +++ b/src/zmq/include/zmq/ZmqUtils.hpp @@ -14,13 +14,13 @@ #include #include -#ifdef __clang__ // TODO: replace (source_location is part of C++20 but still "experimental" for clang +#ifdef __cpp_lib_source_location +#include +#else #include namespace std { typedef std::experimental::source_location source_location; } -#else -#include #endif #ifndef ENABLE_RESULT_CHECKS