has_infinite_coordinate.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Boost.Geometry
  2. // Copyright (c) 2015-2020 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_UTIL_HAS_INFINITE_COORDINATE_HPP
  9. #define BOOST_GEOMETRY_UTIL_HAS_INFINITE_COORDINATE_HPP
  10. #include <type_traits>
  11. #include <boost/geometry/core/coordinate_type.hpp>
  12. #include <boost/geometry/util/has_nan_coordinate.hpp>
  13. #include <boost/math/special_functions/fpclassify.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. #ifndef DOXYGEN_NO_DETAIL
  17. namespace detail
  18. {
  19. struct isinf
  20. {
  21. template <typename T>
  22. static inline bool apply(T const& t)
  23. {
  24. return boost::math::isinf(t);
  25. }
  26. };
  27. } // namespace detail
  28. #endif // DOXYGEN_NO_DETAIL
  29. template <typename Point>
  30. bool has_infinite_coordinate(Point const& point)
  31. {
  32. return detail::has_coordinate_with_property
  33. <
  34. Point,
  35. detail::isinf,
  36. std::is_floating_point
  37. <
  38. typename coordinate_type<Point>::type
  39. >::value
  40. >::apply(point);
  41. }
  42. }} // namespace boost::geometry
  43. #endif // BOOST_GEOMETRY_UTIL_HAS_INFINITE_COORDINATE_HPP