From b7bacb06274dbf6ae599698e49de1d218c248692 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Thu, 20 Jan 2022 09:39:14 +0100 Subject: [PATCH 1/2] Turned operator== and operator!= members into friend functions for Clang C++20 compatibility --- include/ctpg/ctpg.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ctpg/ctpg.hpp b/include/ctpg/ctpg.hpp index 04b46cc..c26daa2 100644 --- a/include/ctpg/ctpg.hpp +++ b/include/ctpg/ctpg.hpp @@ -124,8 +124,8 @@ namespace stdex constexpr it_type* cast() { return static_cast(this); } constexpr const it_type* cast() const { return static_cast(this); } - constexpr bool operator == (const it_type& other) const { return cast()->ptr == other.ptr; } - constexpr bool operator != (const it_type& other) const { return cast()->ptr != other.ptr; } + constexpr friend bool operator == (it_type const& a, it_type const& b) { return a.cast()->ptr == b.cast()->ptr; } + constexpr friend bool operator != (it_type const& a, it_type const& b) { return a.cast()->ptr != b.cast()->ptr; } constexpr it_type operator - (size_type amount) const { return it_type{ cast()->ptr - amount }; } constexpr size_type operator - (const it_type& other) const { return size_type(cast()->ptr - other.ptr); } constexpr it_type operator + (size_type amount) const { return it_type{ cast()->ptr + amount }; } From 66857ea287de2d43822e927c8433d7b2f87c0f79 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Thu, 20 Jan 2022 09:39:59 +0100 Subject: [PATCH 2/2] Added default constructor for non_copyable_thing that Clang doesn't generate in C++20 mode --- tests/list_helpers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/list_helpers.cpp b/tests/list_helpers.cpp index 2a56542..13ae722 100644 --- a/tests/list_helpers.cpp +++ b/tests/list_helpers.cpp @@ -38,6 +38,7 @@ namespace test { struct non_copyable_thing { + non_copyable_thing() = default; non_copyable_thing(const non_copyable_thing&) = delete; non_copyable_thing& operator = (const non_copyable_thing&) = delete; @@ -87,4 +88,4 @@ TEST_CASE("construct", "[list helpers]") REQUIRE(result.has_value()); REQUIRE(result.value().size() == 4); -} \ No newline at end of file +}