has_non_finite_coordinate.hpp 1.4 KB

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