[libc++] Refactor allocate_shared to use an allocation guard

This commit is a step towards making it easier to add support for arrays
in allocate_shared. Adding support for arrays will require writing multiple
functions, and the current complexity of writing allocate_shared is
prohibitive for understanding.

Differential Revision: https://reviews.llvm.org/D93130

GitOrigin-RevId: 19d57b5c42b4e80fcbd5b6a2167e4a5f4f7b64c3
3 files changed