diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/geometry/algorithms/num_geometries.hpp | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/geometry/algorithms/num_geometries.hpp')
-rw-r--r-- | boost/geometry/algorithms/num_geometries.hpp | 103 |
1 files changed, 74 insertions, 29 deletions
diff --git a/boost/geometry/algorithms/num_geometries.hpp b/boost/geometry/algorithms/num_geometries.hpp index 20f35e90d2..d37d0bfabe 100644 --- a/boost/geometry/algorithms/num_geometries.hpp +++ b/boost/geometry/algorithms/num_geometries.hpp @@ -1,8 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -17,7 +22,12 @@ #include <cstddef> -#include <boost/mpl/assert.hpp> +#include <boost/range.hpp> +#include <boost/variant/static_visitor.hpp> +#include <boost/variant/apply_visitor.hpp> +#include <boost/variant/variant_fwd.hpp> + +#include <boost/geometry/algorithms/not_implemented.hpp> #include <boost/geometry/core/tag.hpp> #include <boost/geometry/core/tags.hpp> @@ -25,6 +35,8 @@ #include <boost/geometry/geometries/concepts/check.hpp> +#include <boost/geometry/algorithms/detail/counting.hpp> + namespace boost { namespace geometry { @@ -35,30 +47,74 @@ namespace dispatch { -template <typename Tag, typename Geometry> -struct num_geometries +template +< + typename Geometry, + typename Tag = typename tag_cast + < + typename tag<Geometry>::type, + single_tag, + multi_tag + >::type +> +struct num_geometries: not_implemented<Tag> +{}; + + +template <typename Geometry> +struct num_geometries<Geometry, single_tag> + : detail::counting::other_count<1> +{}; + + +template <typename MultiGeometry> +struct num_geometries<MultiGeometry, multi_tag> { - BOOST_MPL_ASSERT_MSG - ( - false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE - , (types<Geometry>) - ); + static inline std::size_t apply(MultiGeometry const& multi_geometry) + { + return boost::size(multi_geometry); + } }; +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +namespace resolve_variant +{ + template <typename Geometry> -struct num_geometries<single_tag, Geometry> +struct num_geometries { - static inline std::size_t apply(Geometry const&) + static inline std::size_t apply(Geometry const& geometry) { - return 1; + concept::check<Geometry const>(); + + return dispatch::num_geometries<Geometry>::apply(geometry); } }; +template <BOOST_VARIANT_ENUM_PARAMS(typename T)> +struct num_geometries<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> > +{ + struct visitor: boost::static_visitor<std::size_t> + { + template <typename Geometry> + inline std::size_t operator()(Geometry const& geometry) const + { + return num_geometries<Geometry>::apply(geometry); + } + }; + + static inline std::size_t + apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry) + { + return boost::apply_visitor(visitor(), geometry); + } +}; - -} // namespace dispatch -#endif +} // namespace resolve_variant /*! @@ -74,18 +130,7 @@ struct num_geometries<single_tag, Geometry> template <typename Geometry> inline std::size_t num_geometries(Geometry const& geometry) { - concept::check<Geometry const>(); - - return dispatch::num_geometries - < - typename tag_cast - < - typename tag<Geometry>::type, - single_tag, - multi_tag - >::type, - Geometry - >::apply(geometry); + return resolve_variant::num_geometries<Geometry>::apply(geometry); } |