]>
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 | // | |
7 | // Use, modification and distribution is subject to the Boost Software License, | |
8 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP | |
12 | #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP | |
13 | ||
14 | namespace boost { namespace geometry { namespace index { namespace detail { | |
15 | ||
16 | template <typename T> | |
17 | inline T diff_abs_dispatch(T const& v1, T const& v2, boost::mpl::bool_<true> const& /*is_integral*/) | |
18 | { | |
19 | return v1 < v2 ? v2 - v1 : v1 - v2; | |
20 | } | |
21 | ||
22 | template <typename T> | |
23 | inline T diff_abs_dispatch(T const& v1, T const& v2, boost::mpl::bool_<false> const& /*is_integral*/) | |
24 | { | |
25 | return ::fabs(v1 - v2); | |
26 | } | |
27 | ||
28 | template <typename T> | |
29 | inline T diff_abs(T const& v1, T const& v2) | |
30 | { | |
31 | typedef boost::mpl::bool_< | |
32 | boost::is_integral<T>::value | |
33 | > is_integral; | |
34 | return diff_abs_dispatch(v1, v2, is_integral()); | |
35 | } | |
36 | ||
37 | }}}} // namespace boost::geometry::index::detail | |
38 | ||
39 | #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_DIFF_ABS_HPP |