Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:28

0001 // Boost.Geometry Index
0002 //
0003 // Abs of difference
0004 //
0005 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2020-2023.
0008 // Modifications copyright (c) 2020-2023, Oracle and/or its affiliates.
0009 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 //
0012 // Use, modification and distribution is subject to the Boost Software License,
0013 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0014 // http://www.boost.org/LICENSE_1_0.txt)
0015 
0016 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP
0017 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP
0018 
0019 #include <cmath>
0020 #include <type_traits>
0021 
0022 namespace boost { namespace geometry { namespace index { namespace detail
0023 {
0024 
0025 template
0026 <
0027     typename T,
0028     std::enable_if_t<std::is_integral<T>::value, int> = 0
0029 >
0030 inline T diff_abs(T const& v1, T const& v2)
0031 {
0032     return v1 < v2 ? v2 - v1 : v1 - v2;
0033 }
0034 
0035 template
0036 <
0037     typename T,
0038     std::enable_if_t<! std::is_integral<T>::value, int> = 0
0039 >
0040 inline T diff_abs(T const& v1, T const& v2)
0041 {
0042     return ::fabs(v1 - v2);
0043 }
0044 
0045 }}}} // namespace boost::geometry::index::detail
0046 
0047 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP