select_calculation_type.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2014.
  6. // Modifications copyright (c) 2014 Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_UTIL_SELECT_CALCULATION_TYPE_HPP
  14. #define BOOST_GEOMETRY_UTIL_SELECT_CALCULATION_TYPE_HPP
  15. #include <boost/mpl/if.hpp>
  16. #include <boost/type_traits/is_void.hpp>
  17. #include <boost/geometry/util/select_coordinate_type.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. /*!
  21. \brief Meta-function selecting the "calculation" type
  22. \details Based on two input geometry types, and an input calculation type,
  23. (which defaults to void in the calling function), this meta-function
  24. selects the most appropriate:
  25. - if calculation type is specified, that one is used,
  26. - if it is void, the most precise of the two points is used
  27. \ingroup utility
  28. */
  29. template <typename Geometry1, typename Geometry2, typename CalculationType>
  30. struct select_calculation_type
  31. {
  32. typedef typename
  33. boost::mpl::if_
  34. <
  35. boost::is_void<CalculationType>,
  36. typename select_coordinate_type
  37. <
  38. Geometry1,
  39. Geometry2
  40. >::type,
  41. CalculationType
  42. >::type type;
  43. };
  44. // alternative version supporting more than 2 Geometries
  45. template <typename CalculationType,
  46. typename Geometry1,
  47. typename Geometry2 = void,
  48. typename Geometry3 = void>
  49. struct select_calculation_type_alt
  50. {
  51. typedef typename
  52. boost::mpl::if_
  53. <
  54. boost::is_void<CalculationType>,
  55. typename select_coordinate_type
  56. <
  57. Geometry1,
  58. Geometry2,
  59. Geometry3
  60. >::type,
  61. CalculationType
  62. >::type type;
  63. };
  64. }} // namespace boost::geometry
  65. #endif // BOOST_GEOMETRY_UTIL_SELECT_CALCULATION_TYPE_HPP