// Boost.Geometry // Copyright (c) 2021 Barend Gehrels, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_CORE_COORDINATE_PROMOTION_HPP #define BOOST_GEOMETRY_CORE_COORDINATE_PROMOTION_HPP #include // TODO: move this to a future headerfile implementing traits for these types #include #include #include namespace boost { namespace geometry { namespace traits { // todo } // namespace traits /*! \brief Meta-function converting, if necessary, to "a floating point" type \details - if input type is integer, type is double - else type is input type \ingroup utility */ // TODO: replace with, or call, promoted_to_floating_point template struct promote_floating_point { typedef std::conditional_t < std::is_integral::value, PromoteIntegerTo, T > type; }; // TODO: replace with promoted_to_floating_point template struct fp_coordinate_type { typedef typename promote_floating_point < typename coordinate_type::type >::type type; }; namespace detail { // Promote any integral type to double. Floating point // and other user defined types stay as they are, unless specialized. // TODO: we shold add a coordinate_promotion traits for promotion to // floating point or (larger) integer types. template struct promoted_to_floating_point { using type = std::conditional_t < std::is_integral::value, double, Type >; }; // Boost.Rational goes to double template struct promoted_to_floating_point> { using type = double; }; // Any Boost.Multiprecision goes to double (for example int128_t), // unless specialized template struct promoted_to_floating_point> { using type = double; }; // Boost.Multiprecision binary floating point numbers are used as FP. template struct promoted_to_floating_point < boost::multiprecision::number < boost::multiprecision::cpp_bin_float > > { using type = boost::multiprecision::number < boost::multiprecision::cpp_bin_float >; }; } }} // namespace boost::geometry #endif // BOOST_GEOMETRY_CORE_COORDINATE_PROMOTION_HPP