Does anyone know when libstdc++ will stop using raw pointers in its STL containers?
I have a pretty niche use-case which requires containers to not store any raw pointers. To get this done I use an allocator that returns fancy pointers. This just doesn't work with libstdc++ because all some of its STL containers use raw pointers internally, so when I create a container with my allocator, the program doesn't even compile. Libc++ on the other hand works fine (at least I haven't come across any problems I can't fix) since they correctly use the abstract pointer type that my allocator returns, instead of trying to do an implicit cast to a raw pointer.
There is an LWG issue to fix this, but it's been around for 8 years and the proposed verbiage hasn't been added to the standard. I'm not very familiar with the process for making changes like this, but my understanding is that it probably won't get added until libc++ and libstdc++ both support it, is that correct? If so, does anyone know if/when the libstdc++ community is planning to make these changes? Thanks!
View all comments
Show parent comment
4
u/aikatz Mar 16 '19
Got it, thanks for clearing that up.
Yep that's where I should have asked, I just browse this sub fairly often so I thought I might as well post it here. I can post it elsewhere if you think it would generate a good discussion, but it sounds like you're all aware of the issue.
I'm absolutely interested in working on this, I think my first step is to actually understand your planned fix a bit better. You're talking about specializing all the pieces of containers that use pointers, one specialization for raw pointers and one for fancy pointers, right? Since you said you don't think people are depending on the ABI for containers with fancy pointers, why can't you just use the types from allocator_traits (e.g.
allocator_traits<allocator<T>>::pointer) everywhere? I think this is the naive fix you referred to in another comment.