summaryrefslogtreecommitdiff
path: root/boost/bimap/detail/map_view_iterator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/bimap/detail/map_view_iterator.hpp')
-rw-r--r--boost/bimap/detail/map_view_iterator.hpp327
1 files changed, 232 insertions, 95 deletions
diff --git a/boost/bimap/detail/map_view_iterator.hpp b/boost/bimap/detail/map_view_iterator.hpp
index 4f0e20e00a..c796a70156 100644
--- a/boost/bimap/detail/map_view_iterator.hpp
+++ b/boost/bimap/detail/map_view_iterator.hpp
@@ -28,50 +28,101 @@
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/bimap/relation/support/pair_by.hpp>
+// check
+#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
+#include <boost/bimap/relation/detail/static_access_builder.hpp>
+
namespace boost {
namespace bimaps {
namespace detail {
+/** \brief Map View Iterator adaptors from multi index to bimap.
+
+These classes are based on transform iterators from Boost.Iterator.
+ **/
+
+template< class Tag, class BimapCore > struct map_view_iterator ;
+template< class Tag, class BimapCore > struct const_map_view_iterator ;
+
+template< class Tag, class BimapCore > struct reverse_map_view_iterator ;
+template< class Tag, class BimapCore > struct const_reverse_map_view_iterator ;
+
+template< class Tag, class BimapCore > struct local_map_view_iterator ;
+template< class Tag, class BimapCore > struct const_local_map_view_iterator ;
+
+
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
-template< class Tag, class Relation, class CoreIterator > struct map_view_iterator;
+#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
+/*===========================================================================*/
+#define BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT \
+ BOOST_SERIALIZATION_SPLIT_MEMBER() \
+ \
+ friend class ::boost::serialization::access; \
+ \
+ template< class Archive > \
+ void save(Archive & ar, const unsigned int) const \
+ { \
+ ar << ::boost::serialization::make_nvp("mi_iterator",this->base()); \
+ } \
+ \
+ template< class Archive > \
+ void load(Archive & ar, const unsigned int) \
+ { \
+ BOOST_DEDUCED_TYPENAME base_::base_type iter; \
+ ar >> ::boost::serialization::make_nvp("mi_iterator",iter); \
+ this->base_reference() = iter; \
+ }
+/*===========================================================================*/
+#else
+#define BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT // None
+#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
-template< class Tag, class Relation, class CoreIterator >
-struct map_view_iterator_base
-{
- typedef iterator_adaptor
- <
- map_view_iterator< Tag, Relation, CoreIterator >,
- CoreIterator,
- BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
- pair_type_by<Tag,Relation>::type
+/*===========================================================================*/
+#define BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( METANAME, ITERATOR ) \
+BOOST_BIMAP_SYMMETRIC_STATIC_ACCESS_BUILDER( METANAME, BimapCore, \
+ typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE\
+ index<BOOST_DEDUCED_TYPENAME BimapCore::left_tag> \
+ ::type::ITERATOR type, \
+ typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE\
+ index<BOOST_DEDUCED_TYPENAME BimapCore::right_tag> \
+ ::type::ITERATOR type \
+)
+/*===========================================================================*/
- > type;
-};
-#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( core_iterator_type_by
+ , iterator )
-/** \brief Map View Iterator adaptor from multi index to bimap.
+BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( reverse_core_iterator_type_by
+ , reverse_iterator )
-This is class is based on transform iterator from Boost.Iterator that is
-modified to allow serialization. It has been specialized for this
-library, and EBO optimization was applied to the functor.
+BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( local_core_iterator_type_by
+ , local_iterator )
- **/
-template< class Tag, class Relation, class CoreIterator >
-struct map_view_iterator : public map_view_iterator_base<Tag,Relation,CoreIterator>::type
-{
- typedef BOOST_DEDUCED_TYPENAME
- map_view_iterator_base<Tag,Relation,CoreIterator>::type base_;
+// map_view_iterator
+template< class Tag, class BimapCore >
+struct map_view_iterator_adaptor {
+ typedef iterator_adaptor<
+ map_view_iterator<Tag,BimapCore>,
+ BOOST_DEDUCED_TYPENAME core_iterator_type_by<Tag,BimapCore>::type,
+ BOOST_DEDUCED_TYPENAME
+ ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
+ > type;
+};
+template< class Tag, class BimapCore >
+struct map_view_iterator :
+ public map_view_iterator_adaptor<Tag,BimapCore>::type
+{
+ typedef BOOST_DEDUCED_TYPENAME
+ map_view_iterator_adaptor<Tag,BimapCore>::type base_;
public:
map_view_iterator() {}
-
- map_view_iterator(CoreIterator const& iter)
+ map_view_iterator(BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
: base_(iter) {}
-
map_view_iterator(map_view_iterator const & iter)
: base_(iter.base()) {}
@@ -83,117 +134,203 @@ struct map_view_iterator : public map_view_iterator_base<Tag,Relation,CoreIterat
)
);
}
-
private:
-
friend class iterator_core_access;
+ BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
+};
- #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
-
- // Serialization support
-
- BOOST_SERIALIZATION_SPLIT_MEMBER()
- friend class ::boost::serialization::access;
+template< class Tag, class BimapCore >
+struct const_map_view_iterator_adaptor {
+ typedef iterator_adaptor<
+ const_map_view_iterator<Tag,BimapCore>,
+ BOOST_DEDUCED_TYPENAME core_iterator_type_by<Tag,BimapCore>::type,
+ const BOOST_DEDUCED_TYPENAME
+ ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
+ > type;
+};
+template< class Tag, class BimapCore >
+struct const_map_view_iterator :
+ public const_map_view_iterator_adaptor<Tag,BimapCore>::type
+{
+ typedef BOOST_DEDUCED_TYPENAME
+ const_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
+ public:
- template< class Archive >
- void save(Archive & ar, const unsigned int version) const
- {
- ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
- }
+ const_map_view_iterator() {}
+ const_map_view_iterator(
+ BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
+ : base_(iter) {}
+ const_map_view_iterator(const_map_view_iterator const & iter)
+ : base_(iter.base()) {}
+ const_map_view_iterator(map_view_iterator<Tag,BimapCore> i)
+ : base_(i.base()) {}
- template< class Archive >
- void load(Archive & ar, const unsigned int version)
+ BOOST_DEDUCED_TYPENAME base_::reference dereference() const
{
- CoreIterator iter;
- ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
- this->base_reference() = iter;
+ return ::boost::bimaps::relation::support::pair_by<Tag>(*this->base());
}
-
- #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
+ private:
+ friend class iterator_core_access;
+ BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
};
-#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
-
-template< class Tag, class Relation, class CoreIterator > struct const_map_view_iterator;
-
-template< class Tag, class Relation, class CoreIterator >
-struct const_map_view_iterator_base
-{
- typedef iterator_adaptor
- <
- const_map_view_iterator< Tag, Relation, CoreIterator >,
- CoreIterator,
- const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
- pair_type_by<Tag,Relation>::type
+// reverse_map_view_iterator
+template< class Tag, class BimapCore >
+struct reverse_map_view_iterator_adaptor {
+ typedef iterator_adaptor<
+ reverse_map_view_iterator<Tag,BimapCore>,
+ BOOST_DEDUCED_TYPENAME
+ reverse_core_iterator_type_by<Tag,BimapCore>::type,
+ BOOST_DEDUCED_TYPENAME
+ ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
> type;
};
+template< class Tag, class BimapCore >
+struct reverse_map_view_iterator :
+ public reverse_map_view_iterator_adaptor<Tag,BimapCore>::type
+{
+ typedef BOOST_DEDUCED_TYPENAME
+ reverse_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
+ public:
-#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
-
-
-/** \brief Const Map View Iterator adaptor from multi index to bimap.
-
-See also map_view_iterator.
- **/
+ reverse_map_view_iterator() {}
+ reverse_map_view_iterator(
+ BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
+ : base_(iter) {}
+ reverse_map_view_iterator(reverse_map_view_iterator const & iter)
+ : base_(iter.base()) {}
-template< class Tag, class Relation, class CoreIterator >
-struct const_map_view_iterator :
+ BOOST_DEDUCED_TYPENAME base_::reference dereference() const
+ {
+ return ::boost::bimaps::relation::support::pair_by<Tag>(
+ *const_cast<BOOST_DEDUCED_TYPENAME base_::base_type::value_type*>(
+ &(*this->base())
+ )
+ );
+ }
+ private:
+ friend class iterator_core_access;
+ BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
+};
- public const_map_view_iterator_base<Tag,Relation,CoreIterator>::type
+template< class Tag, class BimapCore >
+struct const_reverse_map_view_iterator_adaptor {
+ typedef iterator_adaptor<
+ const_reverse_map_view_iterator<Tag,BimapCore>,
+ BOOST_DEDUCED_TYPENAME
+ reverse_core_iterator_type_by<Tag,BimapCore>::type,
+ const BOOST_DEDUCED_TYPENAME
+ ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
+ > type;
+};
+template< class Tag, class BimapCore >
+struct const_reverse_map_view_iterator :
+ public const_reverse_map_view_iterator_adaptor<Tag,BimapCore>::type
{
- typedef BOOST_DEDUCED_TYPENAME
- const_map_view_iterator_base<Tag,Relation,CoreIterator>::type base_;
-
+ typedef BOOST_DEDUCED_TYPENAME
+ const_reverse_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
+
public:
- const_map_view_iterator() {}
-
- const_map_view_iterator(CoreIterator const& iter)
+ const_reverse_map_view_iterator() {}
+ const_reverse_map_view_iterator(
+ BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
: base_(iter) {}
-
- const_map_view_iterator(const_map_view_iterator const & iter)
+ const_reverse_map_view_iterator(const_reverse_map_view_iterator const & iter)
: base_(iter.base()) {}
-
- const_map_view_iterator(map_view_iterator<Tag,Relation,CoreIterator> i)
+ const_reverse_map_view_iterator(reverse_map_view_iterator<Tag,BimapCore> i)
: base_(i.base()) {}
BOOST_DEDUCED_TYPENAME base_::reference dereference() const
{
return ::boost::bimaps::relation::support::pair_by<Tag>(*this->base());
}
-
private:
-
friend class iterator_core_access;
+ BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
+};
- #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
- // Serialization support
+// local_map_view_iterator
- BOOST_SERIALIZATION_SPLIT_MEMBER()
+template< class Tag, class BimapCore >
+struct local_map_view_iterator_adaptor {
+ typedef iterator_adaptor<
+ local_map_view_iterator<Tag,BimapCore>,
+ BOOST_DEDUCED_TYPENAME
+ local_core_iterator_type_by<Tag,BimapCore>::type,
+ BOOST_DEDUCED_TYPENAME
+ ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
+ > type;
+};
+template< class Tag, class BimapCore >
+struct local_map_view_iterator :
+ public local_map_view_iterator_adaptor<Tag,BimapCore>::type
+{
+ typedef BOOST_DEDUCED_TYPENAME
+ local_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
+ public:
- friend class ::boost::serialization::access;
+ local_map_view_iterator() {}
+ local_map_view_iterator(
+ BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
+ : base_(iter) {}
+ local_map_view_iterator(local_map_view_iterator const & iter)
+ : base_(iter.base()) {}
- template< class Archive >
- void save(Archive & ar, const unsigned int version) const
+ BOOST_DEDUCED_TYPENAME base_::reference dereference() const
{
- ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
+ return ::boost::bimaps::relation::support::pair_by<Tag>(
+ *const_cast<BOOST_DEDUCED_TYPENAME base_::base_type::value_type*>(
+ &(*this->base())
+ )
+ );
}
+ private:
+ friend class iterator_core_access;
+ BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
+};
+
+template< class Tag, class BimapCore >
+struct const_local_map_view_iterator_adaptor {
+ typedef iterator_adaptor<
+ const_local_map_view_iterator<Tag,BimapCore>,
+ BOOST_DEDUCED_TYPENAME
+ local_core_iterator_type_by<Tag,BimapCore>::type,
+ const BOOST_DEDUCED_TYPENAME
+ ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
+ > type;
+};
+template< class Tag, class BimapCore >
+struct const_local_map_view_iterator :
+ public const_local_map_view_iterator_adaptor<Tag,BimapCore>::type
+{
+ typedef BOOST_DEDUCED_TYPENAME
+ const_local_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
+ public:
+
+ const_local_map_view_iterator() {}
+ const_local_map_view_iterator(
+ BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
+ : base_(iter) {}
+ const_local_map_view_iterator(const_local_map_view_iterator const & iter)
+ : base_(iter.base()) {}
+ const_local_map_view_iterator(local_map_view_iterator<Tag,BimapCore> i)
+ : base_(i.base()) {}
- template< class Archive >
- void load(Archive & ar, const unsigned int version)
+ BOOST_DEDUCED_TYPENAME base_::reference dereference() const
{
- CoreIterator iter;
- ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
- this->base_reference() = iter;
+ return ::boost::bimaps::relation::support::pair_by<Tag>(*this->base());
}
-
- #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
+ private:
+ friend class iterator_core_access;
+ BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
};
+#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
} // namespace detail
} // namespace bimaps