Light-weight and type-safe wrapper which serves a purpose of being able to select proper ut::new_arr* overload.
More...
Light-weight and type-safe wrapper which serves a purpose of being able to select proper ut::new_arr* overload.
Without having a separate overload with this type, creating an array of default-initialized instances of T through the ut::new_arr*(Args &&... args) overload would have been impossible because: int *ptr = ut::new_arr_withkey<int>(UT_NEW_THIS_FILE_PSI_KEY, 5); wouldn't even compile and int *ptr = ut::new_arr_withkey<int>(UT_NEW_THIS_FILE_PSI_KEY, std::forward_as_tuple(5)); would compile but would not have intended effect. It would create an array holding 1 integer element that is initialized to 5.
Given that function templates cannot be specialized, having an overload crafted specifically for given case solves the problem: int *ptr = ut::new_arr_withkey<int>(UT_NEW_THIS_FILE_PSI_KEY, ut::Count{5});