|
Hi Sylvain,
The only reason for this const value is that we felt non-const values would be too error prone.
It would be too easy to write:
p->second.push_back("one more string");
and incorrectly believe that the update was saved to the database. This is in particular true if you use a generic algorithm for such updates: with const values, you get a compile-time error, not a surprising runtime behavior.
Of course in-place updates would save memory allocations in some situations. If you can think of an API that is at the same time efficient and safe, I'd be happy to implement it!
It would also be interesting to check how valuable such improvement would be: maybe you could measure this extra memory allocation cost with your example, and compare it with the time it takes to write to disk?
Cheers,
Bernard
|