Skip to content

Commit

Permalink
A few tiny changes for C++23—friendliness (#79)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Sonotsugipaa authored Sep 3, 2024
1 parent 7ee36f3 commit 624b4d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/ctpg/ctpg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ namespace stdex
data[i] |= other.data[i];
}

constexpr bool operator == (const cbitset<N>& other)
constexpr bool operator == (const cbitset<N>& other) const
{
for (auto i = 0u; i < underlying_count; ++i)
if (data[i] != other.data[i])
Expand Down
2 changes: 2 additions & 0 deletions tests/list_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 624b4d1

Please sign in to comment.