From 624b4d1fa407a19f863841673b07563ec4b83ac9 Mon Sep 17 00:00:00 2001 From: Parola Marco Date: Tue, 3 Sep 2024 17:07:18 +0200 Subject: [PATCH] =?UTF-8?q?A=20few=20tiny=20changes=20for=20C++23=E2=80=94?= =?UTF-8?q?friendliness=20(#79)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * stdex::cbitset::operator== made const This change was made in response to a GCC-14.2.1 warning: a comparison operator in the form `bool T::operator==(const U&)` (note that the function itself is not const) expects the left operand to be non-const, but as of C++20 can be "reversed" - so that `T{} == U{}` and `U{} == T{}` may refer to the same operator overload. Apparently this may break things. Regardless of the details regarding this warning, it only makes sense for stdex::cbitset::operator== to allow const operands on both sides, and it is likely the intended behavior. * [list helpers] test: added `test::non_copyable_thing` default constructor With GCC-14.2.1, compiling with `-std=c++23`: the expression `T{}` seems to expect an explicit default constructor if T (only) has deleted copy-constructors and defaulted move-constructors. --- include/ctpg/ctpg.hpp | 2 +- tests/list_helpers.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/ctpg/ctpg.hpp b/include/ctpg/ctpg.hpp index 9ff5905..6631ecc 100644 --- a/include/ctpg/ctpg.hpp +++ b/include/ctpg/ctpg.hpp @@ -265,7 +265,7 @@ namespace stdex data[i] |= other.data[i]; } - constexpr bool operator == (const cbitset& other) + constexpr bool operator == (const cbitset& other) const { for (auto i = 0u; i < underlying_count; ++i) if (data[i] != other.data[i]) diff --git a/tests/list_helpers.cpp b/tests/list_helpers.cpp index 2a56542..d2947c7 100644 --- a/tests/list_helpers.cpp +++ b/tests/list_helpers.cpp @@ -38,6 +38,8 @@ 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;