1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2012 Mateusz Loskot, London, UK.
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)
11 #ifndef BOOST_GEOMETRY_UTIL_CALCULATION_TYPE_HPP
12 #define BOOST_GEOMETRY_UTIL_CALCULATION_TYPE_HPP
14 #include <boost/config.hpp>
15 #include <boost/mpl/if.hpp>
16 #include <boost/type_traits/is_floating_point.hpp>
17 #include <boost/type_traits/is_fundamental.hpp>
18 #include <boost/type_traits/is_void.hpp>
20 #include <boost/geometry/util/select_coordinate_type.hpp>
21 #include <boost/geometry/util/select_most_precise.hpp>
24 namespace boost { namespace geometry
33 struct default_integral
35 #ifdef BOOST_HAS_LONG_LONG
36 typedef boost::long_long_type type;
43 \details Selects the most appropriate:
44 - if calculation type is specified (not void), that one is used
45 - else if type is non-fundamental (user defined e.g. ttmath), that one
46 - else if type is floating point, the specified default FP is used
47 - else it is integral and the specified default integral is used
52 typename CalculationType,
53 typename DefaultFloatingPointCalculationType,
54 typename DefaultIntegralCalculationType
56 struct calculation_type
61 DefaultFloatingPointCalculationType
67 DefaultIntegralCalculationType
72 typedef typename boost::mpl::if_
74 boost::is_void<CalculationType>,
75 typename boost::mpl::if_
77 boost::is_floating_point<Type>,
78 typename select_most_precise
80 DefaultFloatingPointCalculationType,
83 typename select_most_precise
85 DefaultIntegralCalculationType,
96 namespace calculation_type
105 typename CalculationType,
106 typename DefaultFloatingPointCalculationType = double,
107 typename DefaultIntegralCalculationType = detail::default_integral::type
111 typedef typename detail::calculation_type
113 typename geometry::coordinate_type<Geometry>::type,
115 DefaultFloatingPointCalculationType,
116 DefaultIntegralCalculationType
124 typename CalculationType,
125 typename DefaultFloatingPointCalculationType = double,
126 typename DefaultIntegralCalculationType = detail::default_integral::type
130 typedef typename detail::calculation_type
132 typename select_coordinate_type<Geometry1, Geometry2>::type,
134 DefaultFloatingPointCalculationType,
135 DefaultIntegralCalculationType
141 \brief calculation type (ternary, for three geometry types)
148 typename CalculationType,
149 typename DefaultFloatingPointCalculationType = double,
150 typename DefaultIntegralCalculationType = detail::default_integral::type
154 typedef typename detail::calculation_type
156 typename select_most_precise
158 typename coordinate_type<Geometry1>::type,
159 typename select_coordinate_type
166 DefaultFloatingPointCalculationType,
167 DefaultIntegralCalculationType
171 }} // namespace calculation_type::geometric
175 }} // namespace boost::geometry
178 #endif // BOOST_GEOMETRY_UTIL_CALCULATION_TYPE_HPP