]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/index/detail/algorithms/diff_abs.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / index / detail / algorithms / diff_abs.hpp
CommitLineData
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
14namespace boost { namespace geometry { namespace index { namespace detail {
15
16template <typename T>
17inline 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
22template <typename T>
23inline 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
28template <typename T>
29inline 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