From 25ad304fa720e7857dacbc1041da53ee6576eaab Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 7 May 2022 16:19:58 +0200 Subject: [PATCH] [views] Add geometry_collection_view. --- .../views/detail/geometry_collection_view.hpp | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 include/boost/geometry/views/detail/geometry_collection_view.hpp diff --git a/include/boost/geometry/views/detail/geometry_collection_view.hpp b/include/boost/geometry/views/detail/geometry_collection_view.hpp new file mode 100644 index 000000000..be3c29471 --- /dev/null +++ b/include/boost/geometry/views/detail/geometry_collection_view.hpp @@ -0,0 +1,84 @@ +// Boost.Geometry + +// Copyright (c) 2022, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_VIEWS_GEOMETRY_COLLECTION_VIEW_HPP +#define BOOST_GEOMETRY_VIEWS_GEOMETRY_COLLECTION_VIEW_HPP + +#include + +#include +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace detail +{ + + +template +class geometry_collection_view +{ +public: + using iterator = Geometry const*; + using const_iterator = Geometry const*; + + explicit geometry_collection_view(Geometry const& geometry) + : m_geometry(geometry) + {} + + const_iterator begin() const { return boost::addressof(m_geometry); } + const_iterator end() const { return boost::addressof(m_geometry) + 1; } + +private: + Geometry const& m_geometry; +}; + +} // namespace detail + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag> +{ + using type = geometry_collection_tag; +}; + + +template +struct geometry_types> +{ + using type = util::type_sequence; +}; + + +template +struct iter_visit> +{ + template + static void apply(Function && function, Iterator iterator) + { + function(*iterator); + } +}; + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_VIEWS_GEOMETRY_COLLECTION_VIEW_HPP