RFR: 8319117: GrowableArray: Allow for custom initializer instead of copy constructor [v2]
Quan Anh Mai
qamai at openjdk.org
Tue Oct 31 12:27:08 UTC 2023
On Tue, 31 Oct 2023 12:19:57 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 two additional commits since the last revision:
>
> - Use variadic templates for in-place construction
> - Two tests
src/hotspot/share/utilities/growableArray.hpp line 405:
> 403: void push(const E& elem) { append(elem); }
> 404: private:
> 405: static void default_fill(E* ptr) {
This method is unused I believe
src/hotspot/share/utilities/growableArray.hpp line 410:
> 408: public:
> 409: template<typename... Args >
> 410: E at_grow(int i, Args... args) {
Should this be `Args&... args`? Also this method is returning a value instead of a reference, is it intentional?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16409#discussion_r1377501493
PR Review Comment: https://git.openjdk.org/jdk/pull/16409#discussion_r1377501250
More information about the hotspot-dev
mailing list