This is an archive of the discontinued LLVM Phabricator instance.

[libcxx][test] MaybePOCCAAllocator should meet the Cpp17Allocator requirements
ClosedPublic

Authored by CaseyCarter on Jan 26 2022, 12:45 PM.

Details

Summary

Implement rebind, the rebinding constructor, and rebind-compatible comparison operators.

Diff Detail

Event Timeline

CaseyCarter requested review of this revision.Jan 26 2022, 12:45 PM
CaseyCarter created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptJan 26 2022, 12:45 PM
Quuxplusone added a subscriber: Quuxplusone.

LGTM as long as the answers to all my questions are "no, what I have written here is correct." ;)

libcxx/test/support/allocators.h
199–202

Isn't there allocator_traits magic that does this for all templates automatically? or is that only in pointer_traits?

210

If CI is happy with this, then OK, but I suspect that whatever is happening with copy_assigned_into_ is not well-thought-out and works only by accident, wherever it's being used/tested.

233–235

I kneejerk want to leave this operator== alone and rely on the implicit converting ctor you just added... but would that make allocT == allocU ambiguous because the compiler doesn't know which operand to convert?

CaseyCarter added inline comments.Jan 26 2022, 2:17 PM
libcxx/test/support/allocators.h
199–202

The magic only works when the allocator is a specialization of a template with at least one type parameter and no non-type template parameters. ([allocator.traits.types]/11)

210

I think I just had the constructor copy what the == examines for head-in-the-sand conformance, but I suspect the result is tests that always pass. I'll investigate.

212

Unnecessary empty line.

233–235

I think that would be ambiguous, but I don't claim to be able to reason about operator rewrites in the presence of implicit conversions. I'll investigate.

Address review comments.

CaseyCarter marked 2 inline comments as done.Jan 26 2022, 2:38 PM
CaseyCarter added inline comments.
libcxx/test/support/allocators.h
210

Fixed.

233–235

At least two compilers agree with us that it would be ambigous.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 25 2022, 11:04 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 25 2022, 11:04 AM