Add a default value option for new_array

Issue #226 wontfix
Alexander Ding created an issue

Among other things, it’d be nice to do

global_ptr<int> p = new_array<int>(num_values, init_value);

Comments (2)

  1. Dan Bonachea

    I agree this might be nice syntactic sugar, but there's no reason to believe it would ever be more efficient than:

    #include <algorithm>
    
      global_ptr<int> p = upcxx::allocate<int>(num_values);
      std::fill_n(p.local(), num_values, init_value);
    

    Which you can of course wrap up in your own sugar function.

  2. Dan Bonachea

    This issue was discussed at the 2019-07-24 Pagoda issue meeting.

    Given the availability of an existing concise and efficient mechanism to accomplish the requested semantics (given in the first comment), we are not planning to pursue this suggestion at this time.

  3. Log in to comment