42 lines · plain
1// (C) Copyright Matt Borland 2021.2// Use, modification and distribution are subject to the3// Boost Software License, Version 1.0. (See accompanying file4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5//6// Constepxr implementation of fabs (see c.math.abs secion 26.8.2 of the ISO standard)7 8#ifndef BOOST_MATH_CCMATH_FABS9#define BOOST_MATH_CCMATH_FABS10 11#include <boost/math/ccmath/detail/config.hpp>12 13#ifdef BOOST_MATH_NO_CCMATH14#error "The header <boost/math/fabs.hpp> can only be used in C++17 and later."15#endif16 17#include <boost/math/ccmath/abs.hpp>18 19namespace boost::math::ccmath {20 21template <typename T>22inline constexpr auto fabs(T x) noexcept23{24 return boost::math::ccmath::abs(x);25}26 27inline constexpr float fabsf(float x) noexcept28{29 return boost::math::ccmath::abs(x);30}31 32#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS33inline constexpr long double fabsl(long double x) noexcept34{35 return boost::math::ccmath::abs(x);36}37#endif38 39}40 41#endif // BOOST_MATH_CCMATH_FABS42