RFR: 8319117: GrowableArray: Allow for custom initializer instead of copy constructor [v7]
Kim Barrett
kbarrett at openjdk.org
Tue Oct 31 14:40:36 UTC 2023
On Tue, 31 Oct 2023 13:41:55 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
>> Hi,
>>
>> When using at_put and at_put_grow you can provide a value which will be supplied to the constructor of each element. In other words, you can intialize each element through a copy constructor.
>>
>> I suggest that we also provide a function equivalent where the function is provided a pointer to the memory to be initialized. This can be used for `NONCOPYABLE` classes, for example.
>>
>> This is implemented using a SFINAE pattern because `nullptr` introduces ambiguity if you use static overload.
>>
>> Currently running tier1-tier4.
>
> Johan Sjölen has updated the pull request incrementally with one additional commit since the last revision:
>
> Initialize member
Changes requested by kbarrett (Reviewer).
src/hotspot/share/utilities/growableArray.hpp line 411:
> 409: if (i >= this->_capacity) grow(i);
> 410: for (int j = this->_len; j <= i; j++)
> 411: new (&this->_data[j]) E(args...);
Use global placement new, e.g. `::new`. Also below, in `at_put_grow`
-------------
PR Review: https://git.openjdk.org/jdk/pull/16409#pullrequestreview-1706452432
PR Review Comment: https://git.openjdk.org/jdk/pull/16409#discussion_r1377678741
More information about the hotspot-dev
mailing list