]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry Index |
2 | // | |
3 | // Abs of difference | |
4 | // | |
5 | // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. | |
6 | // | |
20effc67 TL |
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 | // | |
7c673cae FG |
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 | ||
20effc67 | 18 | #include <type_traits> |
7c673cae | 19 | |
20effc67 | 20 | namespace boost { namespace geometry { namespace index { namespace detail |
7c673cae | 21 | { |
7c673cae | 22 | |
20effc67 TL |
23 | template |
24 | < | |
25 | typename T, | |
26 | std::enable_if_t<std::is_integral<T>::value, int> = 0 | |
27 | > | |
28 | inline T diff_abs(T const& v1, T const& v2) | |
7c673cae | 29 | { |
20effc67 | 30 | return v1 < v2 ? v2 - v1 : v1 - v2; |
7c673cae FG |
31 | } |
32 | ||
20effc67 TL |
33 | template |
34 | < | |
35 | typename T, | |
36 | std::enable_if_t<! std::is_integral<T>::value, int> = 0 | |
37 | > | |
7c673cae FG |
38 | inline T diff_abs(T const& v1, T const& v2) |
39 | { | |
20effc67 | 40 | return ::fabs(v1 - v2); |
7c673cae FG |
41 | } |
42 | ||
43 | }}}} // namespace boost::geometry::index::detail | |
44 | ||
45 | #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP |