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

Make absl::from_chars_result compatible with C++20 and C++26 #1800

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
4 changes: 4 additions & 0 deletions absl/strings/charconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ enum class chars_format {
struct from_chars_result {
absl::Nonnull<const char*> ptr;
std::errc ec;

bool operator==(const from_chars_result&) = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't work prior to C++20. You will have to implement the operator method.

/abseil-cpp/absl/strings/charconv.h:51:8: error: defaulted 'bool absl::from_chars_result::operator==(const absl::from_chars_result&)' only available with '-std=c++20' or '-std=gnu++20'
   51 |   bool operator==(const from_chars_result&) = default;

Also, I know this is a simple change, but it still needs test coverage.


constexpr explicit operator bool() const noexcept { return ec == std::errc{}; }
};

// Workalike compatibility version of std::from_chars from C++17. Currently
Expand Down