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

Add tests to ensure types correctly use allocator_traits<A>::pointer, ideally based on boost::offset_ptr #348

Open
Twon opened this issue Feb 3, 2024 · 3 comments

Comments

@Twon
Copy link
Collaborator

Twon commented Feb 3, 2024

As @Quuxplusone points out on this PR there should be further testing added for testing to ensure types correctly make use of allocator_traits<A>::pointer.

Adding Boost as a dependency is a little heavy weight as we require a mechanism for supporting the dependency (perhaps Conan?). However, we could emulate this with a custom offset_ptr implementation for the tests.

@jwakely
Copy link
Contributor

jwakely commented Mar 21, 2024

This certainly doesn't work with fancy pointers:

auto* mem = cb_alloc_traits::allocate(cb_alloc, 1);

allocate and deallocate need to work with the allocator's pointer type, but construct and destroy work with raw pointers. You need to use std::to_address and std::pointer_traits<P>::pointer_to to convert between them.

@jwakely
Copy link
Contributor

jwakely commented Mar 21, 2024

Same problem here:

value_types/polymorphic.h

Lines 98 to 100 in a7fa0db

auto mem = cb_alloc_traits::allocate(cb_alloc, 1);
try {
cb_alloc_traits::construct(cb_alloc, mem, std::move(u_));

@Twon
Copy link
Collaborator Author

Twon commented Jun 29, 2024

Note swap methods require the 2 phase swap to support fancy pointers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants