num_geometries.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  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)
  10. #ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
  11. #define BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
  12. #include <cstddef>
  13. #include <boost/geometry/algorithms/not_implemented.hpp>
  14. #include <boost/geometry/core/tag.hpp>
  15. #include <boost/geometry/core/tags.hpp>
  16. #include <boost/geometry/core/tag_cast.hpp>
  17. #include <boost/geometry/geometries/concepts/check.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. #ifndef DOXYGEN_NO_DISPATCH
  21. namespace dispatch
  22. {
  23. template
  24. <
  25. typename Geometry,
  26. typename Tag = typename tag_cast
  27. <
  28. typename tag<Geometry>::type,
  29. single_tag,
  30. multi_tag
  31. >::type
  32. >
  33. struct num_geometries: not_implemented<Tag>
  34. {};
  35. template <typename Geometry>
  36. struct num_geometries<Geometry, single_tag>
  37. {
  38. static inline std::size_t apply(Geometry const&)
  39. {
  40. return 1;
  41. }
  42. };
  43. } // namespace dispatch
  44. #endif
  45. /*!
  46. \brief \brief_calc{number of geometries}
  47. \ingroup num_geometries
  48. \details \details_calc{num_geometries, number of geometries}.
  49. \tparam Geometry \tparam_geometry
  50. \param geometry \param_geometry
  51. \return \return_calc{number of geometries}
  52. \qbk{[include reference/algorithms/num_geometries.qbk]}
  53. */
  54. template <typename Geometry>
  55. inline std::size_t num_geometries(Geometry const& geometry)
  56. {
  57. concept::check<Geometry const>();
  58. return dispatch::num_geometries<Geometry>::apply(geometry);
  59. }
  60. }} // namespace boost::geometry
  61. #endif // BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP