Implement Smart Pointer Creation With Default Initialization by AdamBucior · Pull Request #1315 · microsoft/STL (original) (raw)
This looks great - thanks for the thorough and highly detailed work. (I noticed and appreciated the improvements like using remove_cvref_t
on perfectly forwarded _Types
to handle const lvalues, and unifying additional repetitive code. Combining 3 overloads into 1, for both the make
and allocate
families, is awesome.)
I pushed a merge with master
and a small set of superficial cleanups, after verifying that the test is still passing:
- When granting friendship to
_Make_shared_unbounded_array
and_Allocate_shared_unbounded_array
, dropconst
on the value parametersize_t _Count
. (We conventionally avoid top-levelconst
on value parameters in function declarations, since it has no meaning to callers and is immediately ignored by the language. We are so picky aboutconst
! 😹) - Your
_Make_shared_unbounded_array
/_Allocate_shared_unbounded_array
refactoring has a bonus: we no longer need to grant friendship to severalmake_shared
etc. overloads. - When functions take
const _Arg&
, we don't need to applyremove_cvref_t
to_Arg
(unless we were worried about_Arg
being passed as an explicit template argument, instead of being deduced, which is not a concern here). - Remove a leftover comment after the
allocate_shared
refactoring. - Use
is_bounded_array_v
inmake_unique_for_overwrite
for consistency.
I'll find a second maintainer to review and then we can merge this! 🚀