Use the libc++ detection instead of clang detection around std:isinfinite (#52164)
Summary:
Fixes #52163
The libc++ vs libstdc++ detection in the pre-processor is taken from https://stackoverflow.com/questions/31657499/how-to-detect-stdlib-libc-in-the-preprocessor
Note that in our case `std:isinfinite` presents means that we don't need to import any additional headers to guarantee the `_LIBCPP_VERSION` presents for the `libc++`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52164
Reviewed By: albanD
Differential Revision: D26413108
Pulled By: malfet
fbshipit-source-id: 515e258d6758222c910ababf5172c3a275aff08f