Op 01/06/2017 om 23:37 schreef Thiago Macieira: > On Thursday, 1 June 2017 11:21:14 PDT Yuri Alexandrov wrote: >> Would be great if such external behavior switch is implemented, something >> like QByteArray a; >> >> a.setAllocationPolicy( .. ), or whatever other proper method name. > That means every QByteArray would need to store this policy somewhere. That's > too much overhead for the 99% case, IMHO. > One could make it a policy class like the allocators you can supply in the std containers, but we're not using that pattern anywhere else in Qt that I am aware of. That way, the 99% would not pay for it because the default policy would do and (not) store exactly what is done now. An exteded policy could allow tweaking this behavior, for instance by never releasing more than what was explicitly reserved or never automatically releasing at all.
Downside would be that a QByteArray<DefaultPolicy> would not be the same type as a QByteArray<TweakablePolicy>, so assignments and other operations would not just work between them. Might not be worth the trouble. André _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest