Bug #83959 Allow moving or emplacing elements into Prealloced_array
Submitted: 25 Nov 2016 9:05 Modified: 1 Dec 2016 12:46
Reporter: Knut Anders Hatlen Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: JSON Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[25 Nov 2016 9:05] Knut Anders Hatlen
Prealloced_array only allows copying of elements into the array, which prevents creation of arrays that hold objects that cannot be copied, such as std::unique_ptr.

It would be useful if it were possible to move or emplace new elements in Prealloced_array. This would make it possible to have arrays of std::unique_ptr objects, which could be used to simplify memory management in the Json_object and Json_array classes. Another benefit is that some types might be cheaper to move than to copy.

How to repeat:

Suggested fix:
Add overloads of Prealloced_array::insert() and Prealloced_array::push_back() that take rvalue references, similar to std::vector in C++11. Also add C++ emplace() and emplace_back() functions.
[1 Dec 2016 12:46] Jon Stephens
Fixed in MySQL 8.0.1. Refactoring/internal changes only; no changelog entry required.