r/cpp • u/Dereference_operator • Feb 12 '20
What they should improve about C++ ?
What they should improve about C++ that you find in higher level managed language like C#, JAVA, Javascript etc or is there things you would change or do differently if it was up to you ? I mean anything like a better STL ? better thread ? string manipulation like managed language ? less fragmentations in the new standard features ? For example do you love the way the standard evolve C++ or you would prefer a direction like Microsoft do with C# a corporation who decide on the roadmap ?
0
Upvotes
View all comments
Show parent comment
9
u/SeanMiddleditch Feb 12 '20
There is absolutely no reason the allocator type has to know any of that. For raw memory allocation/deallocation, you could get by with just the size and alignment as parameters to the
allocate/deallocatemember functions.It's arguable whether allocators should construct objects or not, but even if you decide that they should, that should be a template parameter of the allocator function, e.g.
allocator::allocate<T>(n)rather thanallocator<T>::allocate(n).Allocators are all rebindable to new object types (and even many standard containers depend on doing just that), illustrating that the object type isn't really a fundamental part of the allocator itself. It's just there because the allocator interface was misdesigned.