4 ms·
> Exactly. Most C++ libraries are not made with the idea of allowing you to police resource allocation I was saying this from the point of view of the library
by jcelerier 9y ago
> Exactly. Most C++ libraries are not made with the idea of allowing you to police resource allocation
I was saying this from the point of view of the library author, not the code. e.g. for instance I spent some weeks optimizing allocations in a library that I'm working on, and am then making assumptions in the rest of the code according to the optimizations I made. If I did let users of the library change the allocation policy, I would have to introduce costly runtime checks everywhere to ensure that the invariants I set do still hold, that I really have enough memory to do what I must, and abort / throw in case such an invariant is broken. All of these situations are less desirable than enforcing my allocation policy in my code.