forked from OSchip/llvm-project
Implement P0030R1: Introduce a 3-Argument Overload to std::hypot
llvm-svn: 269772
This commit is contained in:
parent
bbd10b4579
commit
4328c2bac8
|
@ -209,6 +209,10 @@ floating_point hypot (arithmetic x, arithmetic y);
|
|||
float hypotf(float x, float y);
|
||||
long double hypotl(long double x, long double y);
|
||||
|
||||
double hypot(double x, double y, double z); // C++17
|
||||
float hypot(float x, float y, float z); // C++17
|
||||
long double hypot(long double x, long double y, long double z); // C++17
|
||||
|
||||
int ilogb (arithmetic x);
|
||||
int ilogbf(float x);
|
||||
int ilogbl(long double x);
|
||||
|
@ -548,6 +552,30 @@ using ::lgamma;
|
|||
using ::lgammaf;
|
||||
#endif // __sun__
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
|
||||
|
||||
template <class _A1, class _A2, class _A3>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename std::__lazy_enable_if
|
||||
<
|
||||
std::is_arithmetic<_A1>::value &&
|
||||
std::is_arithmetic<_A2>::value &&
|
||||
std::is_arithmetic<_A3>::value,
|
||||
std::__promote<_A1, _A2, _A3>
|
||||
>::type
|
||||
hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
|
||||
{
|
||||
typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
|
||||
static_assert((!(std::is_same<_A1, __result_type>::value &&
|
||||
std::is_same<_A2, __result_type>::value &&
|
||||
std::is_same<_A3, __result_type>::value)), "");
|
||||
return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_CMATH
|
||||
|
|
|
@ -79,6 +79,7 @@ Ambiguous fma(Ambiguous, Ambiguous, Ambiguous){ return Ambiguous(); }
|
|||
Ambiguous fmax(Ambiguous, Ambiguous){ return Ambiguous(); }
|
||||
Ambiguous fmin(Ambiguous, Ambiguous){ return Ambiguous(); }
|
||||
Ambiguous hypot(Ambiguous, Ambiguous){ return Ambiguous(); }
|
||||
Ambiguous hypot(Ambiguous, Ambiguous, Ambiguous){ return Ambiguous(); }
|
||||
Ambiguous ilogb(Ambiguous){ return Ambiguous(); }
|
||||
Ambiguous lgamma(Ambiguous){ return Ambiguous(); }
|
||||
Ambiguous llrint(Ambiguous){ return Ambiguous(); }
|
||||
|
@ -1010,6 +1011,28 @@ void test_hypot()
|
|||
static_assert((std::is_same<decltype(std::hypot((int)0, (int)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(hypot(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
|
||||
assert(std::hypot(3,4) == 5);
|
||||
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (float)0, (float)0)), float>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (bool)0, (float)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (unsigned short)0, (double)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (int)0, (long double)0)), long double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (unsigned int)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (double)0, (long)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (long double)0, (unsigned long)0)), long double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (int)0, (long long)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (int)0, (unsigned long long)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (double)0, (double)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (long double)0, (long double)0)), long double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (float)0, (double)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (float)0, (long double)0)), long double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((float)0, (double)0, (long double)0)), long double>::value), "");
|
||||
static_assert((std::is_same<decltype(std::hypot((int)0, (int)0, (int)0)), double>::value), "");
|
||||
static_assert((std::is_same<decltype(hypot(Ambiguous(), Ambiguous(), Ambiguous())), Ambiguous>::value), "");
|
||||
|
||||
assert(std::hypot(2,3,6) == 7);
|
||||
assert(std::hypot(1,4,8) == 9);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_ilogb()
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<tr><td><a href="http://wg21.link/P0253R1">P0253R1</a></td><td>LWG</td><td>Fixing a design mistake in the searchers interface</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
|
||||
<tr><td><a href="http://wg21.link/P0025R0">P0025R0</a></td><td>LWG</td><td>An algorithm to "clamp" a value between a pair of boundary values</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
|
||||
<tr><td><a href="http://wg21.link/P0154R1">P0154R1</a></td><td>LWG</td><td>constexpr std::hardware_{constructive,destructive}_interference_size</td><td>Jacksonville</td><td></td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/P0030R1">P0030R1</a></td><td>LWG</td><td>Proposal to Introduce a 3-Argument Overload to std::hypot</td><td>Jacksonville</td><td></td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/P0030R1">P0030R1</a></td><td>LWG</td><td>Proposal to Introduce a 3-Argument Overload to std::hypot</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
|
||||
<tr><td><a href="http://wg21.link/P0031R0">P0031R0</a></td><td>LWG</td><td>A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access</td><td>Jacksonville</td><td></td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/P0272R1">P0272R1</a></td><td>LWG</td><td>Give <tt>std::string</tt> a non-const <tt>.data()</tt> member function</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
|
||||
<tr><td><a href="http://wg21.link/P0077R2">P0077R2</a></td><td>LWG</td><td><tt>is_callable</tt>, the missing INVOKE related trait</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
|
||||
|
|
Loading…
Reference in New Issue