fix: ambiguous comparison between indexed accessor and cell reference#436
Merged
HDembinski merged 1 commit intoJul 23, 2026
Merged
Conversation
Comparing two const accessors, or an accessor with a storage cell reference, did not compile with the default storage: the accessor's catch-all comparison templates and the mirrored friend operators of unlimited_storage::reference were equally good matches. Make the accessor-vs-accessor operators const so that standard algorithms (which compare through const references) use them, and constrain the generic operators in detail/operators.hpp to yield when the other operand's class handles the comparison with a member, as operator== already did. Fixes boostorg#403 Assisted-by: ClaudeCode:claude-fable-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Fixes #403.
With the default storage, comparing two const accessors (as
std::min_element/max_elementdo via libc++'s comparator) or an accessor with a cell reference failed to compile: the accessor's catch-all comparison templates and the mirrored friend operators ofunlimited_storage::referencewere equally good matches. The existing stdlib test did not catch this because it usesstd::array<int>storage, where the cell reference is a plainint&.constto the accessor-vs-accessor comparison operators, so const contexts use them instead of falling into the catch-all template.detail/operators.hppto yield when the other operand's class handles the comparison with a member, extending the tie-breakeroperator==already had (via newhas_method_*detectors indetail/detect.hpp). The constraints only remove one side of a former ambiguity, solarge_intand arithmetic operands are unaffected.Verified locally with Apple clang (C++14/17/20/2b, libc++) and gcc-16 (C++14/20, libstdc++); full CMake test suite passes.