constexpr_abs
authorYedidya Feldblum <yfeldblum@fb.com>
Tue, 9 Aug 2016 02:46:27 +0000 (19:46 -0700)
committerFacebook Github Bot 1 <facebook-github-bot-1-bot@fb.com>
Tue, 9 Aug 2016 02:53:28 +0000 (19:53 -0700)
commitcf93e8078003574f8b48d411383098d52ba0c642
tree7e606059c914be1fe1be32b94048e287d04bd5ca
parentb26ef8ac2f904cff06d68f260134cb5a174fba95
constexpr_abs

Summary:
[Folly] `constexpr_abs`.

Is `constexpr`.

Works over integral and floating types.

If given an integral type, the return type is the usigned version of that integral type, thereby avoiding the undefined behavior of `std::abs(std::numeric_limits<int>::min())`.

Reviewed By: simpkins

Differential Revision: D3654072

fbshipit-source-id: 24fefc0c3b055f78ba3e07472c38fb9c550e0f31
folly/portability/Constexpr.h
folly/portability/test/ConstexprTest.cpp [new file with mode: 0644]
folly/test/Makefile.am