jbcoe / value_types

value types for composite class design - with allocators
MIT License
34 stars 13 forks source link

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

Open Twon opened 7 months ago

Twon commented 7 months ago

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 commented 6 months ago

This certainly doesn't work with fancy pointers: https://github.com/jbcoe/value_types/blob/a7fa0db8f4710853f9c4469c6749102a3906e7b1/experimental/polymorphic_inline_vtable.h#L77 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 commented 6 months ago

Same problem here: https://github.com/jbcoe/value_types/blob/a7fa0db8f4710853f9c4469c6749102a3906e7b1/polymorphic.h#L98-L100

Twon commented 2 months ago

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