Boost.Geometry.Index
|
00001 // Boost.Geometry Index 00002 // 00003 // Insert iterator 00004 // 00005 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. 00006 // 00007 // Use, modification and distribution is subject to the Boost Software License, 00008 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 00009 // http://www.boost.org/LICENSE_1_0.txt) 00010 00011 #ifndef BOOST_GEOMETRY_INDEX_INSERTER_HPP 00012 #define BOOST_GEOMETRY_INDEX_INSERTER_HPP 00013 00014 #include <iterator> 00015 00020 namespace boost { namespace geometry { namespace index { 00021 00022 template <class Container> 00023 class insert_iterator : 00024 public std::iterator<std::output_iterator_tag, void, void, void, void> 00025 { 00026 public: 00027 typedef Container container_type; 00028 00029 inline explicit insert_iterator(Container & c) 00030 : container(&c) 00031 {} 00032 00033 insert_iterator & operator=(typename Container::value_type const& value) 00034 { 00035 container->insert(value); 00036 return *this; 00037 } 00038 00039 insert_iterator & operator* () 00040 { 00041 return *this; 00042 } 00043 00044 insert_iterator & operator++ () 00045 { 00046 return *this; 00047 } 00048 00049 insert_iterator operator++(int) 00050 { 00051 return *this; 00052 } 00053 00054 private: 00055 Container * container; 00056 }; 00057 00070 template <typename Container> 00071 insert_iterator<Container> inserter(Container & c) 00072 { 00073 return insert_iterator<Container>(c); 00074 } 00075 00076 }}} // namespace boost::geometry::index 00077 00078 #endif // BOOST_GEOMETRY_INDEX_INSERTER_HPP