1 // Boost.Geometry Index
2 //
3 // Abs of difference
4 //
5 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // This file was modified by Oracle on 2020.
8 // Modifications copyright (c) 2020, Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 //
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14 
15 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP
16 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP
17 
18 #include <type_traits>
19 
20 namespace boost { namespace geometry { namespace index { namespace detail
21 {
22 
23 template
24 <
25     typename T,
26     std::enable_if_t<std::is_integral<T>::value, int> = 0
27 >
diff_abs(T const & v1,T const & v2)28 inline T diff_abs(T const& v1, T const& v2)
29 {
30     return v1 < v2 ? v2 - v1 : v1 - v2;
31 }
32 
33 template
34 <
35     typename T,
36     std::enable_if_t<! std::is_integral<T>::value, int> = 0
37 >
diff_abs(T const & v1,T const & v2)38 inline T diff_abs(T const& v1, T const& v2)
39 {
40     return ::fabs(v1 - v2);
41 }
42 
43 }}}} // namespace boost::geometry::index::detail
44 
45 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP
46