Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:12:23

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2023 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // Use, modification and distribution is subject to the Boost Software License,
0006 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #ifndef BOOST_GEOMETRY_UTIL_FOR_EACH_WITH_INDEX_HPP
0010 #define BOOST_GEOMETRY_UTIL_FOR_EACH_WITH_INDEX_HPP
0011 
0012 #include <boost/range/begin.hpp>
0013 #include <boost/range/end.hpp>
0014 #include <boost/range/size_type.hpp>
0015 
0016 namespace boost { namespace geometry
0017 {
0018 
0019 #ifndef DOXYGEN_NO_DETAIL
0020 namespace detail
0021 {
0022 
0023 // Utility function to implement a Kotlin like range based for loop
0024 template <typename Container, typename Function>
0025 inline void for_each_with_index(Container const& container, Function func)
0026 {
0027     typename boost::range_size<Container>::type index = 0;
0028     for (auto it = boost::begin(container); it != boost::end(container); ++it, ++index)
0029     {
0030         func(index, *it);
0031     }
0032 }
0033 
0034 template <typename Container, typename Function>
0035 inline void for_each_with_index(Container& container, Function func)
0036 {
0037     typename boost::range_size<Container>::type index = 0;
0038     for (auto it = boost::begin(container); it != boost::end(container); ++it, ++index)
0039     {
0040         func(index, *it);
0041     }
0042 }
0043 
0044 } // namespace detail
0045 #endif // DOXYGEN_NO_DETAIL
0046 
0047 }} // namespace boost::geometry
0048 
0049 #endif // BOOST_GEOMETRY_UTIL_FOR_EACH_WITH_INDEX_HPP