Changeset View
Changeset View
Standalone View
Standalone View
libcxx/include/__cmath/fabs.h
- This file was added.
//===----------------------------------------------------------------------===// | |||||
// | |||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |||||
// See https://llvm.org/LICENSE.txt for license information. | |||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |||||
// | |||||
//===----------------------------------------------------------------------===// | |||||
#ifndef _LIBCPP___CMATH_FABS_H | |||||
#define _LIBCPP___CMATH_FABS_H | |||||
#include <__config> | |||||
#include <__type_traits/enable_if.h> | |||||
#include <__type_traits/is_integral.h> | |||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |||||
# pragma GCC system_header | |||||
#endif | |||||
_LIBCPP_BEGIN_NAMESPACE_STD | |||||
inline _LIBCPP_HIDE_FROM_ABI float fabs(float __v) _NOEXCEPT { return __builtin_fabsf(__v); } | |||||
template <class = int> | |||||
_LIBCPP_HIDE_FROM_ABI double fabs(double __v) _NOEXCEPT { | |||||
return __builtin_fabs(__v); | |||||
} | |||||
inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __v) _NOEXCEPT { return __builtin_fabsl(__v); } | |||||
template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> | |||||
_LIBCPP_HIDE_FROM_ABI double fabs(_Tp __v) _NOEXCEPT { | |||||
return __builtin_fabs(static_cast<double>(__v)); | |||||
} | |||||
_LIBCPP_END_NAMESPACE_STD | |||||
using std::fabs; | |||||
#endif // _LIBCPP___CMATH_FABS_H |