[libc++] Add `__truncating_cast` for safely casting float types to integers

This is needed anytime we need to clamp an arbitrary floating point
value to an integer type.

Thanks to Eric Fiselier for the patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@370891 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit c9ac8d533010d8915bcfdecab891fb451f71ce74)
(cherry picked from commit 4561f55204960c0b3bc4594089ddcf56e5655cad)

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=994957
Bug: http://b/139690488
Change-Id: I300b6565137b51bb3051bb629ec3316edf7f71e9
(cherry picked from commit 34d1dd71fa4c096107dde636e5c723c32a20d387)
2 files changed