Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

431
test/external/boost/bimap/bimap.hpp vendored Normal file
View File

@@ -0,0 +1,431 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file bimap.hpp
/// \brief Includes the basic bimap container
/** \mainpage notitle
\n
\image html http://matias.capeletto.googlepages.com/boost.bimap.reference.logo.png
\section Introduction
This is the complete reference of Boost.Bimap.
After getting a good understanding of the library from a user perspective
the next step will be:
- Understand the tagged idiom. (boost::bimaps::tags)
- Understand the internals of the relation class (boost::bimaps::relation)
- Read the container_adaptor toolbox docs (boost::bimaps::container_adaptor)
- Understand the internals of the bimap class. (boost::bimaps, boost::bimaps::views
and boost::bimaps::detail)
**/
/** \defgroup mutant_group mutant idiom
\brief A safe wrapper around reinterpret_cast
**/
/** \defgroup relation_group relation
\brief The relation
**/
/** \defgroup tags_group tagged idiom
\brief The tagged idiom
**/
#ifndef BOOST_BIMAP_BIMAP_HPP
#define BOOST_BIMAP_BIMAP_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <boost/mpl/aux_/na.hpp>
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
#include <boost/serialization/nvp.hpp>
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
// Boost.Bimap
#include <boost/bimap/detail/bimap_core.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
#include <boost/bimap/detail/modifier_adaptor.hpp>
#include <boost/bimap/relation/support/data_extractor.hpp>
#include <boost/bimap/relation/support/member_with_tag.hpp>
#include <boost/bimap/support/map_type_by.hpp>
#include <boost/bimap/support/map_by.hpp>
#include <boost/bimap/support/iterator_type_by.hpp>
/// \brief The namespace where all the boost libraries lives.
namespace boost {
/// \brief Boost.Bimap library namespace
/**
All the entities in the library are defined in this namespace.
**/
namespace bimaps {
/// \brief The bimap class is the entry point to the library.
/**
This class manages the instantiation of the desired bimap type.
As there are several types of bidirectional maps that can be
created using it. the main job of it is to find the desired
type. This is done using metaprogramming to obtain the relation
type that will be stored, the map_view type of each side and
the set_view type of the general relationship. The instantiation
is kept simple using an extended standard set theory, where a
bidirectional map type is defined by the set types it relates.
For example, a bidirectional map that has multimap semantics
viewed from both sides is defined by specifying that the two
keys sets are of \c multiset_of<Key> type.
This allows the bimap class to support seamingless N-N, 1-N,
ordered/unordered and even vector-list types of mapping.
The three last parameters are used to specify the set type of
the relation, an inplace hooked data class and the allocator
type. As a help to the bimap user, these parameters support
default types but use a special idiom that allow them to be
specified without interleaving the usual use_default keyword.
The possible bimap instantiation are enumerated here:
\c {Side}KeyType can be directly a type, this is default to
\c set_of<{Side}KeyType>, or can be a \c {SetType}_of<Type>
specification. Additionally this two parameters can be tagged
to specify others tags instead of the usual \c member_at::{Side}
ones.
\code
typedef bimap
<
LeftCollectionType, RightCollectionType
[ , SetTypeOfRelation ] // Default to left_based
[ , info_hook< Info > ] // Default to no info
[ , Allocator ] // Default to std::allocator<>
> bm;
\endcode
**/
template
<
class KeyTypeA, class KeyTypeB,
class AP1 = ::boost::mpl::na,
class AP2 = ::boost::mpl::na,
class AP3 = ::boost::mpl::na
>
class bimap
:
// Bimap Core, use mpl magic to find the desired bimap type
public ::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>,
// You can use bimap as a collection of relations
public ::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>
::relation_set,
// Include extra typedefs (i.e. left_local_iterator for unordered_map)
public ::boost::bimaps::detail:: left_map_view_extra_typedefs<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::left_map_view_type<
::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>
>::type
>,
public ::boost::bimaps::detail::right_map_view_extra_typedefs<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::right_map_view_type<
::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>
>::type
>
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3> base_;
BOOST_DEDUCED_TYPENAME base_::core_type core;
public:
// metadata --------------------------------------------------------
/*
// The rest is computed in the core, because it is quite difficult to
// expose a nice interface with so many metaprogramming stuff.
// Here it is the complete metadat list.
// Map by {side} metadata
typedef -unspecified- {side}_tag;
typedef -unspecified- {side}_data_type;
typedef -unspecified- {side}_value_type;
typedef -unspecified- {side}_key_type;
typedef -unspecified- {side}_iterator;
typedef -unspecified- {side}_const_iterator;
------------------------------------------------------------------*/
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
left_map_view_type<base_>::type left_map;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
right_map_view_type<base_>::type right_map;
typedef BOOST_DEDUCED_TYPENAME
left_map::reference left_reference;
typedef BOOST_DEDUCED_TYPENAME
left_map::const_reference left_const_reference;
typedef BOOST_DEDUCED_TYPENAME
right_map::reference right_reference;
typedef BOOST_DEDUCED_TYPENAME
right_map::const_reference right_const_reference;
typedef BOOST_DEDUCED_TYPENAME base_::relation::info_type info_type;
typedef BOOST_DEDUCED_TYPENAME base_::core_type::allocator_type allocator_type;
/// Left map view
left_map left;
/// Right map view
right_map right;
typedef BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag
logic_relation_set_tag;
typedef BOOST_DEDUCED_TYPENAME base_::logic_left_tag logic_left_tag;
typedef BOOST_DEDUCED_TYPENAME base_::logic_right_tag logic_right_tag;
typedef BOOST_DEDUCED_TYPENAME base_::core_type::ctor_args_list
ctor_args_list;
bimap(const allocator_type& al = allocator_type()) :
base_::relation_set(
::boost::multi_index::get<
logic_relation_set_tag
>(core)
),
core(al),
left (
::boost::multi_index::get<
logic_left_tag
>(core)
),
right (
::boost::multi_index::get<
logic_right_tag
>(core)
)
{}
template< class InputIterator >
bimap(InputIterator first,InputIterator last,
const allocator_type& al = allocator_type()) :
base_::relation_set(
::boost::multi_index::get<logic_relation_set_tag>(core)
),
core(first,last,ctor_args_list(),al),
left (
::boost::multi_index::get<logic_left_tag>(core)
),
right (
::boost::multi_index::get<logic_right_tag>(core)
)
{}
bimap(const bimap& x) :
base_::relation_set(
::boost::multi_index::get<logic_relation_set_tag>(core)
),
core(x.core),
left (
::boost::multi_index::get<logic_left_tag>(core)
),
right (
::boost::multi_index::get<logic_right_tag>(core)
)
{}
bimap& operator=(const bimap& x)
{
core = x.core;
return *this;
}
// Projection of iterators
template< class IteratorType >
BOOST_DEDUCED_TYPENAME base_::left_iterator
project_left(IteratorType iter)
{
return core.template project<
BOOST_DEDUCED_TYPENAME base_::logic_left_tag>(iter.base());
}
template< class IteratorType >
BOOST_DEDUCED_TYPENAME base_::left_const_iterator
project_left(IteratorType iter) const
{
return core.template project<
BOOST_DEDUCED_TYPENAME base_::logic_left_tag>(iter.base());
}
template< class IteratorType >
BOOST_DEDUCED_TYPENAME base_::right_iterator
project_right(IteratorType iter)
{
return core.template project<
BOOST_DEDUCED_TYPENAME base_::logic_right_tag>(iter.base());
}
template< class IteratorType >
BOOST_DEDUCED_TYPENAME base_::right_const_iterator
project_right(IteratorType iter) const
{
return core.template project<
BOOST_DEDUCED_TYPENAME base_::logic_right_tag>(iter.base());
}
template< class IteratorType >
BOOST_DEDUCED_TYPENAME base_::relation_set::iterator
project_up(IteratorType iter)
{
return core.template project<
BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag>(iter.base());
}
template< class IteratorType >
BOOST_DEDUCED_TYPENAME base_::relation_set::const_iterator
project_up(IteratorType iter) const
{
return core.template project<
BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag>(iter.base());
}
// Support for tags
template< class Tag, class IteratorType >
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
iterator_type_by<Tag,bimap>::type
project(IteratorType iter
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag))
{
return core.template project<Tag>(iter.base());
}
template< class Tag, class IteratorType >
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
const_iterator_type_by<Tag,bimap>::type
project(IteratorType iter
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Tag)) const
{
return core.template project<Tag>(iter.base());
}
template< class Tag >
struct map_by :
public ::boost::bimaps::support::map_type_by<Tag,bimap>::type
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
map_type_by<Tag,bimap>::type type;
private: map_by() {}
};
template< class Tag >
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
map_type_by<Tag,bimap>::type &
by(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag))
{
return ::boost::bimaps::support::map_by<Tag>(*this);
}
template< class Tag >
const BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
map_type_by<Tag,bimap>::type &
by(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag)) const
{
return ::boost::bimaps::support::map_by<Tag>(*this);
}
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
// Serialization support
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & serialization::make_nvp("mi_core",core);
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
} // namespace bimaps
} // namespace boost
/** \namespace boost::bimaps::support
\brief Metafunctions to help working with bimaps.
**/
/** \namespace boost::bimaps::views
\brief Bimap views.
**/
/** \namespace boost::bimaps::views::detail
\brief Bimap views details.
**/
// Include basic tools for user commodity
#include <boost/bimap/tags/tagged.hpp>
#include <boost/bimap/relation/member_at.hpp>
#include <boost/multi_index/detail/unbounded.hpp>
// Bring the most used namespaces directly to the user main namespace
namespace boost {
namespace bimaps {
using ::boost::bimaps::tags::tagged;
namespace member_at = ::boost::bimaps::relation::member_at;
using ::boost::multi_index::unbounded;
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_BIMAP_HPP

View File

@@ -0,0 +1,287 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/associative_container_adaptor.hpp
/// \brief Container adaptor to build a type that is compliant to the concept of an associative container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <utility>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/bimap/container_adaptor/detail/identity_converters.hpp>
#include <boost/bimap/container_adaptor/container_adaptor.hpp>
#include <boost/call_traits.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template
<
class Base, class Iterator, class ConstIterator, class KeyType,
class IteratorToBaseConverter, class IteratorFromBaseConverter,
class ValueToBaseConverter, class ValueFromBaseConverter, class KeyToBaseConverter,
class FunctorsFromDerivedClasses
>
struct associative_container_adaptor_base
{
typedef container_adaptor
<
Base,
Iterator, ConstIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ValueToBaseConverter , ValueFromBaseConverter,
BOOST_DEDUCED_TYPENAME mpl::push_front<
FunctorsFromDerivedClasses,
BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<KeyToBaseConverter>,
// {
detail::key_to_base_identity
<
BOOST_DEDUCED_TYPENAME Base::key_type, KeyType
>,
// }
// else
// {
KeyToBaseConverter
// }
>::type
>::type
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Container adaptor to build a type that is compliant to the concept of an associative container.
template
<
class Base,
class Iterator,
class ConstIterator,
class KeyType,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class associative_container_adaptor :
public associative_container_adaptor_base
<
Base, Iterator, ConstIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
FunctorsFromDerivedClasses
>::type
{
// MetaData -------------------------------------------------------------
typedef typename associative_container_adaptor_base
<
Base, Iterator, ConstIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
FunctorsFromDerivedClasses
>::type base_;
public:
typedef KeyType key_type;
protected:
typedef BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<KeyToBaseConverter>,
// {
detail::key_to_base_identity
<
BOOST_DEDUCED_TYPENAME Base::key_type, KeyType
>,
// }
// else
// {
KeyToBaseConverter
// }
>::type key_to_base;
public:
explicit associative_container_adaptor(Base & c)
: base_(c) {}
protected:
typedef associative_container_adaptor associative_container_adaptor_;
// Interface --------------------------------------------------------------
public:
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::size_type erase(const CompatibleKey & k)
{
return this->base().erase
(
this->template functor<key_to_base>()(k)
);
}
// As we redefine erase, the other overloads need to be manually routed
BOOST_DEDUCED_TYPENAME base_::iterator erase(
BOOST_DEDUCED_TYPENAME base_::iterator pos)
{
return base_::container_adaptor_::erase(pos);
}
BOOST_DEDUCED_TYPENAME base_::iterator erase(
BOOST_DEDUCED_TYPENAME base_::iterator first,
BOOST_DEDUCED_TYPENAME base_::iterator last)
{
return base_::container_adaptor_::erase(first,last);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::size_type count(const CompatibleKey & k) const
{
return this->base().count(
this->template functor<key_to_base>()(k)
);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::iterator find(const CompatibleKey & k)
{
return this->template functor<typename base_::iterator_from_base>()
(
this->base().find(
this->template functor<key_to_base>()(k)
)
);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::const_iterator
find(const CompatibleKey & k) const
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()
(
this->base().find(
this->template functor<key_to_base>()(k)
)
);
}
template< class CompatibleKey >
std::pair
<
BOOST_DEDUCED_TYPENAME base_::iterator,
BOOST_DEDUCED_TYPENAME base_::iterator
>
equal_range(const CompatibleKey & k)
{
std::pair<
BOOST_DEDUCED_TYPENAME Base::iterator,
BOOST_DEDUCED_TYPENAME Base::iterator
> r( this->base().equal_range(
this->template functor<key_to_base>()(k)
)
);
return std::pair
<
BOOST_DEDUCED_TYPENAME base_::iterator,
BOOST_DEDUCED_TYPENAME base_::iterator
>(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base
>() ( r.first ),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base
>() ( r.second )
);
}
template< class CompatibleKey >
std::pair
<
BOOST_DEDUCED_TYPENAME base_::const_iterator,
BOOST_DEDUCED_TYPENAME base_::const_iterator
>
equal_range(const CompatibleKey & k) const
{
std::pair<
BOOST_DEDUCED_TYPENAME Base::const_iterator,
BOOST_DEDUCED_TYPENAME Base::const_iterator
> r( this->base().equal_range(
this->template functor<key_to_base>()(k)
)
);
return std::pair
<
BOOST_DEDUCED_TYPENAME base_::const_iterator,
BOOST_DEDUCED_TYPENAME base_::const_iterator
>(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base
>() ( r.first ),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base
>() ( r.second )
);
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP

View File

@@ -0,0 +1,291 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/container_adaptor.hpp
/// \brief Container adaptor to build a type that is compliant to the concept of a container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_CONTAINER_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_CONTAINER_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <utility>
#include <boost/mpl/if.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/bimap/container_adaptor/detail/identity_converters.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/bimap/container_adaptor/detail/functor_bag.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/copy.hpp>
#include <boost/mpl/front_inserter.hpp>
#include <boost/call_traits.hpp>
namespace boost {
namespace bimaps {
/// \brief Container Adaptor toolbox, easy way to build new containers from existing ones.
namespace container_adaptor {
/// \brief Container adaptor to build a type that is compliant to the concept of a container.
template
<
class Base,
class Iterator,
class ConstIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class container_adaptor
{
// MetaData -------------------------------------------------------------
public:
typedef Iterator iterator;
typedef ConstIterator const_iterator;
typedef BOOST_DEDUCED_TYPENAME iterator_value < iterator >::type value_type;
typedef BOOST_DEDUCED_TYPENAME iterator_pointer < iterator >::type pointer;
typedef BOOST_DEDUCED_TYPENAME iterator_reference< iterator >::type reference;
typedef BOOST_DEDUCED_TYPENAME iterator_reference< const_iterator >::type const_reference;
typedef BOOST_DEDUCED_TYPENAME Base::size_type size_type;
typedef BOOST_DEDUCED_TYPENAME Base::difference_type difference_type;
typedef BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<IteratorToBaseConverter>,
// {
::boost::bimaps::container_adaptor::detail::
iterator_to_base_identity
<
BOOST_DEDUCED_TYPENAME Base::iterator , iterator,
BOOST_DEDUCED_TYPENAME Base::const_iterator , const_iterator
>,
// }
// else
// {
IteratorToBaseConverter
// }
>::type iterator_to_base;
typedef BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<IteratorFromBaseConverter>,
// {
::boost::bimaps::container_adaptor::detail::
iterator_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::iterator , iterator,
BOOST_DEDUCED_TYPENAME Base::const_iterator , const_iterator
>,
// }
// else
// {
IteratorFromBaseConverter
// }
>::type iterator_from_base;
typedef BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<ValueToBaseConverter>,
// {
::boost::bimaps::container_adaptor::detail::
value_to_base_identity
<
BOOST_DEDUCED_TYPENAME Base::value_type,
value_type
>,
// }
// else
// {
ValueToBaseConverter
// }
>::type value_to_base;
typedef BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<ValueFromBaseConverter>,
// {
::boost::bimaps::container_adaptor::detail::
value_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::value_type,
value_type
>,
// }
// else
// {
ValueFromBaseConverter
// }
>::type value_from_base;
// ACCESS -----------------------------------------------------------------
public:
explicit container_adaptor(Base & c) : dwfb(c) {}
protected:
typedef Base base_type;
typedef container_adaptor container_adaptor_;
const Base & base() const { return dwfb.data; }
Base & base() { return dwfb.data; }
// Interface --------------------------------------------------------------
public:
size_type size() const { return base().size(); }
size_type max_size() const { return base().max_size(); }
bool empty() const { return base().empty(); }
iterator begin()
{
return this->template functor<iterator_from_base>()( base().begin() );
}
iterator end()
{
return this->template functor<iterator_from_base>()( base().end() );
}
const_iterator begin() const
{
return this->template functor<iterator_from_base>()( base().begin() );
}
const_iterator end() const
{
return this->template functor<iterator_from_base>()( base().end() );
}
iterator erase(iterator pos)
{
return this->template functor<iterator_from_base>()(
base().erase(this->template functor<iterator_to_base>()(pos))
);
}
iterator erase(iterator first, iterator last)
{
return this->template functor<iterator_from_base>()(
base().erase(
this->template functor<iterator_to_base>()(first),
this->template functor<iterator_to_base>()(last)
)
);
}
void clear()
{
base().clear();
}
template< class InputIterator >
void insert(InputIterator iterBegin, InputIterator iterEnd)
{
for( ; iterBegin != iterEnd ; ++iterBegin )
{
base().insert( this->template
functor<value_to_base>()( *iterBegin )
);
}
}
std::pair<iterator, bool> insert(
BOOST_DEDUCED_TYPENAME ::boost::call_traits< value_type >::param_type x)
{
std::pair< BOOST_DEDUCED_TYPENAME Base::iterator, bool > r(
base().insert( this->template functor<value_to_base>()(x) )
);
return std::pair<iterator, bool>( this->template
functor<iterator_from_base>()(r.first),r.second
);
}
iterator insert(iterator pos,
BOOST_DEDUCED_TYPENAME ::boost::call_traits< value_type >::param_type x)
{
return this->template functor<iterator_from_base>()(
base().insert(
this->template functor<iterator_to_base>()(pos),
this->template functor<value_to_base>()(x))
);
}
void swap( container_adaptor & c )
{
base().swap( c.base() );
}
// Access to functors ----------------------------------------------------
protected:
template< class Functor >
Functor & functor()
{
return dwfb.template functor<Functor>();
}
template< class Functor >
Functor const & functor() const
{
return dwfb.template functor<Functor>();
}
// Data ------------------------------------------------------------------
private:
::boost::bimaps::container_adaptor::detail::data_with_functor_bag
<
Base &,
BOOST_DEDUCED_TYPENAME mpl::copy
<
mpl::vector
<
iterator_to_base,
iterator_from_base,
value_to_base,
value_from_base
>,
mpl::front_inserter< FunctorsFromDerivedClasses >
>::type
> dwfb;
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_CONTAINER_ADAPTOR_HPP

View File

@@ -0,0 +1,101 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/detail/comparison_adaptor.hpp
/// \brief Comparison adaptor.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/call_traits.hpp>
#include <functional>
namespace boost {
namespace bimaps {
namespace container_adaptor {
namespace detail {
/// \brief Comparison adaptor
/**
A simple comparison adaptor.
**/
template < class Compare, class NewType, class Converter >
struct comparison_adaptor : std::binary_function<NewType,NewType,bool>
{
comparison_adaptor( const Compare & comp, const Converter & conv)
: compare(comp), converter(conv) {}
bool operator()( BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type x,
BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type y) const
{
return compare( converter(x), converter(y) );
}
private:
Compare compare;
Converter converter;
};
template < class Compare, class NewType, class Converter >
struct compatible_comparison_adaptor : std::binary_function<NewType,NewType,bool>
{
compatible_comparison_adaptor( const Compare & comp, const Converter & conv)
: compare(comp), converter(conv) {}
template< class CompatibleTypeLeft, class CompatibleTypeRight >
bool operator()( const CompatibleTypeLeft & x,
const CompatibleTypeRight & y) const
{
return compare( converter(x), converter(y) );
}
private:
Compare compare;
Converter converter;
};
/// \brief Unary Check adaptor
/**
A simple unary check adaptor.
**/
template < class Compare, class NewType, class Converter >
struct unary_check_adaptor : std::unary_function<NewType,bool>
{
unary_check_adaptor( const Compare & comp, const Converter & conv ) :
compare(comp), converter(conv) {}
bool operator()( BOOST_DEDUCED_TYPENAME call_traits<NewType>::param_type x) const
{
return compare( converter(x) );
}
private:
Compare compare;
Converter converter;
};
} // namespace detail
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_COMPARISON_ADAPTOR_HPP

View File

@@ -0,0 +1,100 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/detail/functor_bag.hpp
/// \brief Defines a EBO optimizacion helper for functors.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_FUNCTOR_BAG_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_FUNCTOR_BAG_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
// This bogus warning will appear when add_const is applied to a
// const volatile reference because we can't detect const volatile
// references with MSVC6.
# pragma warning(push)
# pragma warning(disable:4181)
// warning C4181: qualifier applied to reference type ignored
#endif
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/mpl/inherit_linearly.hpp>
#include <boost/mpl/inherit.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
namespace detail {
/// \brief EBO optimizacion helper for functors
/**
This class is a generalization of a helper class explained in an article by
Nathan C. Myers.\n
See it at \link http://www.cantrip.org/emptyopt.html
**/
template < class Data, class FunctorList >
struct data_with_functor_bag :
public mpl::inherit_linearly<
FunctorList,
mpl::if_< is_base_of< mpl::_2, mpl::_1 >,
// {
mpl::_1,
// }
// else
// {
mpl::inherit< mpl::_1, mpl::_2 >
// }
>
>::type
{
Data data;
data_with_functor_bag() {}
data_with_functor_bag(BOOST_DEDUCED_TYPENAME add_reference<Data>::type d)
: data(d) {}
template< class Functor >
Functor& functor()
{
return *(static_cast<Functor*>(this));
}
template< class Functor >
const Functor& functor() const
{
return *(static_cast<Functor const *>(this));
}
};
} // namespace detail
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_FUNCTOR_BAG_HPP

View File

@@ -0,0 +1,191 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/detail/identity_converters.hpp
/// \brief Value and iterators identity converters.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Details of the container adaptor toolbox
namespace detail {
/// \brief Iterator identity converter used by default in container adaptors.
/**
If Iterator and ConstIterator are of the same type one of the convert function is not
included.
**/
template
<
class BaseIterator , class Iterator,
class BaseConstIterator , class ConstIterator
>
struct iterator_to_base_identity
{
BaseIterator operator()(Iterator iter) const
{
return BaseIterator(iter);
}
BaseConstIterator operator()(ConstIterator iter) const
{
return BaseConstIterator(iter);
}
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class BaseIterator, class Iterator >
struct iterator_to_base_identity<BaseIterator,Iterator,BaseIterator,Iterator>
{
BaseIterator operator()(Iterator iter) const
{
return BaseIterator(iter);
}
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Iterator from base identity converter used by default in container adaptors.
/**
If Iterator and ConstIterator are of the same type one of the convert function is not
included.
**/
template
<
class BaseIterator , class Iterator,
class BaseConstIterator , class ConstIterator
>
struct iterator_from_base_identity
{
Iterator operator()(BaseIterator iter) const
{
return Iterator(iter);
}
ConstIterator operator()(BaseConstIterator iter) const
{
return ConstIterator(iter);
}
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class BaseIterator, class Iterator, class ConstIterator >
struct iterator_from_base_identity<BaseIterator,Iterator,BaseIterator,ConstIterator>
{
Iterator operator()(BaseIterator iter) const
{
return Iterator(iter);
}
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Value to base identity converter used by default in container adaptors.
template< class BaseValue, class Value >
struct value_to_base_identity
{
BaseValue operator()(const Value & val) const
{
return BaseValue(val);
}
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Value >
struct value_to_base_identity< Value, Value >
{
const Value & operator()(const Value & val) const
{
return val;
}
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Value from base identity converter used by default in container adaptors.
template< class BaseValue, class Value >
struct value_from_base_identity
{
Value operator()(const BaseValue & val) const
{
return Value(val);
}
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Value >
struct value_from_base_identity<Value,Value>
{
Value & operator()(Value & val) const
{
return val;
}
const Value & operator()(const Value & val) const
{
return val;
}
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Key to base identity converter used by default in container adaptors.
template< class BaseKey, class Key >
struct key_to_base_identity
{
BaseKey operator()(const Key & k) const
{
return BaseKey(k);
}
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Key >
struct key_to_base_identity< Key, Key >
{
// As default accept any type as key in order to allow container
// adaptors to work with compatible key types
template< class CompatibleKey >
const CompatibleKey & operator()(const CompatibleKey & k) const
{
return k;
}
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
} // namespace detail
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP

View File

@@ -0,0 +1,45 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/detail/key_extractor.hpp
/// \brief Key extractor for a pair<Key,Data>.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <functional>
namespace boost {
namespace bimaps {
namespace container_adaptor {
namespace detail {
/// \brief Key Extractor
template < class T >
struct key_from_pair_extractor
: std::unary_function< T, BOOST_DEDUCED_TYPENAME T::first_type >
{
bool operator()( const T & p ) { return p.first; }
};
} // namespace detail
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP

View File

@@ -0,0 +1,62 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/detail/non_unique_container_helper.hpp
/// \brief Details for non unique containers
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_NON_UNIQUE_CONTAINER_HELPER_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_NON_UNIQUE_CONTAINER_HELPER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
/*****************************************************************************/
#define BOOST_BIMAP_NON_UNIQUE_CONTAINER_ADAPTOR_INSERT_FUNCTIONS \
\
template <class InputIterator> \
void insert(InputIterator iterBegin, InputIterator iterEnd) \
{ \
for( ; iterBegin != iterEnd ; ++iterBegin ) \
{ \
this->base().insert( \
this->template functor< \
BOOST_DEDUCED_TYPENAME base_::value_to_base>()( \
BOOST_DEDUCED_TYPENAME base_::value_type(*iterBegin)) ); \
} \
} \
\
BOOST_DEDUCED_TYPENAME base_::iterator insert( \
BOOST_DEDUCED_TYPENAME ::boost::call_traits< \
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x) \
{ \
return this->base().insert( this->template functor< \
BOOST_DEDUCED_TYPENAME base_:: \
value_to_base>()(x) ); \
} \
\
BOOST_DEDUCED_TYPENAME base_::iterator \
insert(BOOST_DEDUCED_TYPENAME base_::iterator pos, \
BOOST_DEDUCED_TYPENAME ::boost::call_traits< \
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x) \
{ \
return this->template functor< \
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()( \
this->base().insert(this->template functor< \
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(pos), \
this->template functor< \
BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x)) \
); \
}
/*****************************************************************************/
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_NON_UNIQUE_CONTAINER_HELPER_HPP

View File

@@ -0,0 +1,249 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/list_adaptor.hpp
/// \brief Container adaptor to easily build a std::list signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/sequence_container_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/call_traits.hpp>
#include <functional>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::list signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class list_adaptor :
public ::boost::bimaps::container_adaptor::sequence_container_adaptor
<
Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::sequence_container_adaptor
<
Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
> base_;
// Access -----------------------------------------------------------------
public:
explicit list_adaptor(Base & c) :
base_(c) {}
protected:
typedef list_adaptor list_adaptor_;
// Interface -------------------------------------------------------------
public:
void splice(Iterator position, list_adaptor & x)
{
this->base().splice(
this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()
(position),
x.base()
);
}
void splice(Iterator position, list_adaptor & x, Iterator i)
{
this->base().splice(
this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()
(position),
x.base(),
this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
);
}
void splice(Iterator position, list_adaptor & x,
Iterator first, Iterator last)
{
this->base().splice(
this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()
(position),
x.base(),
this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
);
}
void remove(
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type
>::param_type value
)
{
this->base().remove(
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_to_base>()(value)
);
}
template< class Predicate >
void remove_if(Predicate pred)
{
this->base().remove_if(
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
Predicate,
BOOST_DEDUCED_TYPENAME Base::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( pred, this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
void unique()
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::equal_to<BOOST_DEDUCED_TYPENAME base_::value_type>,
BOOST_DEDUCED_TYPENAME Base::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>(
std::equal_to<BOOST_DEDUCED_TYPENAME base_::value_type>(),
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>()
)
);
}
template< class BinaryPredicate >
void unique(BinaryPredicate binary_pred)
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
BinaryPredicate,
BOOST_DEDUCED_TYPENAME Base::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( binary_pred,
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
void merge(list_adaptor & x)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>,
BOOST_DEDUCED_TYPENAME Base::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>(
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>(),
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>()
)
);
}
template< class Compare >
void merge(list_adaptor & x, Compare comp)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME Base::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( comp, this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
void sort()
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>,
BOOST_DEDUCED_TYPENAME Base::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>(
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>(),
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>()
)
);
}
template< class Compare >
void sort(Compare comp)
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME Base::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( comp, this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
void reverse()
{
this->base().reverse();
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP

View File

@@ -0,0 +1,282 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/list_map_adaptor.hpp
/// \brief Container adaptor.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_MAP_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_MAP_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/bimap/container_adaptor/list_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/identity_converters.hpp>
#include <boost/bimap/container_adaptor/detail/key_extractor.hpp>
#include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/if.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template
<
class Base, class Iterator, class ConstIterator,
class ReverseIterator, class ConstReverseIterator,
class IteratorToBaseConverter, class IteratorFromBaseConverter,
class ReverseIteratorFromBaseConverter,
class ValueToBaseConverter, class ValueFromBaseConverter,
class KeyFromBaseValueConverter,
class FunctorsFromDerivedClasses
>
struct list_map_adaptor_base
{
typedef list_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
BOOST_DEDUCED_TYPENAME mpl::push_front<
FunctorsFromDerivedClasses,
BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<KeyFromBaseValueConverter>,
// {
detail::key_from_pair_extractor
<
BOOST_DEDUCED_TYPENAME Iterator::value_type
>,
// }
// else
// {
KeyFromBaseValueConverter
// }
>::type
>::type
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Container adaptor to easily build a list map container
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyFromBaseValueConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class list_map_adaptor :
public list_map_adaptor_base
<
Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyFromBaseValueConverter,
FunctorsFromDerivedClasses
>::type
{
typedef BOOST_DEDUCED_TYPENAME list_map_adaptor_base
<
Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyFromBaseValueConverter,
FunctorsFromDerivedClasses
>::type base_;
// MetaData -------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type key_type;
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
protected:
typedef BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<KeyFromBaseValueConverter>,
// {
detail::key_from_pair_extractor< BOOST_DEDUCED_TYPENAME Iterator::value_type >,
// }
// else
// {
KeyFromBaseValueConverter
// }
>::type key_from_base_value;
// Access -----------------------------------------------------------------
public:
explicit list_map_adaptor(Base & c) :
base_(c) {}
protected:
typedef list_map_adaptor list_map_adaptor_;
// Functions -------------------------------------------------------------
public:
// The following functions are overwritten in order to work
// with key_type instead of value_type
template< class Predicate >
void remove_if(Predicate pred)
{
this->base().remove_if(
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
Predicate,
BOOST_DEDUCED_TYPENAME Base::value_type,
key_from_base_value
>( pred, this->template functor<key_from_base_value>() )
);
}
void unique()
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::equal_to<key_type>,
BOOST_DEDUCED_TYPENAME Base::value_type,
key_from_base_value
>(
std::equal_to<key_type>(),
this->template functor<key_from_base_value>()
)
);
}
template< class BinaryPredicate >
void unique(BinaryPredicate binary_pred)
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
BinaryPredicate,
BOOST_DEDUCED_TYPENAME Base::value_type,
key_from_base_value
>( binary_pred, this->template functor<key_from_base_value>() )
);
}
void merge(list_map_adaptor & x)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<key_type>,
BOOST_DEDUCED_TYPENAME Base::value_type,
key_from_base_value
>(
std::less<key_type>(),
this->template functor<key_from_base_value>()
)
);
}
template< class Compare >
void merge(list_map_adaptor & x, Compare comp)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME Base::value_type,
key_from_base_value
>( comp, this->template functor<key_from_base_value>() )
);
}
void sort()
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<key_type>,
BOOST_DEDUCED_TYPENAME Base::value_type,
key_from_base_value
>(
std::less<key_type>(),
this->template functor<key_from_base_value>()
)
);
}
template< class Compare >
void sort(Compare comp)
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME Base::value_type,
key_from_base_value
>( comp, this->template functor<key_from_base_value>() )
);
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_MAP_ADAPTOR_HPP

View File

@@ -0,0 +1,131 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/map_adaptor.hpp
/// \brief Container adaptor to easily build a std::map signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_MAP_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_MAP_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/ordered_associative_container_adaptor.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/call_traits.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::map signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class map_adaptor :
public ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// MetaData -------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
// Access -----------------------------------------------------------------
public:
explicit map_adaptor(Base & c) :
base_(c) {}
protected:
typedef map_adaptor map_adaptor_;
// Interface --------------------------------------------------------------
public:
template< class CompatibleKey >
data_type& operator[](const CompatibleKey & k)
{
return this->base()
[this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)];
}
template< class CompatibleKey >
data_type& at(const CompatibleKey & k)
{
return this->base().
at(this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k));
}
template< class CompatibleKey >
const data_type& at(const CompatibleKey & k) const
{
return this->base().
at(this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k));
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_MAP_ADAPTOR_HPP

View File

@@ -0,0 +1,109 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/multimap_adaptor.hpp
/// \brief Container adaptor to easily build a std::multimap signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_MULTIMAP_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_MULTIMAP_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/ordered_associative_container_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/non_unique_container_helper.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::multimap signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class multimap_adaptor :
public ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// MetaData -------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
// Access -----------------------------------------------------------------
public:
explicit multimap_adaptor(Base & c) :
base_(c) {}
protected:
typedef multimap_adaptor multimap_adaptor_;
public:
BOOST_BIMAP_NON_UNIQUE_CONTAINER_ADAPTOR_INSERT_FUNCTIONS
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_MULTIMAP_ADAPTOR_HPP

View File

@@ -0,0 +1,103 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/multiset_adaptor.hpp
/// \brief Container adaptor to easily build a std::multiset signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_MULTISET_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_MULTISET_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/ordered_associative_container_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/non_unique_container_helper.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::multiset signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class multiset_adaptor :
public ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// Access -----------------------------------------------------------------
public:
explicit multiset_adaptor(Base & c) :
base_(c) {}
protected:
typedef multiset_adaptor multiset_adaptor_;
public:
BOOST_BIMAP_NON_UNIQUE_CONTAINER_ADAPTOR_INSERT_FUNCTIONS
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_MULTISET_ADAPTOR_HPP

View File

@@ -0,0 +1,312 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/ordered_associative_container_adaptor.hpp
/// \brief Container adaptor to build a type that is compliant to the concept of an ordered associative container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_ORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_ORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/associative_container_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/operators.hpp>
#include <boost/call_traits.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template
<
class Base, class Iterator, class ConstIterator,
class ReverseIterator, class ConstReverseIterator, class KeyType,
class IteratorToBaseConverter, class IteratorFromBaseConverter,
class ReverseIteratorFromBaseConverter,
class ValueToBaseConverter, class ValueFromBaseConverter,
class KeyToBaseConverter,
class FunctorsFromDerivedClasses
>
struct ordered_associative_container_adaptor_base
{
typedef associative_container_adaptor<
Base, Iterator, ConstIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
BOOST_DEDUCED_TYPENAME mpl::push_front<
FunctorsFromDerivedClasses,
BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::mpl::is_na<ReverseIteratorFromBaseConverter>,
// {
detail::iterator_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::reverse_iterator,
ReverseIterator,
BOOST_DEDUCED_TYPENAME Base::const_reverse_iterator,
ConstReverseIterator
>,
// }
// else
// {
ReverseIteratorFromBaseConverter
// }
>::type
>::type
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Container adaptor to build a type that is compliant to the concept of an ordered associative container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class KeyType,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class ordered_associative_container_adaptor :
public ordered_associative_container_adaptor_base
<
Base, Iterator, ConstIterator,
ReverseIterator, ConstReverseIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
FunctorsFromDerivedClasses
>::type,
::boost::totally_ordered
<
ordered_associative_container_adaptor
<
Base, Iterator, ConstIterator,
ReverseIterator, ConstReverseIterator,
KeyType, IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter, FunctorsFromDerivedClasses
>
>
{
// MetaData -------------------------------------------------------------
typedef BOOST_DEDUCED_TYPENAME ordered_associative_container_adaptor_base
<
Base, Iterator, ConstIterator,
ReverseIterator, ConstReverseIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
FunctorsFromDerivedClasses
>::type base_;
public:
typedef detail::compatible_comparison_adaptor
<
BOOST_DEDUCED_TYPENAME Base::key_compare,
BOOST_DEDUCED_TYPENAME base_::key_type,
BOOST_DEDUCED_TYPENAME base_::key_to_base
> key_compare;
typedef detail::comparison_adaptor
<
BOOST_DEDUCED_TYPENAME Base::value_compare,
BOOST_DEDUCED_TYPENAME base_::value_type,
BOOST_DEDUCED_TYPENAME base_::value_to_base
> value_compare;
typedef ReverseIterator reverse_iterator;
typedef ConstReverseIterator const_reverse_iterator;
protected:
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::mpl::is_na<ReverseIteratorFromBaseConverter>,
// {
detail::iterator_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::reverse_iterator,
reverse_iterator,
BOOST_DEDUCED_TYPENAME Base::const_reverse_iterator,
const_reverse_iterator
>,
// }
// else
// {
ReverseIteratorFromBaseConverter
// }
>::type reverse_iterator_from_base;
// Access -----------------------------------------------------------------
public:
explicit ordered_associative_container_adaptor(Base & c)
: base_(c) {}
protected:
typedef ordered_associative_container_adaptor
ordered_associative_container_adaptor_;
// Interface --------------------------------------------------------------
public:
reverse_iterator rbegin()
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rbegin() );
}
reverse_iterator rend()
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rend() );
}
const_reverse_iterator rbegin() const
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rbegin() );
}
const_reverse_iterator rend() const
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rend() );
}
key_compare key_comp() const
{
typedef BOOST_DEDUCED_TYPENAME base_::key_to_base key_to_base_;
return key_compare(
this->base().key_comp(),
this->template functor<key_to_base_>()
);
}
value_compare value_comp() const
{
typedef BOOST_DEDUCED_TYPENAME base_::value_to_base value_to_base_;
return value_compare(
this->base().value_comp(),
this->template functor<value_to_base_>()
);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::iterator lower_bound(const CompatibleKey & k)
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
this->base().lower_bound(
this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
)
);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::const_iterator lower_bound(const CompatibleKey & k) const
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
this->base().lower_bound(
this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
)
);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::iterator upper_bound(const CompatibleKey & k)
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
this->base().upper_bound(
this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
)
);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::const_iterator upper_bound(const CompatibleKey & k) const
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
this->base().upper_bound(
this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
)
);
}
// Totally ordered implementation
bool operator==(const ordered_associative_container_adaptor & c) const
{
return ( this->base() == c.base() );
}
bool operator<(const ordered_associative_container_adaptor & c) const
{
return ( this->base() < c.base() );
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_ORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP

View File

@@ -0,0 +1,356 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/sequence_container_adaptor.hpp
/// \brief Container adaptor to build a type that is compliant to the concept of a weak associative container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_SEQUENCE_CONTAINER_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_SEQUENCE_CONTAINER_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <utility>
#include <boost/mpl/if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/bimap/container_adaptor/detail/identity_converters.hpp>
#include <boost/bimap/container_adaptor/container_adaptor.hpp>
#include <boost/call_traits.hpp>
#include <boost/operators.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template
<
class Base, class Iterator, class ConstIterator,
class ReverseIterator, class ConstReverseIterator,
class IteratorToBaseConverter, class IteratorFromBaseConverter,
class ReverseIteratorFromBaseConverter,
class ValueToBaseConverter, class ValueFromBaseConverter,
class FunctorsFromDerivedClasses
>
struct sequence_container_adaptor_base
{
typedef container_adaptor
<
Base, Iterator, ConstIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
BOOST_DEDUCED_TYPENAME mpl::push_front<
FunctorsFromDerivedClasses,
BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::mpl::is_na<ReverseIteratorFromBaseConverter>,
// {
detail::iterator_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::reverse_iterator,
ReverseIterator,
BOOST_DEDUCED_TYPENAME Base::const_reverse_iterator,
ConstReverseIterator
>,
// }
// else
// {
ReverseIteratorFromBaseConverter
// }
>::type
>::type
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Container adaptor to build a type that is compliant to the concept of a sequence container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class sequence_container_adaptor :
public sequence_container_adaptor_base
<
Base, Iterator, ConstIterator,
ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
>::type,
::boost::totally_ordered
<
sequence_container_adaptor
<
Base, Iterator, ConstIterator,
ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
>
>
{
typedef BOOST_DEDUCED_TYPENAME sequence_container_adaptor_base
<
Base, Iterator, ConstIterator,
ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
>::type base_;
// MetaData -------------------------------------------------------------
public:
typedef ReverseIterator reverse_iterator;
typedef ConstReverseIterator const_reverse_iterator;
protected:
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::mpl::is_na<ReverseIteratorFromBaseConverter>,
// {
detail::iterator_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::reverse_iterator,
reverse_iterator,
BOOST_DEDUCED_TYPENAME Base::const_reverse_iterator,
const_reverse_iterator
>,
// }
// else
// {
ReverseIteratorFromBaseConverter
// }
>::type reverse_iterator_from_base;
// Access -----------------------------------------------------------------
public:
explicit sequence_container_adaptor(Base & c)
: base_(c) {}
protected:
typedef sequence_container_adaptor sequence_container_adaptor_;
// Interface --------------------------------------------------------------
public:
reverse_iterator rbegin()
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rbegin() );
}
reverse_iterator rend()
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rend() );
}
const_reverse_iterator rbegin() const
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rbegin() );
}
const_reverse_iterator rend() const
{
return this->template functor<
reverse_iterator_from_base
>() ( this->base().rend() );
}
void resize(BOOST_DEDUCED_TYPENAME base_::size_type n,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x =
BOOST_DEDUCED_TYPENAME base_::value_type())
{
this->base().resize(n,
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x)
);
}
BOOST_DEDUCED_TYPENAME base_::reference front()
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
(
this->base().front()
);
}
BOOST_DEDUCED_TYPENAME base_::reference back()
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
(
this->base().back()
);
}
BOOST_DEDUCED_TYPENAME base_::const_reference front() const
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
(
this->base().front()
);
}
BOOST_DEDUCED_TYPENAME base_::const_reference back() const
{
return this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
(
this->base().back()
);
}
void push_front(
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x)
{
this->base().push_front(
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x));
}
void pop_front()
{
this->base().pop_front();
}
void push_back(
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x)
{
this->base().push_back(
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x));
}
void pop_back()
{
this->base().pop_back();
}
std::pair<BOOST_DEDUCED_TYPENAME base_::iterator,bool>
insert(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x)
{
std::pair< BOOST_DEDUCED_TYPENAME Base::iterator, bool > r(
this->base().insert(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_to_base >()(x)
)
);
return std::pair<BOOST_DEDUCED_TYPENAME base_::iterator, bool>(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(r.first),
r.second
);
}
void insert(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::size_type m,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x)
{
this->base().insert(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
m,
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_to_base >()(x)
);
}
template< class InputIterator >
void insert(BOOST_DEDUCED_TYPENAME base_::iterator position,
InputIterator first, InputIterator last)
{
// This is the same problem found in the insert function
// of container_adaptor
// For now, do the simple thing. This can be optimized
for( ; first != last ; ++first )
{
this->base().insert(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()( position ),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_to_base >()( *first )
);
}
}
// Totally ordered implementation
bool operator==(const sequence_container_adaptor & c) const
{
return ( this->base() == c.base() );
}
bool operator<(const sequence_container_adaptor & c) const
{
return ( this->base() < c.base() );
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_SEQUENCE_CONTAINER_ADAPTOR_HPP

View File

@@ -0,0 +1,100 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/set_adaptor.hpp
/// \brief Container adaptor to easily build a std::set signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/ordered_associative_container_adaptor.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/aux_/na.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::set signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class set_adaptor :
public ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
ordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// Access -----------------------------------------------------------------
public:
explicit set_adaptor(Base & c) :
base_(c) {}
protected:
typedef set_adaptor set_adaptor_;
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP

View File

@@ -0,0 +1,77 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/support/iterator_facade_converters.hpp
/// \brief Converter for Boost.Iterators based iterators.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_ITERATOR_FACADE_CONVERTERS_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_ITERATOR_FACADE_CONVERTERS_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Utilities to help in the construction of a container adaptor
namespace support {
/// \brief Converter for Boost.Iterators based iterators.
/**
Container adaptor is dessigned to play well with Boost.Iterators. This
converter can be used if this library is used to adapt the iterators.
**/
template
<
class Iterator,
class ConstIterator
>
struct iterator_facade_to_base
{
BOOST_DEDUCED_TYPENAME Iterator::base_type operator()(Iterator iter) const
{
return iter.base();
}
BOOST_DEDUCED_TYPENAME ConstIterator::base_type operator()(ConstIterator iter) const
{
return iter.base();
}
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template
<
class Iterator
>
struct iterator_facade_to_base<Iterator,Iterator>
{
BOOST_DEDUCED_TYPENAME Iterator::base_type operator()(Iterator iter) const
{
return iter.base();
}
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#undef BOOST_BIMAP_CONTAINER_ADAPTOR_IMPLEMENT_CONVERT_FACADE_FUNCTION
} // namespace support
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_ITERATOR_FACADE_CONVERTERS_HPP

View File

@@ -0,0 +1,293 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/unordered_associative_container_adaptor.hpp
/// \brief Container adaptor to build a type that is compliant to the concept of an unordered associative container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/associative_container_adaptor.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/call_traits.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template
<
class Base, class Iterator, class ConstIterator,
class LocalIterator, class ConstLocalIterator,
class KeyType,
class IteratorToBaseConverter, class IteratorFromBaseConverter,
class LocalIteratorFromBaseConverter,
class ValueToBaseConverter, class ValueFromBaseConverter,
class KeyToBaseConverter,
class FunctorsFromDerivedClasses
>
struct unordered_associative_container_adaptor_base
{
typedef associative_container_adaptor
<
Base, Iterator, ConstIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ValueToBaseConverter , ValueFromBaseConverter,
KeyToBaseConverter,
BOOST_DEDUCED_TYPENAME mpl::push_front<
FunctorsFromDerivedClasses,
BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::mpl::is_na<LocalIteratorFromBaseConverter>,
// {
detail::iterator_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::local_iterator,
LocalIterator,
BOOST_DEDUCED_TYPENAME Base::const_local_iterator,
ConstLocalIterator
>,
// }
// else
// {
LocalIteratorFromBaseConverter
// }
>::type
>::type
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Container adaptor to build a type that is compliant to the concept of an unordered associative container.
template
<
class Base,
class Iterator,
class ConstIterator,
class LocalIterator,
class ConstLocalIterator,
class KeyType,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class LocalIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class unordered_associative_container_adaptor :
public unordered_associative_container_adaptor_base
<
Base, Iterator, ConstIterator,
LocalIterator, ConstLocalIterator,
KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>::type
{
typedef BOOST_DEDUCED_TYPENAME unordered_associative_container_adaptor_base
<
Base, Iterator, ConstIterator,
LocalIterator, ConstLocalIterator,
KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>::type base_;
// Metadata ---------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME Base::key_equal key_equal;
typedef BOOST_DEDUCED_TYPENAME Base::hasher hasher;
typedef LocalIterator local_iterator;
typedef ConstLocalIterator const_local_iterator;
protected:
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::mpl::is_na<LocalIteratorFromBaseConverter>,
// {
detail::iterator_from_base_identity
<
BOOST_DEDUCED_TYPENAME Base::local_iterator,
local_iterator,
BOOST_DEDUCED_TYPENAME Base::const_local_iterator,
const_local_iterator
>,
// }
// else
// {
LocalIteratorFromBaseConverter
// }
>::type local_iterator_from_base;
// Access -----------------------------------------------------------------
public:
explicit unordered_associative_container_adaptor(Base & c)
: base_(c) {}
protected:
typedef unordered_associative_container_adaptor
unordered_associative_container_adaptor_;
// Interface --------------------------------------------------------------
public:
// bucket interface:
BOOST_DEDUCED_TYPENAME base_::size_type bucket_count() const
{
return this->base().bucket_count();
}
BOOST_DEDUCED_TYPENAME base_::size_type max_bucket_count() const
{
return this->base().max_bucket_count();
}
BOOST_DEDUCED_TYPENAME base_::size_type bucket_size(
BOOST_DEDUCED_TYPENAME base_::size_type n) const
{
return this->base().bucket_size(n);
}
template< class CompatibleKey >
BOOST_DEDUCED_TYPENAME base_::size_type bucket(
const CompatibleKey & k) const
{
typedef BOOST_DEDUCED_TYPENAME base_::key_to_base key_to_base;
return this->base().bucket(
this->template functor<key_to_base>()(k)
);
}
local_iterator begin(BOOST_DEDUCED_TYPENAME base_::size_type n)
{
return this->template functor<
local_iterator_from_base
>() ( this->base().begin(n) );
}
const_local_iterator begin(BOOST_DEDUCED_TYPENAME base_::size_type n) const
{
return this->template functor<
local_iterator_from_base
>() ( this->base().begin(n) );
}
local_iterator end(BOOST_DEDUCED_TYPENAME base_::size_type n)
{
return this->template functor<
local_iterator_from_base
>() ( this->base().end(n) );
}
const_local_iterator end(BOOST_DEDUCED_TYPENAME base_::size_type n) const
{
return this->template functor<
local_iterator_from_base
>() ( this->base().end(n) );
}
// hash policy
float load_factor() const
{
return this->base().load_factor();
}
float max_load_factor() const
{
return this->base().max_load_factor();
}
void max_load_factor(float z)
{
return this->base().max_load_factor(z);
}
void rehash(BOOST_DEDUCED_TYPENAME base_::size_type n)
{
return this->base().rehash(n);
}
// We have redefined end and begin so we have to manually route the old ones
BOOST_DEDUCED_TYPENAME base_::iterator begin()
{
return base_::container_adaptor_::begin();
}
BOOST_DEDUCED_TYPENAME base_::iterator end()
{
return base_::container_adaptor_::end();
}
BOOST_DEDUCED_TYPENAME base_::const_iterator begin() const
{
return base_::container_adaptor_::begin();
}
BOOST_DEDUCED_TYPENAME base_::const_iterator end() const
{
return base_::container_adaptor_::end();
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP

View File

@@ -0,0 +1,132 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/unordered_map_adaptor.hpp
/// \brief Container adaptor to easily build a std::unordered_map signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MAP_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MAP_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/unordered_associative_container_adaptor.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/call_traits.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::unordered_map signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class LocalIterator,
class ConstLocalIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class LocalIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class unordered_map_adaptor :
public ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// MetaData -------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
// Access -----------------------------------------------------------------
public:
explicit unordered_map_adaptor(Base & c) :
base_(c) {}
protected:
typedef unordered_map_adaptor unordered_map_adaptor_;
// Interface --------------------------------------------------------------
public:
template< class CompatibleKey >
data_type& operator[](const CompatibleKey & k)
{
return this->base()
[this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)];
}
template< class CompatibleKey >
data_type& at(const CompatibleKey & k)
{
return this->base().
at(this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k));
}
template< class CompatibleKey >
const data_type& at(const CompatibleKey & k) const
{
return this->base().
at(this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k));
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MAP_ADAPTOR_HPP

View File

@@ -0,0 +1,110 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/unordered_multimap_adaptor.hpp
/// \brief Container adaptor to easily build a std::unordered_multimap signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MULTIMAP_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MULTIMAP_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/unordered_associative_container_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/non_unique_container_helper.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::unordered_multimap signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class LocalIterator,
class ConstLocalIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class LocalIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class unordered_multimap_adaptor :
public ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// MetaData -------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
// Access -----------------------------------------------------------------
public:
explicit unordered_multimap_adaptor(Base & c) :
base_(c) {}
protected:
typedef unordered_multimap_adaptor unordered_multimap_adaptor_;
public:
BOOST_BIMAP_NON_UNIQUE_CONTAINER_ADAPTOR_INSERT_FUNCTIONS
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MULTIMAP_ADAPTOR_HPP

View File

@@ -0,0 +1,102 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/unordered_multiset_adaptor.hpp
/// \brief Container adaptor to easily build a std::unordered_multiset signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MULTISET_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MULTISET_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/unordered_associative_container_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/non_unique_container_helper.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::unordered_multiset signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class LocalIterator,
class ConstLocalIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class LocalIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class unordered_multiset_adaptor :
public ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// Access -----------------------------------------------------------------
public:
explicit unordered_multiset_adaptor(Base & c) :
base_(c) {}
protected:
typedef unordered_multiset_adaptor unordered_multiset_adaptor_;
public:
BOOST_BIMAP_NON_UNIQUE_CONTAINER_ADAPTOR_INSERT_FUNCTIONS
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_MULTISET_ADAPTOR_HPP

View File

@@ -0,0 +1,98 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/unordered_set_adaptor.hpp
/// \brief Container adaptor to easily build a std::unordered_set signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_SET_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_SET_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/unordered_associative_container_adaptor.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::unordered_set signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class LocalIterator,
class ConstLocalIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class LocalIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class KeyToBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class unordered_set_adaptor :
public ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::
unordered_associative_container_adaptor
<
Base,
Iterator, ConstIterator, LocalIterator, ConstLocalIterator,
BOOST_DEDUCED_TYPENAME Iterator::value_type,
IteratorToBaseConverter, IteratorFromBaseConverter,
LocalIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter,
FunctorsFromDerivedClasses
> base_;
// Access -----------------------------------------------------------------
public:
explicit unordered_set_adaptor(Base & c) :
base_(c) {}
protected:
typedef unordered_set_adaptor unordered_set_adaptor_;
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_SET_ADAPTOR_HPP

View File

@@ -0,0 +1,142 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/vector_adaptor.hpp
/// \brief Container adaptor to easily build a std::vector signature compatible container.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/sequence_container_adaptor.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/mpl/vector.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor to easily build a std::vector signature compatible container.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class vector_adaptor :
public ::boost::bimaps::container_adaptor::sequence_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef ::boost::bimaps::container_adaptor::sequence_container_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
> base_;
// Access -----------------------------------------------------------------
public:
vector_adaptor() {}
explicit vector_adaptor(Base & c) :
base_(c) {}
protected:
typedef vector_adaptor vector_adaptor_;
// Interface --------------------------------------------------------------
public:
BOOST_DEDUCED_TYPENAME base_::size_type capacity() const
{
return this->base().capacity();
}
void reserve(BOOST_DEDUCED_TYPENAME base_::size_type m)
{
this->base().resize(m);
}
void resize(BOOST_DEDUCED_TYPENAME base_::size_type n,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x =
BOOST_DEDUCED_TYPENAME base_::value_type())
{
this->base().resize(n,
this->template functor<BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x)
);
}
BOOST_DEDUCED_TYPENAME base_::const_reference
operator[](BOOST_DEDUCED_TYPENAME base_::size_type n) const
{
return this->base().operator[](n);
}
BOOST_DEDUCED_TYPENAME base_::const_reference
at(BOOST_DEDUCED_TYPENAME base_::size_type n) const
{
return this->base().at(n);
}
BOOST_DEDUCED_TYPENAME base_::reference
operator[](BOOST_DEDUCED_TYPENAME base_::size_type n)
{
return this->base().operator[](n);
}
BOOST_DEDUCED_TYPENAME base_::reference
at(BOOST_DEDUCED_TYPENAME base_::size_type n)
{
return this->base().at(n);
}
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_ADAPTOR_HPP

View File

@@ -0,0 +1,103 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file container_adaptor/vector_map_adaptor.hpp
/// \brief Container adaptor.
#ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_MAP_ADAPTOR_HPP
#define BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_MAP_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/bimap/container_adaptor/vector_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/identity_converters.hpp>
#include <boost/mpl/vector.hpp>
namespace boost {
namespace bimaps {
namespace container_adaptor {
/// \brief Container adaptor.
template
<
class Base,
class Iterator,
class ConstIterator,
class ReverseIterator,
class ConstReverseIterator,
class IteratorToBaseConverter = ::boost::mpl::na,
class IteratorFromBaseConverter = ::boost::mpl::na,
class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
class ValueToBaseConverter = ::boost::mpl::na,
class ValueFromBaseConverter = ::boost::mpl::na,
class FunctorsFromDerivedClasses = mpl::vector<>
>
class vector_map_adaptor :
public vector_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
>
{
typedef vector_adaptor
<
Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter,
ValueToBaseConverter, ValueFromBaseConverter,
FunctorsFromDerivedClasses
> base_;
// MetaData -------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type key_type;
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
// Access -----------------------------------------------------------------
public:
vector_map_adaptor() {}
explicit vector_map_adaptor(Base & c) :
base_(c) {}
protected:
typedef vector_map_adaptor vector_map_adaptor_;
};
} // namespace container_adaptor
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_MAP_ADAPTOR_HPP

View File

@@ -0,0 +1,520 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/bimap_core.hpp
/// \brief Bimap base definition.
#ifndef BOOST_BIMAP_DETAIL_BIMAP_CORE_HPP
#define BOOST_BIMAP_DETAIL_BIMAP_CORE_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/concept_check.hpp>
// Boost.MultiIndex
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
// Boost.Bimap
#include <boost/bimap/relation/mutant_relation.hpp>
#include <boost/bimap/relation/member_at.hpp>
#include <boost/bimap/relation/support/data_extractor.hpp>
#include <boost/bimap/tags/support/default_tagged.hpp>
#include <boost/bimap/tags/tagged.hpp>
#include <boost/bimap/detail/manage_bimap_key.hpp>
#include <boost/bimap/detail/manage_additional_parameters.hpp>
#include <boost/bimap/detail/map_view_iterator.hpp>
#include <boost/bimap/detail/set_view_iterator.hpp>
#include <boost/bimap/set_of.hpp>
#include <boost/bimap/unconstrained_set_of.hpp>
namespace boost {
namespace bimaps {
/// \brief Library details
namespace detail {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Type >
struct get_value_type
{
typedef BOOST_DEDUCED_TYPENAME Type::value_type type;
};
struct independent_index_tag {};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief Base for the bimap class.
/**
See also bimap.
**/
template< class LeftSetType, class RightSetType, class AP1, class AP2, class AP3 >
class bimap_core
{
// Manage bimap key instantiation
// --------------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME manage_bimap_key
<
LeftSetType
>::type left_set_type;
typedef BOOST_DEDUCED_TYPENAME manage_bimap_key
<
RightSetType
>::type right_set_type;
private:
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::default_tagged
<
BOOST_DEDUCED_TYPENAME left_set_type::user_type,
::boost::bimaps::relation::member_at::left
>::type left_tagged_type;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::default_tagged
<
BOOST_DEDUCED_TYPENAME right_set_type::user_type,
::boost::bimaps::relation::member_at::right
>::type right_tagged_type;
public:
//@{
typedef BOOST_DEDUCED_TYPENAME left_tagged_type::tag left_tag;
typedef BOOST_DEDUCED_TYPENAME right_tagged_type::tag right_tag;
//@}
//@{
typedef BOOST_DEDUCED_TYPENAME left_set_type::value_type left_key_type;
typedef BOOST_DEDUCED_TYPENAME right_set_type::value_type right_key_type;
//@}
//@{
typedef right_key_type left_data_type;
typedef left_key_type right_data_type;
//@}
// Manage the additional parameters
// --------------------------------------------------------------------
private:
typedef BOOST_DEDUCED_TYPENAME manage_additional_parameters<AP1,AP2,AP3>::type parameters;
/// \brief Relation type stored by the bimap.
// --------------------------------------------------------------------
public:
typedef ::boost::bimaps::relation::mutant_relation
<
::boost::bimaps::tags::tagged<
BOOST_DEDUCED_TYPENAME mpl::if_<
mpl::and_
<
BOOST_DEDUCED_TYPENAME left_set_type::mutable_key,
BOOST_DEDUCED_TYPENAME parameters::set_type_of_relation::left_mutable_key
>,
// {
left_key_type,
// }
// else
// {
BOOST_DEDUCED_TYPENAME ::boost::add_const< left_key_type >::type
// }
>::type,
left_tag
>,
::boost::bimaps::tags::tagged<
BOOST_DEDUCED_TYPENAME mpl::if_<
mpl::and_
<
BOOST_DEDUCED_TYPENAME right_set_type::mutable_key,
BOOST_DEDUCED_TYPENAME parameters::set_type_of_relation::right_mutable_key
>,
// {
right_key_type,
// }
// else
// {
BOOST_DEDUCED_TYPENAME ::boost::add_const< right_key_type >::type
// }
>::type,
right_tag
>,
// It is ::boost::mpl::na if no info_hook was included
BOOST_DEDUCED_TYPENAME parameters::additional_info,
// Force mutable keys
true
> relation;
//@{
typedef BOOST_DEDUCED_TYPENAME relation::left_pair left_value_type;
typedef BOOST_DEDUCED_TYPENAME relation::right_pair right_value_type;
//@}
// Bind the member of the relation, so multi_index can manage them
// --------------------------------------------------------------------
private:
typedef BOOST_DEDUCED_TYPENAME relation::storage_base relation_storage_base;
typedef BOOST_MULTI_INDEX_MEMBER(relation_storage_base, left_key_type, left)
left_member_extractor;
typedef BOOST_MULTI_INDEX_MEMBER(relation_storage_base,right_key_type,right)
right_member_extractor;
// The core indices are somewhat complicated to calculate, because they
// can be zero, one, two or three indices, depending on the use of
// {side}_based set type of relations and unconstrained_set_of and
// unconstrained_set_of_relation specifications.
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::bimaps::detail::is_unconstrained_set_of< left_set_type >,
// {
mpl::vector<>,
// }
// else
// {
mpl::vector
<
BOOST_DEDUCED_TYPENAME left_set_type::
BOOST_NESTED_TEMPLATE index_bind
<
left_member_extractor,
left_tag
>::type
>
// }
>::type left_core_indices;
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::bimaps::detail::is_unconstrained_set_of< right_set_type >,
// {
left_core_indices,
// }
// else
// {
BOOST_DEDUCED_TYPENAME mpl::push_front
<
left_core_indices,
BOOST_DEDUCED_TYPENAME right_set_type::
BOOST_NESTED_TEMPLATE index_bind
<
right_member_extractor,
right_tag
>::type
>::type
// }
>::type basic_core_indices;
// If it is based either on the left or on the right, then only the side
// indices are needed. But the set type of the relation can be completely
// diferent from the one used for the sides in wich case we have to add yet
// another index to the core.
// TODO
// If all the set types are unsconstrained there must be readable compile
// time error.
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
is_same< BOOST_DEDUCED_TYPENAME parameters::set_type_of_relation, left_based >,
// {
::boost::bimaps::tags::tagged< left_set_type, left_tag >,
// }
/* else */ BOOST_DEDUCED_TYPENAME mpl::if_<
is_same< BOOST_DEDUCED_TYPENAME parameters::set_type_of_relation, right_based >,
// {
::boost::bimaps::tags::tagged< right_set_type, right_tag >,
// }
// else
// {
tags::tagged
<
BOOST_DEDUCED_TYPENAME parameters::
set_type_of_relation::BOOST_NESTED_TEMPLATE bind_to
<
relation
>::type,
independent_index_tag
>
// }
>::type
>::type tagged_set_of_relation_type;
protected:
typedef BOOST_DEDUCED_TYPENAME tagged_set_of_relation_type::tag
relation_set_tag;
typedef BOOST_DEDUCED_TYPENAME tagged_set_of_relation_type::value_type
relation_set_type_of;
// Logic tags
// This is a necesary extra level of indirection to allow unconstrained
// sets to be plug in the design. The bimap constructors use this logic
// tags.
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::bimaps::detail::is_unconstrained_set_of< left_set_type >,
BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::bimaps::detail::is_unconstrained_set_of< right_set_type >,
independent_index_tag,
right_tag
>::type,
left_tag
>::type logic_left_tag;
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::bimaps::detail::is_unconstrained_set_of< right_set_type >,
BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::bimaps::detail::is_unconstrained_set_of< left_set_type >,
independent_index_tag,
left_tag
>::type,
right_tag
>::type logic_right_tag;
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
is_same< relation_set_tag, independent_index_tag >,
BOOST_DEDUCED_TYPENAME mpl::if_<
::boost::bimaps::detail::
is_unconstrained_set_of< relation_set_type_of >,
logic_left_tag,
independent_index_tag
>::type,
BOOST_DEDUCED_TYPENAME mpl::if_<
is_same< BOOST_DEDUCED_TYPENAME parameters::set_type_of_relation, left_based >,
logic_left_tag,
logic_right_tag
>::type
>::type logic_relation_set_tag;
private:
typedef BOOST_DEDUCED_TYPENAME mpl::if_<
mpl::and_< is_same< relation_set_tag, independent_index_tag >,
mpl::not_<
::boost::bimaps::detail::
is_unconstrained_set_of< relation_set_type_of >
>
>,
// {
BOOST_DEDUCED_TYPENAME mpl::push_front
<
basic_core_indices,
BOOST_DEDUCED_TYPENAME relation_set_type_of::
BOOST_NESTED_TEMPLATE index_bind
<
::boost::bimaps::relation::support::both_keys_extractor<relation>,
independent_index_tag
>::type
>::type,
// }
// else
// {
basic_core_indices
// }
>::type complete_core_indices;
struct core_indices : public complete_core_indices {};
// Define the core using compute_index_type to translate the
// set type to an multi-index specification
// --------------------------------------------------------------------
public:
typedef multi_index::multi_index_container
<
relation,
core_indices,
BOOST_DEDUCED_TYPENAME parameters::allocator::
BOOST_NESTED_TEMPLATE rebind<relation>::other
> core_type;
// Core metadata
// --------------------------------------------------------------------
public:
typedef BOOST_DEDUCED_TYPENAME ::boost::multi_index::
index<core_type, logic_left_tag>::type left_index;
typedef BOOST_DEDUCED_TYPENAME ::boost::multi_index::
index<core_type,logic_right_tag>::type right_index;
typedef BOOST_DEDUCED_TYPENAME left_index::iterator left_core_iterator;
typedef BOOST_DEDUCED_TYPENAME left_index::const_iterator left_core_const_iterator;
typedef BOOST_DEDUCED_TYPENAME right_index::iterator right_core_iterator;
typedef BOOST_DEDUCED_TYPENAME right_index::const_iterator right_core_const_iterator;
// Map by {side} iterator metadata
// --------------------------------------------------------------------
public:
//@{
typedef ::boost::bimaps::detail::map_view_iterator
<
left_tag,
relation,
left_core_iterator
> left_iterator;
typedef ::boost::bimaps::detail::map_view_iterator
<
right_tag,
relation,
right_core_iterator
> right_iterator;
//@}
//@{
typedef ::boost::bimaps::detail::const_map_view_iterator
<
left_tag,
relation,
left_core_const_iterator
> left_const_iterator;
typedef ::boost::bimaps::detail::const_map_view_iterator
<
right_tag,
relation,
right_core_const_iterator
> right_const_iterator;
//@}
// Relation set view
typedef BOOST_DEDUCED_TYPENAME ::boost::multi_index::index
<
core_type, logic_relation_set_tag
>::type relation_set_core_index;
typedef BOOST_DEDUCED_TYPENAME relation_set_type_of::
BOOST_NESTED_TEMPLATE set_view_bind
<
relation_set_core_index
>::type relation_set;
public:
typedef bimap_core bimap_core_;
};
// Two auxiliar metafunctions to compute the map view types
// The map view type can not be computed inside the bimap core because a
// they need the bimap core to be parsed first.
template< class BimapBaseType >
struct left_map_view_type
{
typedef BOOST_DEDUCED_TYPENAME BimapBaseType::left_set_type left_set_type;
typedef BOOST_DEDUCED_TYPENAME
left_set_type::BOOST_NESTED_TEMPLATE map_view_bind<
BOOST_DEDUCED_TYPENAME BimapBaseType::left_tag, BimapBaseType
>::type type;
};
template< class BimapBaseType >
struct right_map_view_type
{
typedef BOOST_DEDUCED_TYPENAME BimapBaseType::right_set_type right_set_type;
typedef BOOST_DEDUCED_TYPENAME
right_set_type::BOOST_NESTED_TEMPLATE map_view_bind<
BOOST_DEDUCED_TYPENAME BimapBaseType::right_tag, BimapBaseType
>::type type;
};
} // namespace detail
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_BIMAP_CORE_HPP

View File

@@ -0,0 +1,97 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/concept_tags.hpp
/// \brief Bimap tags and concepts
#ifndef BOOST_BIMAP_DETAIL_CONCEPT_TAGS_HPP
#define BOOST_BIMAP_DETAIL_CONCEPT_TAGS_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/bool.hpp>
namespace boost {
namespace bimaps {
namespace detail {
/// \brief Tag of {SetType}_of definition classes
/**
The {SetType}_of classes are derived from this class so it is easy to construct
metafunctions. For example now is easy to create a is_set_type_of metafunction.
**/
struct set_type_of_tag {};
/// \brief Tag of {SetType}_of_relation defition classes
struct set_type_of_relation_tag {};
/// \brief Tag of {Side}_based identifiers
struct side_based_tag : set_type_of_relation_tag {};
} // namespace detail
/** \struct boost::bimaps::left_based
\brief Tag to indicate that the main view will be based on the left side.
This is convenient because the multi-index core will be more efficient.
If possible use this options or the right based one.
See also right_based.
**/
/** \struct boost::bimaps::right_based
\brief Tag to indicate that the main view will be based on the right side.
This is convenient because the multi-index core will be more efficient.
If possible use this options or the right based one.
See also left_based.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
struct left_based : ::boost::bimaps::detail::side_based_tag
{
// I run into troubles if I do not define bind for side based tags.
// Maybe a more coherent way of binding the relation can be developped.
template< class Relation > struct bind_to { typedef void type; };
typedef mpl::bool_<true> left_mutable_key;
typedef mpl::bool_<true> right_mutable_key;
};
struct right_based : ::boost::bimaps::detail::side_based_tag
{
// I run into troubles if I do not define bind for side based tags.
// Maybe a more coherent way of binding the relation can be developped.
template< class Relation > struct bind_to { typedef void type; };
typedef mpl::bool_<true> left_mutable_key;
typedef mpl::bool_<true> right_mutable_key;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
typedef mpl::_ _relation;
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_CONCEPT_TAGS_HPP

View File

@@ -0,0 +1,36 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/debug/static_error.hpp
/// \brief Formatted compile time error
#ifndef BOOST_BIMAP_DETAIL_DEBUG_STATIC_ERROR_HPP
#define BOOST_BIMAP_DETAIL_DEBUG_STATIC_ERROR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/preprocessor/cat.hpp>
// Easier way to call BOOST_MPL_ASSERT_MSG in class scope to generate
// a static error.
/*===========================================================================*/
#define BOOST_BIMAP_STATIC_ERROR(MESSAGE,VARIABLES) \
struct BOOST_PP_CAT(BIMAP_STATIC_ERROR__,MESSAGE) {}; \
BOOST_MPL_ASSERT_MSG(false, \
BOOST_PP_CAT(BIMAP_STATIC_ERROR__,MESSAGE), \
VARIABLES)
/*===========================================================================*/
#endif // BOOST_BIMAP_DETAIL_DEBUG_STATIC_ERROR_HPP

View File

@@ -0,0 +1,125 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/generate_index_binder.hpp
/// \brief Define macros to help building the set type of definitions
#ifndef BOOST_BIMAP_DETAIL_GENERATE_INDEX_BINDER_HPP
#define BOOST_BIMAP_DETAIL_GENERATE_INDEX_BINDER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/multi_index/tag.hpp>
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP( \
\
MULTI_INDEX_TYPE \
\
) \
\
template< class KeyExtractor, class Tag > \
struct index_bind \
{ \
typedef MULTI_INDEX_TYPE \
< \
multi_index::tag< Tag >, \
KeyExtractor \
\
> type; \
};
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP( \
\
MULTI_INDEX_TYPE, \
CONFIG_PARAMETER \
\
) \
\
template< class KeyExtractor, class Tag > \
struct index_bind \
{ \
typedef MULTI_INDEX_TYPE \
< \
multi_index::tag< Tag >, \
KeyExtractor, \
CONFIG_PARAMETER \
\
> type; \
};
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_INDEX_BINDER_2CP( \
\
MULTI_INDEX_TYPE, \
CONFIG_PARAMETER_1, \
CONFIG_PARAMETER_2 \
) \
\
template< class KeyExtractor, class Tag > \
struct index_bind \
{ \
typedef MULTI_INDEX_TYPE \
< \
multi_index::tag< Tag >, \
KeyExtractor, \
CONFIG_PARAMETER_1, \
CONFIG_PARAMETER_2 \
\
> type; \
\
};
/*===========================================================================*/
// This is a special registration to allow sequenced and random access indices
// to play along smoothly with the other index types.
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP_NO_EXTRACTOR( \
\
MULTI_INDEX_TYPE \
\
) \
\
template< class KeyExtractor, class Tag > \
struct index_bind \
{ \
typedef MULTI_INDEX_TYPE< multi_index::tag< Tag > > type; \
};
/*===========================================================================*/
// This is yet another special registration to allow unconstrained sets
// to play along smoothly with the other index types.
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_INDEX_BINDER_FAKE \
\
template< class KeyExtractor, class Tag > \
struct index_bind \
{ \
typedef void type; \
}; \
/*===========================================================================*/
#endif // BOOST_BIMAP_DETAIL_GENERATE_INDEX_BINDER_HPP

View File

@@ -0,0 +1,88 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/generate_relation_binder.hpp
/// \brief Define macros to help building the set type of definitions
#ifndef BOOST_BIMAP_DETAIL_GENERATE_RELATION_BINDER_HPP
#define BOOST_BIMAP_DETAIL_GENERATE_RELATION_BINDER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/apply.hpp>
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP( \
\
SET_TYPE_OF \
) \
\
template< class Relation > \
struct bind_to \
{ \
typedef SET_TYPE_OF<Relation> type; \
\
};
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP( \
\
SET_TYPE_OF, \
CP1 \
) \
\
template< class Relation > \
struct bind_to \
{ \
typedef SET_TYPE_OF \
< \
Relation, \
BOOST_DEDUCED_TYPENAME mpl::apply<CP1, \
BOOST_DEDUCED_TYPENAME Relation::storage_base >::type \
\
> type; \
\
};
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_RELATION_BINDER_2CP( \
\
SET_TYPE_OF, \
CP1, \
CP2 \
) \
\
template< class Relation > \
struct bind_to \
{ \
typedef SET_TYPE_OF \
< \
Relation, \
BOOST_DEDUCED_TYPENAME mpl::apply<CP1, \
BOOST_DEDUCED_TYPENAME Relation::storage_base >::type, \
BOOST_DEDUCED_TYPENAME mpl::apply<CP2, \
BOOST_DEDUCED_TYPENAME Relation::storage_base >::type \
\
> type; \
\
};
/*===========================================================================*/
#endif // BOOST_BIMAP_DETAIL_GENERATE_RELATION_BINDER_HPP

View File

@@ -0,0 +1,58 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/generate_view_binder.hpp
/// \brief Define macros to help building the set type of definitions
#ifndef BOOST_BIMAP_DETAIL_GENERATE_VIEW_BINDER_HPP
#define BOOST_BIMAP_DETAIL_GENERATE_VIEW_BINDER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/multi_index/tag.hpp>
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER( \
\
MAP_VIEW_TYPE \
\
) \
\
template< class Tag, class BimapType > \
struct map_view_bind \
{ \
typedef MAP_VIEW_TYPE \
< \
Tag, \
BimapType \
\
> type; \
};
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_GENERATE_SET_VIEW_BINDER( \
\
SET_VIEW_TYPE \
\
) \
\
template< class IndexType > \
struct set_view_bind \
{ \
typedef SET_VIEW_TYPE<IndexType> type; \
};
/*===========================================================================*/
#endif // BOOST_BIMAP_DETAIL_GENERATE_VIEW_BINDER_HPP

View File

@@ -0,0 +1,66 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/is_set_type_of.hpp
/// \brief Is set type of and is set type of relation metafunctions.
#ifndef BOOST_BIMAP_DETAIL_IS_SET_TYPE_OF_HPP
#define BOOST_BIMAP_DETAIL_IS_SET_TYPE_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
/** \struct boost::bimaps::detail::is_set_type_of
\brief Type trait to check if a class is a set_type_of specification
\code
template< class Type >
struct is_set_type_of : {true_|false_} {};
\endcode
**/
/** \struct boost::bimaps::detail::is_set_type_of_relation
\brief Type trait to check if a class is a set_type_of_relation specification
\code
template< class Type >
struct is_set_type_of_relation : {true_|false_} {};
\endcode
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace detail {
template< class Type >
struct is_set_type_of :
is_base_of< set_type_of_tag, Type > {};
template< class Type >
struct is_set_type_of_relation :
is_base_of< set_type_of_relation_tag, Type > {};
} // namespace detail
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_DETAIL_IS_SET_TYPE_OF_HPP

View File

@@ -0,0 +1,243 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/manage_additional_parameters.hpp
/// \brief Utility class to extract the additional parameters from the template parameters.
#ifndef BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
#define BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <memory>
// Boost.MPL
#include <boost/mpl/bool.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/bimap/detail/is_set_type_of.hpp>
namespace boost {
namespace bimaps {
template< class Type >
struct with_info
{
typedef Type value_type;
};
namespace detail {
/// \brief Metafunction to check if a given type is a data_hook specification.
template< class Type >
struct is_with_info : ::boost::mpl::false_ {};
template< class ValueType >
struct is_with_info< with_info<ValueType> > : ::boost::mpl::true_ {};
/** \struct boost::bimaps::detail::manage_additional_parameters
\brief Utility class to extract the additional parameters from the template parameters.
\code
template< class AP1, class AP2, class AP3 >
struct manage_additional_parameters
{
struct parameters
{
typedef -unspecified- set_type_of_relation;
typedef -unspecified- data_hook;
typedef -unspecified- allocator;
};
typedef parameters type;
};
\endcode
See also bimap, bimap_core.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class AP1, class AP2, class AP3 >
struct manage_additional_parameters
{
// (1) manage_additional_parameters<
// not_specified,not_specified,not_specified>
//
// set_type_of_relation: based on the left key type
// info_hook: no additional info
// allocator: default allocator
struct case_NNN
{
typedef left_based set_type_of_relation;
typedef std::allocator<void> allocator;
typedef ::boost::mpl::na additional_info;
};
// (2) manage_additional_parameters<Allocator,not_specified,not_specified>
//
// set_type_of_relation: based on the left key type
// info_hook: no additional info
// allocator: Allocator
struct case_ANN
{
typedef left_based set_type_of_relation;
typedef AP1 allocator;
typedef ::boost::mpl::na additional_info;
};
// (3) manage_additional_parameters<
// SetOfRelationType,not_specified,not_specified>
//
// set_type_of_relation: SetTypeOfRelation
// info_hook: no additional info
// allocator: default allocator
struct case_SNN
{
typedef AP1 set_type_of_relation;
typedef std::allocator<void> allocator;
typedef ::boost::mpl::na additional_info;
};
// (4) manage_additional_parameters<
// SetTypeOfRelation,Allocator,not_specified>
//
// set_type_of_relation: SetTypeOfRelation
// info_hook: no additional info
// allocator: Allocator
struct case_SAN
{
typedef AP1 set_type_of_relation;
typedef AP2 allocator;
typedef ::boost::mpl::na additional_info;
};
// (5) manage_additional_parameters<InfoToHook,not_specified,not_specified>
//
// set_type_of_relation: based on the left key type
// info_hook: InfoToHook
// allocator: default allocator
struct case_HNN
{
typedef left_based set_type_of_relation;
typedef std::allocator<void> allocator;
typedef BOOST_DEDUCED_TYPENAME AP1::value_type additional_info;
};
// (6) manage_additional_parameters<
// SetTypeOfRelation,InfoToHook,not_specified>
//
// set_type_of_relation: SetTypeOfRelation
// info_hook: InfoToHook
// allocator: default allocator
struct case_SHN
{
typedef AP1 set_type_of_relation;
typedef std::allocator<void> allocator;
typedef BOOST_DEDUCED_TYPENAME AP2::value_type additional_info;
};
// (7) manage_additional_parameters<
// DataToHook,Allocator,not_specified>
//
// set_type_of_relation: SetTypeOfRelation
// info_hook: InfoToHook
// allocator: default allocator
struct case_HAN
{
typedef left_based set_type_of_relation;
typedef AP2 allocator;
typedef BOOST_DEDUCED_TYPENAME AP1::value_type additional_info;
};
// (8) manage_additional_parameters<
// SetTypeOfRelation,DataToHook,Allocator>
//
// set_type_of_relation: SetTypeOfRelation
// info_hook: InfoToHook
// allocator: Allocator
struct case_SHA
{
typedef AP1 set_type_of_relation;
typedef AP2 allocator;
typedef BOOST_DEDUCED_TYPENAME AP2::value_type additional_info;
};
// Some annidated mpl::if_ and we are done!
typedef BOOST_DEDUCED_TYPENAME mpl::if_
<
::boost::mpl::is_na<AP1>,
case_NNN, // (1)
BOOST_DEDUCED_TYPENAME mpl::if_
<
::boost::mpl::is_na<AP2>,
BOOST_DEDUCED_TYPENAME mpl::if_
<
is_set_type_of_relation<AP1>,
case_SNN, // (3)
BOOST_DEDUCED_TYPENAME mpl::if_
<
is_with_info<AP1>,
case_HNN, // (5)
case_ANN // (2)
>::type
>::type,
BOOST_DEDUCED_TYPENAME mpl::if_
<
::boost::mpl::is_na<AP3>,
BOOST_DEDUCED_TYPENAME mpl::if_
<
is_with_info<AP1>,
case_HAN, // (7)
BOOST_DEDUCED_TYPENAME mpl::if_
<
is_with_info<AP2>,
case_SHN, // (6)
case_SAN // (4)
>::type
>::type,
case_SHA // (8)
>::type
>::type
>::type type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
} // namespace detail
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_MANAGE_ADDITIONAL_PARAMETERS_HPP

View File

@@ -0,0 +1,84 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/manage_bimap_key.hpp
/// \brief Utility class to manage the set types of a bimap.
#ifndef BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP
#define BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/bimap/detail/is_set_type_of.hpp>
#include <boost/bimap/set_of.hpp>
namespace boost {
namespace bimaps {
namespace detail {
/** \struct boost::bimaps::detail::manage_bimap_key
\brief Metafunction to manage the set types of a bimap.
\code
template< class Type >
struct manage_bimap_key
{
typedef -SetType- type;
}
\endcode
See also bimap, bimap_core.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Type >
struct manage_bimap_key
{
typedef BOOST_DEDUCED_TYPENAME
mpl::eval_if< BOOST_DEDUCED_TYPENAME is_set_type_of< Type >::type,
// {
mpl::identity< Type >,
// }
// else
// {
// Default it to a set
mpl::identity< set_of< Type > >
// }
>::type set_type;
// Returns set_type and evaluate the concept_checked_type
typedef BOOST_DEDUCED_TYPENAME mpl::if_c< true, set_type,
BOOST_DEDUCED_TYPENAME set_type::lazy_concept_checked::type
>::type type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
} // namespace detail
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP

View File

@@ -0,0 +1,553 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/map_view_base.hpp
/// \brief Helper base for the construction of the bimap views types.
#ifndef BOOST_BIMAP_DETAIL_MAP_VIEW_BASE_HPP
#define BOOST_BIMAP_DETAIL_MAP_VIEW_BASE_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <stdexcept>
#include <utility>
#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/if.hpp>
#include <boost/bimap/relation/support/get_pair_functor.hpp>
#include <boost/bimap/relation/detail/to_mutable_relation_functor.hpp>
#include <boost/bimap/container_adaptor/support/iterator_facade_converters.hpp>
#include <boost/bimap/relation/support/data_extractor.hpp>
#include <boost/bimap/relation/support/opposite_tag.hpp>
#include <boost/bimap/relation/support/pair_type_by.hpp>
#include <boost/bimap/support/iterator_type_by.hpp>
#include <boost/bimap/support/key_type_by.hpp>
#include <boost/bimap/support/data_type_by.hpp>
#include <boost/bimap/support/value_type_by.hpp>
#include <boost/bimap/detail/modifier_adaptor.hpp>
#include <boost/bimap/detail/debug/static_error.hpp>
namespace boost {
namespace bimaps {
namespace detail {
// The next macro can be converted in a metafunctor to gain code robustness.
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR( \
CONTAINER_ADAPTOR, TAG,BIMAP, OTHER_ITER, CONST_OTHER_ITER \
) \
::boost::bimaps::container_adaptor::CONTAINER_ADAPTOR \
< \
BOOST_DEDUCED_TYPENAME BIMAP::core_type:: \
BOOST_NESTED_TEMPLATE index<TAG>::type, \
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support:: \
iterator_type_by<TAG,BIMAP>::type, \
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support:: \
const_iterator_type_by<TAG,BIMAP>::type, \
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support:: \
OTHER_ITER<TAG,BIMAP>::type, \
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support:: \
CONST_OTHER_ITER<TAG,BIMAP>::type, \
::boost::bimaps::container_adaptor::support::iterator_facade_to_base \
< \
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support:: \
iterator_type_by<TAG,BIMAP>::type, \
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support:: \
const_iterator_type_by<TAG,BIMAP>::type \
\
>, \
::boost::mpl::na, \
::boost::mpl::na, \
::boost::bimaps::relation::detail:: \
pair_to_relation_functor<TAG,BOOST_DEDUCED_TYPENAME BIMAP::relation>, \
::boost::bimaps::relation::support:: \
get_pair_functor<TAG, BOOST_DEDUCED_TYPENAME BIMAP::relation > \
>
/*===========================================================================*/
#if defined(BOOST_MSVC)
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(TYPE,TAG,BIMAP) \
typedef ::boost::bimaps::detail::map_view_base< \
TYPE<TAG,BIMAP>,TAG,BIMAP > friend_map_view_base; \
friend class friend_map_view_base;
/*===========================================================================*/
#else
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(TYPE,TAG,BIMAP) \
friend class ::boost::bimaps::detail::map_view_base< \
TYPE<TAG,BIMAP>,TAG,BIMAP >;
/*===========================================================================*/
#endif
/// \brief Common base for map views.
template< class Derived, class Tag, class BimapType>
class map_view_base
{
typedef ::boost::bimaps::container_adaptor::support::
iterator_facade_to_base<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
iterator_type_by<Tag,BimapType>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
const_iterator_type_by<Tag,BimapType>::type
> iterator_to_base_;
typedef ::boost::bimaps::relation::detail::
pair_to_relation_functor<Tag,
BOOST_DEDUCED_TYPENAME BimapType::relation> value_to_base_;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
key_type_by<Tag,BimapType>::type key_type_;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
data_type_by<Tag,BimapType>::type data_type_;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
pair_type_by<Tag,
BOOST_DEDUCED_TYPENAME BimapType::relation>::type value_type_;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
iterator_type_by<Tag,BimapType>::type iterator_;
public:
bool replace(iterator_ position, const value_type_ & x)
{
return derived().base().replace(
derived().template functor<iterator_to_base_>()(position),
derived().template functor<value_to_base_>()(x)
);
}
template< class CompatibleKey >
bool replace_key(iterator_ position, const CompatibleKey & k)
{
return derived().base().replace(
derived().template functor<iterator_to_base_>()(position),
derived().template functor<value_to_base_>()(
value_type_(k,position->second)
)
);
}
template< class CompatibleData >
bool replace_data(iterator_ position, const CompatibleData & d)
{
return derived().base().replace(
derived().template functor<iterator_to_base_>()(position),
derived().template functor<value_to_base_>()(
value_type_(position->first,d)
)
);
}
/* This function may be provided in the future
template< class Modifier >
bool modify(iterator_ position, Modifier mod)
{
return derived().base().modify(
derived().template functor<iterator_to_base_>()(position),
::boost::bimaps::detail::relation_modifier_adaptor
<
Modifier,
BOOST_DEDUCED_TYPENAME BimapType::relation,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
data_extractor
<
Tag, BOOST_DEDUCED_TYPENAME BimapType::relation
>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
data_extractor
<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
opossite_tag<Tag,BimapType>::type,
BOOST_DEDUCED_TYPENAME BimapType::relation
>::type
>(mod)
);
}
*/
template< class Modifier >
bool modify_key(iterator_ position, Modifier mod)
{
return derived().base().modify_key(
derived().template functor<iterator_to_base_>()(position), mod
);
}
template< class Modifier >
bool modify_data(iterator_ position, Modifier mod)
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
data_extractor
<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
opossite_tag<Tag,BimapType>::type,
BOOST_DEDUCED_TYPENAME BimapType::relation
>::type data_extractor_;
return derived().base().modify(
derived().template functor<iterator_to_base_>()(position),
// this may be replaced later by
// ::boost::bind( mod, ::boost::bind(data_extractor_(),_1) )
::boost::bimaps::detail::unary_modifier_adaptor
<
Modifier,
BOOST_DEDUCED_TYPENAME BimapType::relation,
data_extractor_
>(mod)
);
}
protected:
typedef map_view_base map_view_base_;
private:
// Curiously Recurring Template interface.
Derived& derived()
{
return *static_cast<Derived*>(this);
}
Derived const& derived() const
{
return *static_cast<Derived const*>(this);
}
};
template< class Derived, class Tag, class BimapType>
class mutable_data_unique_map_view_access
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
data_type_by<Tag,BimapType>::type data_type_;
public:
template< class CompatibleKey >
data_type_ & at(const CompatibleKey& k)
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
iterator_type_by<Tag,BimapType>::type iterator;
iterator iter = derived().find(k);
if( iter == derived().end() )
{
::boost::throw_exception(
std::out_of_range("bimap<>: invalid key")
);
}
return iter->second;
}
template< class CompatibleKey >
const data_type_ & at(const CompatibleKey& k) const
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
const_iterator_type_by<Tag,BimapType>::type const_iterator;
const_iterator iter = derived().find(k);
if( iter == derived().end() )
{
::boost::throw_exception(
std::out_of_range("bimap<>: invalid key")
);
}
return iter->second;
}
template< class CompatibleKey >
data_type_ & operator[](const CompatibleKey& k)
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
iterator_type_by<Tag,BimapType>::type iterator;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
value_type_by<Tag,BimapType>::type value_type;
iterator iter = derived().find(k);
if( iter == derived().end() )
{
iter = derived().insert( value_type(k,data_type_()) ).first;
}
return iter->second;
}
protected:
typedef mutable_data_unique_map_view_access
mutable_data_unique_map_view_access_;
private:
// Curiously Recurring Template interface.
Derived& derived()
{
return *static_cast<Derived*>(this);
}
Derived const& derived() const
{
return *static_cast<Derived const*>(this);
}
};
template< class Derived, class Tag, class BimapType>
class non_mutable_data_unique_map_view_access
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
data_type_by<Tag,BimapType>::type data_type_;
public:
template< class CompatibleKey >
const data_type_ & at(const CompatibleKey& k) const
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
const_iterator_type_by<Tag,BimapType>::type const_iterator;
const_iterator iter = derived().find(k);
if( iter == derived().end() )
{
::boost::throw_exception(
std::out_of_range("bimap<>: invalid key")
);
}
return iter->second;
}
template< class CompatibleKey >
data_type_ & operator[](const CompatibleKey& k)
{
BOOST_BIMAP_STATIC_ERROR( OPERATOR_BRACKET_IS_NOT_SUPPORTED, (Derived));
}
protected:
typedef non_mutable_data_unique_map_view_access
non_mutable_data_unique_map_view_access_;
private:
// Curiously Recurring Template interface.
Derived& derived()
{
return *static_cast<Derived*>(this);
}
Derived const& derived() const
{
return *static_cast<Derived const*>(this);
}
};
template< class Derived, class Tag, class BimapType>
struct unique_map_view_access
{
private:
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
value_type_by<Tag,BimapType>::type value_type;
public:
typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_
<
typename ::boost::is_const<
BOOST_DEDUCED_TYPENAME value_type::second_type >::type,
non_mutable_data_unique_map_view_access<Derived,Tag,BimapType>,
mutable_data_unique_map_view_access<Derived,Tag,BimapType>
>::type type;
};
// Map views specialize the following structs to provide to the bimap class
// the extra side typedefs (i.e. left_local_iterator for unordered_maps,
// right_range_type for maps)
template< class MapView >
struct left_map_view_extra_typedefs {};
template< class MapView >
struct right_map_view_extra_typedefs {};
} // namespace detail
// This function is already part of Boost.Lambda.
// They may be moved to Boost.Utility.
template <class T> inline const T& make_const(const T& t) { return t; }
} // namespace bimaps
} // namespace boost
// The following macros avoids code duplication in map views
// Maybe this can be changed in the future using a scheme similar to
// the one used with map_view_base.
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_RANGE_IMPLEMENTATION(BASE) \
\
typedef std::pair< \
BOOST_DEDUCED_TYPENAME base_::iterator, \
BOOST_DEDUCED_TYPENAME base_::iterator> range_type; \
\
typedef std::pair< \
BOOST_DEDUCED_TYPENAME base_::const_iterator, \
BOOST_DEDUCED_TYPENAME base_::const_iterator> const_range_type; \
\
\
template< class LowerBounder, class UpperBounder> \
range_type range(LowerBounder lower,UpperBounder upper) \
{ \
std::pair< \
\
BOOST_DEDUCED_TYPENAME BASE::base_type::iterator, \
BOOST_DEDUCED_TYPENAME BASE::base_type::iterator \
\
> r( this->base().range(lower,upper) ); \
\
return range_type( \
this->template functor< \
BOOST_DEDUCED_TYPENAME BASE::iterator_from_base \
>() ( r.first ), \
this->template functor< \
BOOST_DEDUCED_TYPENAME BASE::iterator_from_base \
>() ( r.second ) \
); \
} \
\
template< class LowerBounder, class UpperBounder> \
const_range_type range(LowerBounder lower,UpperBounder upper) const \
{ \
std::pair< \
\
BOOST_DEDUCED_TYPENAME BASE::base_type::const_iterator, \
BOOST_DEDUCED_TYPENAME BASE::base_type::const_iterator \
\
> r( this->base().range(lower,upper) ); \
\
return const_range_type( \
this->template functor< \
BOOST_DEDUCED_TYPENAME BASE::iterator_from_base \
>() ( r.first ), \
this->template functor< \
BOOST_DEDUCED_TYPENAME BASE::iterator_from_base \
>() ( r.second ) \
); \
}
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(BASE) \
\
template< class InputIterator > \
void assign(InputIterator first,InputIterator last) \
{ \
this->clear(); \
this->insert(this->end(),first,last); \
} \
\
void assign(BOOST_DEDUCED_TYPENAME BASE::size_type n, \
const BOOST_DEDUCED_TYPENAME BASE::value_type& v) \
{ \
this->clear(); \
for(BOOST_DEDUCED_TYPENAME BASE::size_type i = 0 ; i < n ; ++n) \
{ \
this->push_back(v); \
} \
}
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(BASE) \
\
BOOST_DEDUCED_TYPENAME BASE::reference front() \
{ \
return this->template functor< \
BOOST_DEDUCED_TYPENAME base_::value_from_base>() \
( \
const_cast \
< \
BOOST_DEDUCED_TYPENAME BASE::base_type::value_type & \
\
> ( this->base().front() ) \
); \
} \
\
BOOST_DEDUCED_TYPENAME BASE::reference back() \
{ \
return this->template functor< \
BOOST_DEDUCED_TYPENAME base_::value_from_base>() \
( \
const_cast \
< \
BOOST_DEDUCED_TYPENAME BASE::base_type::value_type & \
\
>( this->base().back() ) \
); \
} \
\
BOOST_DEDUCED_TYPENAME BASE::const_reference front() const \
{ \
return this->template functor< \
BOOST_DEDUCED_TYPENAME BASE::value_from_base>() \
( \
this->base().front() \
); \
} \
\
BOOST_DEDUCED_TYPENAME BASE::const_reference back() const \
{ \
return this->template functor< \
BOOST_DEDUCED_TYPENAME BASE::value_from_base>() \
( \
this->base().back() \
); \
}
/*===========================================================================*/
#endif // BOOST_BIMAP_DETAIL_MAP_VIEW_BASE_HPP

View File

@@ -0,0 +1,200 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/map_view_iterator.hpp
/// \brief Iterator adaptors from multi-index to bimap.
#ifndef BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP
#define BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
// Boost
#include <boost/serialization/nvp.hpp>
#include <boost/iterator/detail/enable_if.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/bimap/relation/support/pair_by.hpp>
namespace boost {
namespace bimaps {
namespace detail {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Tag, class Relation, class CoreIterator > struct map_view_iterator;
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
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/** \brief Map View Iterator adaptor from multi index to bimap.
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.
**/
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_;
public:
map_view_iterator() {}
map_view_iterator(CoreIterator const& iter)
: base_(iter) {}
map_view_iterator(map_view_iterator const & iter)
: base_(iter.base()) {}
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;
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
// Serialization support
BOOST_SERIALIZATION_SPLIT_MEMBER()
friend class ::boost::serialization::access;
template< class Archive >
void save(Archive & ar, const unsigned int version) const
{
ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
}
template< class Archive >
void load(Archive & ar, const unsigned int version)
{
CoreIterator iter;
ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
this->base_reference() = iter;
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
#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
> type;
};
#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.
**/
template< class Tag, class Relation, class CoreIterator >
struct const_map_view_iterator :
public const_map_view_iterator_base<Tag,Relation,CoreIterator>::type
{
typedef BOOST_DEDUCED_TYPENAME
const_map_view_iterator_base<Tag,Relation,CoreIterator>::type base_;
public:
const_map_view_iterator() {}
const_map_view_iterator(CoreIterator 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,Relation,CoreIterator> 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;
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
// Serialization support
BOOST_SERIALIZATION_SPLIT_MEMBER()
friend class ::boost::serialization::access;
template< class Archive >
void save(Archive & ar, const unsigned int version) const
{
ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
}
template< class Archive >
void load(Archive & ar, const unsigned int version)
{
CoreIterator iter;
ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
this->base_reference() = iter;
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
} // namespace detail
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP

View File

@@ -0,0 +1,89 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/modifier_adaptor.hpp
/// \brief A binary to unary functor relation modifier adaptor.
#ifndef BOOST_BIMAP_DETAIL_MODIFIER_ADAPTOR_HPP
#define BOOST_BIMAP_DETAIL_MODIFIER_ADAPTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <functional>
namespace boost {
namespace bimaps {
namespace detail {
/// \brief A binary to unary functor relation modifier adaptor.
template
<
class Modifier,
class NewArgument,
class FirstExtractor,
class SecondExtractor
>
struct relation_modifier_adaptor :
public std::unary_function<NewArgument,bool>,
Modifier,
FirstExtractor,
SecondExtractor
{
relation_modifier_adaptor( const Modifier & m ) : Modifier(m) {}
relation_modifier_adaptor( const Modifier & m,
const FirstExtractor & fe,
const SecondExtractor & se ) :
Modifier(m), FirstExtractor(fe), SecondExtractor(se) {}
void operator()( NewArgument & x ) const
{
Modifier::operator()(
FirstExtractor ::operator()( x ),
SecondExtractor::operator()( x )
);
}
};
/// \brief A simple unary modifier adaptor.
// This modifier is equivalent to bind( Modifier, bind( Extractor, _1 ) )
// It may be a good idea to start using Boost.Bind instead of it.
template
<
class Modifier,
class NewArgument,
class Extractor
>
struct unary_modifier_adaptor :
public std::unary_function<NewArgument,bool>,
Modifier,
Extractor
{
unary_modifier_adaptor( const Modifier & m ) : Modifier(m) {}
unary_modifier_adaptor( const Modifier & m,
const Extractor & fe) :
Modifier(m), Extractor(fe) {}
void operator()( NewArgument & x ) const
{
Modifier::operator()( Extractor::operator()( x ) );
}
};
} // namespace detail
} // namespace bimap
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_MODIFIER_ADAPTOR_HPP

View File

@@ -0,0 +1,71 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/non_unique_views_helper.hpp
/// \brief Details for non unique views
#ifndef BOOST_BIMAP_DETAIL_NON_UNIQUE_VIEWS_HELPER_HPP
#define BOOST_BIMAP_DETAIL_NON_UNIQUE_VIEWS_HELPER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
/*===========================================================================*/
#define BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS \
\
template <class InputIterator> \
void insert(InputIterator iterBegin, InputIterator iterEnd) \
{ \
for( ; iterBegin != iterEnd ; ++iterBegin ) \
{ \
this->base().insert( \
this->template functor< \
BOOST_DEDUCED_TYPENAME base_::value_to_base>()( \
BOOST_DEDUCED_TYPENAME base_::value_type(*iterBegin)) ); \
} \
} \
\
std::pair<BOOST_DEDUCED_TYPENAME base_::iterator, bool> insert( \
BOOST_DEDUCED_TYPENAME ::boost::call_traits< \
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x) \
{ \
typedef BOOST_DEDUCED_TYPENAME base_::base_type::iterator base_iterator; \
\
std::pair< base_iterator, bool > r( \
this->base().insert( \
this->template functor< \
BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x) ) \
); \
\
return std::pair<typename base_::iterator, bool>( \
this->template functor< \
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(r.first), \
r.second \
); \
} \
\
BOOST_DEDUCED_TYPENAME base_::iterator insert( \
BOOST_DEDUCED_TYPENAME base_::iterator pos, \
BOOST_DEDUCED_TYPENAME ::boost::call_traits< \
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x) \
{ \
return this->template functor< \
BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()( \
this->base().insert( \
this->template functor< \
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(pos), \
this->template functor< \
BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x)) \
); \
}
/*===========================================================================*/
#endif // BOOST_BIMAP_DETAIL_NON_UNIQUE_VIEWS_HELPER_HPP

View File

@@ -0,0 +1,331 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/set_view_base.hpp
/// \brief Helper base for the construction of the bimap views types.
#ifndef BOOST_BIMAP_DETAIL_SET_VIEW_BASE_HPP
#define BOOST_BIMAP_DETAIL_SET_VIEW_BASE_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/member_at.hpp>
#include <boost/bimap/relation/support/data_extractor.hpp>
#include <boost/bimap/detail/modifier_adaptor.hpp>
#include <boost/bimap/detail/set_view_iterator.hpp>
#include <boost/bimap/relation/support/get_pair_functor.hpp>
#include <boost/bimap/relation/detail/to_mutable_relation_functor.hpp>
#include <boost/bimap/relation/mutant_relation.hpp>
#include <boost/bimap/container_adaptor/support/iterator_facade_converters.hpp>
namespace boost {
namespace bimaps {
namespace detail {
template< class Key, class Value, class KeyToBase >
class set_view_key_to_base
{
public:
const Key operator()( const Value & v ) const
{
return keyToBase( v );
}
private:
KeyToBase keyToBase;
};
template< class MutantRelationStorage, class KeyToBase >
class set_view_key_to_base<MutantRelationStorage,MutantRelationStorage,KeyToBase>
{
typedef BOOST_DEDUCED_TYPENAME MutantRelationStorage::non_mutable_storage non_mutable_storage;
public:
const MutantRelationStorage & operator()( const non_mutable_storage & k ) const
{
return ::boost::bimaps::relation::detail::mutate<MutantRelationStorage>(k);
}
const MutantRelationStorage & operator()( const MutantRelationStorage & k ) const
{
return k;
}
};
// The next macro can be converted in a metafunctor to gain code robustness.
/*===========================================================================*/
#define BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( \
CONTAINER_ADAPTOR, CORE_INDEX, OTHER_ITER, CONST_OTHER_ITER \
) \
::boost::bimaps::container_adaptor::CONTAINER_ADAPTOR \
< \
CORE_INDEX, \
::boost::bimaps::detail:: \
set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator >, \
::boost::bimaps::detail:: \
const_set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator >, \
::boost::bimaps::detail:: \
set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::OTHER_ITER >, \
::boost::bimaps::detail:: \
const_set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::CONST_OTHER_ITER >, \
::boost::bimaps::container_adaptor::support::iterator_facade_to_base \
< \
::boost::bimaps::detail:: set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator>, \
::boost::bimaps::detail::const_set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator> \
\
>, \
::boost::mpl::na, \
::boost::mpl::na, \
::boost::bimaps::relation::detail:: \
get_mutable_relation_functor< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type >, \
::boost::bimaps::relation::support:: \
get_above_view_functor< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type >, \
::boost::bimaps::detail::set_view_key_to_base< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::key_type, \
BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type, \
BOOST_DEDUCED_TYPENAME CORE_INDEX::key_from_value \
> \
>
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR( \
CONTAINER_ADAPTOR, CORE_INDEX, OTHER_ITER, CONST_OTHER_ITER \
) \
::boost::bimaps::container_adaptor::CONTAINER_ADAPTOR \
< \
CORE_INDEX, \
::boost::bimaps::detail:: \
set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator >, \
::boost::bimaps::detail:: \
const_set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator >, \
::boost::bimaps::detail:: \
set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::OTHER_ITER >, \
::boost::bimaps::detail:: \
const_set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::CONST_OTHER_ITER >, \
::boost::bimaps::container_adaptor::support::iterator_facade_to_base \
< \
::boost::bimaps::detail:: set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator>, \
::boost::bimaps::detail::const_set_view_iterator< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator> \
\
>, \
::boost::mpl::na, \
::boost::mpl::na, \
::boost::bimaps::relation::detail:: \
get_mutable_relation_functor< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type >, \
::boost::bimaps::relation::support:: \
get_above_view_functor< \
BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type > \
>
/*===========================================================================*/
#if defined(BOOST_MSVC)
/*===========================================================================*/
#define BOOST_BIMAP_SET_VIEW_BASE_FRIEND(TYPE,INDEX_TYPE) \
typedef ::boost::bimaps::detail::set_view_base< \
TYPE< INDEX_TYPE >, INDEX_TYPE > template_class_friend; \
friend class template_class_friend;
/*===========================================================================*/
#else
/*===========================================================================*/
#define BOOST_BIMAP_SET_VIEW_BASE_FRIEND(TYPE,INDEX_TYPE) \
friend class ::boost::bimaps::detail::set_view_base< \
TYPE< INDEX_TYPE >, INDEX_TYPE >;
/*===========================================================================*/
#endif
/// \brief Common base for set views.
template< class Derived, class Index >
class set_view_base
{
typedef ::boost::bimaps::container_adaptor::support::
iterator_facade_to_base
<
::boost::bimaps::detail::
set_view_iterator<BOOST_DEDUCED_TYPENAME Index:: iterator>,
::boost::bimaps::detail::
const_set_view_iterator<BOOST_DEDUCED_TYPENAME Index::const_iterator>
> iterator_to_base_;
typedef BOOST_DEDUCED_TYPENAME Index::value_type::left_value_type left_type_;
typedef BOOST_DEDUCED_TYPENAME Index::value_type::right_value_type right_type_;
typedef BOOST_DEDUCED_TYPENAME Index::value_type value_type_;
typedef ::boost::bimaps::detail::
set_view_iterator<BOOST_DEDUCED_TYPENAME Index::iterator> iterator_;
public:
bool replace(iterator_ position,
const value_type_ & x)
{
return derived().base().replace(
derived().template functor<iterator_to_base_>()(position),x
);
}
template< class CompatibleLeftType >
bool replace_left(iterator_ position,
const CompatibleLeftType & l)
{
return derived().base().replace(
derived().template functor<iterator_to_base_>()(position),
value_type_(l,position->right)
);
}
template< class CompatibleRightType >
bool replace_right(iterator_ position,
const CompatibleRightType & r)
{
return derived().base().replace(
derived().template functor<iterator_to_base_>()(position),
value_type_(position->left,r)
);
}
/* This function may be provided in the future
template< class Modifier >
bool modify(iterator_ position,
Modifier mod)
{
return derived().base().modify(
derived().template functor<iterator_to_base_>()(position),
::boost::bimaps::detail::relation_modifier_adaptor
<
Modifier,
BOOST_DEDUCED_TYPENAME Index::value_type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
data_extractor
<
::boost::bimaps::relation::member_at::left,
BOOST_DEDUCED_TYPENAME Index::value_type
>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
data_extractor
<
::boost::bimaps::relation::member_at::right,
BOOST_DEDUCED_TYPENAME Index::value_type
>::type
>(mod)
);
}
*/
/*
template< class Modifier >
bool modify_left(iterator_ position, Modifier mod)
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
data_extractor
<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::member_at::right,
BOOST_DEDUCED_TYPENAME Index::value_type
>::type left_data_extractor_;
return derived().base().modify(
derived().template functor<iterator_to_base_>()(position),
// this may be replaced later by
// ::boost::bind( mod, ::boost::bind(data_extractor_(),_1) )
::boost::bimaps::detail::unary_modifier_adaptor
<
Modifier,
BOOST_DEDUCED_TYPENAME Index::value_type,
left_data_extractor_
>(mod)
);
}
template< class Modifier >
bool modify_right(iterator_ position, Modifier mod)
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
data_extractor
<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::member_at::right,
BOOST_DEDUCED_TYPENAME Index::value_type
>::type right_data_extractor_;
return derived().base().modify(
derived().template functor<iterator_to_base_>()(position),
// this may be replaced later by
// ::boost::bind( mod, ::boost::bind(data_extractor_(),_1) )
::boost::bimaps::detail::unary_modifier_adaptor
<
Modifier,
BOOST_DEDUCED_TYPENAME Index::value_type,
right_data_extractor_
>(mod)
);
}
*/
protected:
typedef set_view_base set_view_base_;
private:
// Curiously Recurring Template interface.
Derived& derived()
{
return *static_cast<Derived*>(this);
}
Derived const& derived() const
{
return *static_cast<Derived const*>(this);
}
};
} // namespace detail
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_SET_VIEW_BASE_HPP

View File

@@ -0,0 +1,193 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/set_view_iterator.hpp
/// \brief Iterator adaptors from multi-index to bimap.
#ifndef BOOST_BIMAP_DETAIL_SET_VIEW_ITERATOR_HPP
#define BOOST_BIMAP_DETAIL_SET_VIEW_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
// Boost
#include <boost/serialization/nvp.hpp>
#include <boost/iterator/detail/enable_if.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/bimap/relation/support/get_pair_functor.hpp>
namespace boost {
namespace bimaps {
namespace detail {
/** \brief Set View Iterator adaptor from multi index to bimap.
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.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class CoreIterator > struct set_view_iterator;
template< class CoreIterator >
struct set_view_iterator_base
{
typedef iterator_adaptor
<
set_view_iterator< CoreIterator >,
CoreIterator,
BOOST_DEDUCED_TYPENAME CoreIterator::value_type::above_view
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class CoreIterator >
struct set_view_iterator : public set_view_iterator_base<CoreIterator>::type
{
typedef BOOST_DEDUCED_TYPENAME set_view_iterator_base<CoreIterator>::type base_;
public:
set_view_iterator() {}
set_view_iterator(CoreIterator const& iter)
: base_(iter) {}
set_view_iterator(set_view_iterator const & iter)
: base_(iter.base()) {}
typename base_::reference dereference() const
{
return const_cast<
BOOST_DEDUCED_TYPENAME base_::base_type::value_type*>(
&(*this->base())
)->get_view();
}
private:
friend class iterator_core_access;
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
// Serialization support
BOOST_SERIALIZATION_SPLIT_MEMBER()
friend class ::boost::serialization::access;
template< class Archive >
void save(Archive & ar, const unsigned int version) const
{
ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
}
template< class Archive >
void load(Archive & ar, const unsigned int version)
{
CoreIterator iter;
ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
this->base_reference() = iter;
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class CoreIterator > struct const_set_view_iterator;
template< class CoreIterator >
struct const_set_view_iterator_base
{
typedef iterator_adaptor
<
const_set_view_iterator< CoreIterator >,
CoreIterator,
const BOOST_DEDUCED_TYPENAME CoreIterator::value_type::above_view
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/** \brief Const Set View Iterator adaptor from multi index to bimap.
See also set_view_iterator.
**/
template< class CoreIterator >
struct const_set_view_iterator : public const_set_view_iterator_base<CoreIterator>::type
{
typedef BOOST_DEDUCED_TYPENAME const_set_view_iterator_base<CoreIterator>::type base_;
public:
const_set_view_iterator() {}
const_set_view_iterator(CoreIterator const& iter)
: base_(iter) {}
const_set_view_iterator(const_set_view_iterator const & iter)
: base_(iter.base()) {}
const_set_view_iterator(set_view_iterator<CoreIterator> i)
: base_(i.base()) {}
BOOST_DEDUCED_TYPENAME base_::reference dereference() const
{
return this->base()->get_view();
}
private:
friend class iterator_core_access;
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
// Serialization support
BOOST_SERIALIZATION_SPLIT_MEMBER()
friend class ::boost::serialization::access;
template< class Archive >
void save(Archive & ar, const unsigned int version) const
{
ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
}
template< class Archive >
void load(Archive & ar, const unsigned int version)
{
CoreIterator iter;
ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
this->base_reference() = iter;
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
} // namespace detail
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP

View File

@@ -0,0 +1,113 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_BIMAP_DETAIL_CHECK_METADATA_HPP
#define BOOST_BIMAP_DETAIL_CHECK_METADATA_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/preprocessor/cat.hpp>
// Easier way to call BOOST_MPL_ASSERT_MSG in class scope
/*===========================================================================*/
#define BOOST_BIMAP_MPL_ASSERT_MSG_ACS(p1,p2,p3) \
\
struct p2 {}; \
BOOST_MPL_ASSERT_MSG(p1,p2,p3); \
/*===========================================================================*/
// Build a descriptive name.
/*===========================================================================*/
#define BOOST_BIMAP_WRONG_METADATA_MESSAGE( \
\
P_CLASS, \
P_NAME, \
P_CORRECT_TYPE \
\
) \
\
BOOST_PP_CAT \
( \
WRONG_METADATA__, \
BOOST_PP_CAT \
( \
P_CLASS, \
BOOST_PP_CAT \
( \
__AT__, \
BOOST_PP_CAT \
( \
P_NAME, \
BOOST_PP_CAT \
( \
__IS_DIFERENT_TO__, \
P_CORRECT_TYPE \
) \
) \
) \
) \
)
/*===========================================================================*/
// Check if the metadata have the correct type, and if not inform
// it with a useful compile time message.
/*===========================================================================*/
#define BOOST_BIMAP_CHECK_METADATA( \
\
P_CLASS, \
P_NAME, \
P_CORRECT_TYPE \
\
) \
\
BOOST_BIMAP_MPL_ASSERT_MSG_ACS \
( \
( \
::boost::is_same \
< \
P_CLASS::P_NAME, \
P_CORRECT_TYPE \
\
>::value \
), \
BOOST_BIMAP_WRONG_METADATA_MESSAGE \
( \
P_CLASS, \
P_NAME, \
P_CORRECT_TYPE \
), \
(P_CLASS::P_NAME,P_CORRECT_TYPE) \
)
/*===========================================================================*/
// Just for autodocumment the test code
/*===========================================================================*/
#define BOOST_BIMAP_TEST_STATIC_FUNCTION(NAME) \
namespace NAME
/*===========================================================================*/
// Just for autodocument the test code
/*===========================================================================*/
#define BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION(NAME)
/*===========================================================================*/
#endif // BOOST_BIMAP_DETAIL_CHECK_METADATA_HPP

View File

@@ -0,0 +1,24 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file detail/user_interface_config.hpp
/// \brief General configuration directives
#ifndef BOOST_BIMAP_DETAIL_USER_INTERFACE_CONFIG_HPP
#define BOOST_BIMAP_DETAIL_USER_INTERFACE_CONFIG_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#ifdef BOOST_BIMAP_DISABLE_SERIALIZATION
#define BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
#endif
#endif // BOOST_BIMAP_DETAIL_USER_INTERFACE_CONFIG_HPP

181
test/external/boost/bimap/list_of.hpp vendored Normal file
View File

@@ -0,0 +1,181 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file list_of.hpp
/// \brief Include support for list constrains for the bimap container
#ifndef BOOST_BIMAP_LIST_OF_HPP
#define BOOST_BIMAP_LIST_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/concept_check.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/bimap/detail/generate_index_binder.hpp>
#include <boost/bimap/detail/generate_view_binder.hpp>
#include <boost/bimap/detail/generate_relation_binder.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/bimap/views/list_map_view.hpp>
#include <boost/bimap/views/list_set_view.hpp>
namespace boost {
namespace bimaps {
/// \brief Set Type Specification
/**
This struct is used to specify a set specification.
It is not a container, it is just a metaprogramming facility to
express the type of a set. Generally, this specification will
be used in other place to create a container.
It has the same syntax that an std::list instantiation, except
that the allocator cannot be specified. The rationale behind
this difference is that the allocator is not part of the set
type specification, rather it is a container configuration
parameter.
\code
using namespace support;
BOOST_STATIC_ASSERT( is_set_type_of< list_of<Type> >::value )
BOOST_STATIC_ASSERT
(
is_same
<
list_of<Type>::index_bind
<
KeyExtractor,
Tag
>::type,
sequenced< tag<Tag>, KeyExtractor >
>::value
)
typedef bimap
<
list_of<Type>, RightKeyType
> bimap_with_left_type_as_list;
BOOST_STATIC_ASSERT
(
is_same
<
list_of<Type>::map_view_bind
<
member_at::left,
bimap_with_left_type_as_list
>::type,
list_map_view< member_at::left, bimap_with_left_type_as_list >
>::value
)
\endcode
See also list_of_relation.
**/
template< class Type >
struct list_of : public ::boost::bimaps::detail::set_type_of_tag
{
/// User type, can be tagged
typedef Type user_type;
/// Type of the object that will be stored in the list
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
value_type_of<user_type>::type value_type;
struct lazy_concept_checked
{
BOOST_CLASS_REQUIRE ( value_type,
boost, AssignableConcept );
typedef list_of type;
};
BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP_NO_EXTRACTOR(
// binds to
multi_index::sequenced
)
BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
// binds to
views::list_map_view
)
BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
// binds to
views::list_set_view
)
typedef mpl::bool_<true> mutable_key;
};
/// \brief List Of Relation Specification
/**
This struct is similar to list_of but it is bind logically to a
relation. It is used in the bimap instantiation to specify the
desired type of the main view. This struct implements internally
a metafunction named bind_to that manages the quite complicated
task of finding the right type of the set for the relation.
\code
template<class Relation>
struct bind_to
{
typedef -unspecified- type;
};
\endcode
See also list_of, is_set_type_of_relation.
**/
struct list_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
{
BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
// binds to
list_of
)
typedef mpl::bool_<true> left_mutable_key;
typedef mpl::bool_<true> right_mutable_key;
};
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_LIST_OF_HPP

View File

@@ -0,0 +1,205 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file multiset_of.hpp
/// \brief Include support for multiset constrains for the bimap container
#ifndef BOOST_BIMAP_MULTISET_OF_HPP
#define BOOST_BIMAP_MULTISET_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <functional>
#include <boost/mpl/bool.hpp>
#include <boost/concept_check.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/bimap/detail/generate_index_binder.hpp>
#include <boost/bimap/detail/generate_view_binder.hpp>
#include <boost/bimap/detail/generate_relation_binder.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/bimap/views/multimap_view.hpp>
#include <boost/bimap/views/multiset_view.hpp>
namespace boost {
namespace bimaps {
/// \brief Set Type Specification
/**
This struct is used to specify a multiset specification.
It is not a container, it is just a metaprogramming facility to
express the type of a set. Generally, this specification will
be used in other place to create a container.
It has the same syntax that an std::set instantiation, except
that the allocator cannot be specified. The rationale behind
this difference is that the allocator is not part of the set
type specification, rather it is a container configuration
parameter.
The first parameter is the type of the objects in the multiset,
and the second one is a Functor that compares them.
Bimap binding metafunctions can be used with this class in
the following way:
\code
using namespace support;
BOOST_STATIC_ASSERT( is_set_type_of< multiset_of<Type> >::value )
BOOST_STATIC_ASSERT
(
is_same
<
compute_index_type
<
multiset_of<Type,KeyCompare>,
KeyExtractor,
Tag
>::type
,
ordered_nonunique< tag<Tag>, KeyExtractor, KeyCompare >
>::value
)
typedef bimap
<
multiset_of<Type>, RightKeyType
> bimap_with_left_type_as_multiset;
BOOST_STATIC_ASSERT
(
is_same
<
compute_map_view_type
<
member_at::left,
bimap_with_left_type_as_multiset
>::type,
multimap_view< member_at::left, bimap_with_left_type_as_multiset >
>::value
)
\endcode
See also multiset_of_relation.
**/
template
<
class KeyType,
class KeyCompare = std::less< BOOST_DEDUCED_TYPENAME
::boost::bimaps::tags::support::value_type_of<KeyType>::type >
>
struct multiset_of : public ::boost::bimaps::detail::set_type_of_tag
{
/// User type, can be tagged
typedef KeyType user_type;
/// Type of the object that will be stored in the multiset
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
value_type_of<user_type>::type value_type;
/// Functor that compare two keys
typedef KeyCompare key_compare;
struct lazy_concept_checked
{
BOOST_CLASS_REQUIRE ( value_type,
boost, AssignableConcept );
BOOST_CLASS_REQUIRE4( key_compare, bool, value_type, value_type,
boost, BinaryFunctionConcept );
typedef multiset_of type;
};
BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
// binds to
multi_index::ordered_non_unique,
// with
key_compare
)
BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
// binds to
views::multimap_view
)
BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
// binds to
views::multiset_view
)
typedef mpl::bool_<false> mutable_key;
};
/// \brief Set Of Relation Specification
/**
This struct is similar to multiset_of but it is bind logically to a
relation. It is used in the bimap instantiation to specify the
desired type of the main view. This struct implements internally
a metafunction named bind_to that manages the quite complicated
task of finding the right type of the set for the relation.
\code
template<class Relation>
struct bind_to
{
typedef -unspecified- type;
};
\endcode
See also multiset_of, is_set_type_of_relation.
**/
template< class KeyCompare = std::less< _relation > >
struct multiset_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
{
/// Functor that compare two keys
typedef KeyCompare key_compare;
BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(
// binds to
multiset_of,
// with
key_compare
)
typedef mpl::bool_<false> left_mutable_key;
typedef mpl::bool_<false> right_mutable_key;
};
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_MULTISET_OF_HPP

View File

@@ -0,0 +1,55 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file property_map/set_support.hpp
/// \brief Support for the property map concept.
#ifndef BOOST_BIMAP_PROPERTY_MAP_SET_SUPPORT_HPP
#define BOOST_BIMAP_PROPERTY_MAP_SET_SUPPORT_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/bimap/set_of.hpp>
#include <boost/bimap/support/data_type_by.hpp>
#include <boost/bimap/support/key_type_by.hpp>
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
template< class Tag, class Bimap >
struct property_traits< ::boost::bimaps::views::map_view<Tag,Bimap> >
{
typedef BOOST_DEDUCED_TYPENAME
::boost::bimaps::support::data_type_by<Tag,Bimap>::type value_type;
typedef BOOST_DEDUCED_TYPENAME
::boost::bimaps::support:: key_type_by<Tag,Bimap>::type key_type;
typedef readable_property_map_tag category;
};
template< class Tag, class Bimap >
const BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::data_type_by<Tag,Bimap>::type &
get(const ::boost::bimaps::views::map_view<Tag,Bimap> & m,
const BOOST_DEDUCED_TYPENAME
::boost::bimaps::support::key_type_by<Tag,Bimap>::type & key)
{
return m.at(key);
}
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_PROPERTY_MAP_SET_SUPPORT_HPP

View File

@@ -0,0 +1,55 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file property_map/unordered_set_support.hpp
/// \brief Support for the property map concept.
#ifndef BOOST_BIMAP_PROPERTY_MAP_UNORDERED_SET_SUPPORT_HPP
#define BOOST_BIMAP_PROPERTY_MAP_UNORDERED_SET_SUPPORT_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/bimap/unordered_set_of.hpp>
#include <boost/bimap/support/data_type_by.hpp>
#include <boost/bimap/support/key_type_by.hpp>
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
template< class Tag, class Bimap >
struct property_traits< ::boost::bimaps::views::unordered_map_view<Tag,Bimap> >
{
typedef BOOST_DEDUCED_TYPENAME
::boost::bimaps::support::data_type_by<Tag,Bimap>::type value_type;
typedef BOOST_DEDUCED_TYPENAME
::boost::bimaps::support:: key_type_by<Tag,Bimap>::type key_type;
typedef readable_property_map_tag category;
};
template< class Tag, class Bimap >
const BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::data_type_by<Tag,Bimap>::type &
get(const ::boost::bimaps::views::unordered_map_view<Tag,Bimap> & m,
const BOOST_DEDUCED_TYPENAME
::boost::bimaps::support::key_type_by<Tag,Bimap>::type & key)
{
return m.at(key);
}
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_PROPERTY_MAP_UNORDERED_SET_SUPPORT_HPP

View File

@@ -0,0 +1,170 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/detail/access_builder.hpp
/// \brief Define macros to help building metafunctions
#ifndef BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP
#define BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/support/member_with_tag.hpp>
#include <boost/bimap/relation/member_at.hpp>
#include <boost/call_traits.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/utility/enable_if.hpp>
/******************************************************************************
BIMAP SYMMETRIC ACCESS RESULT OF
*******************************************************************************
namespace result_of {
template< class Tag, class SymmetricType >
struct NAME
{
typedef -unspecified- type;
};
} // namespace result_of
******************************************************************************/
/*===========================================================================*/
#define BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER( \
\
NAME, \
METAFUNCTION_BASE \
) \
\
namespace result_of { \
\
template< class Tag, class SymmetricType > \
struct NAME \
{ \
typedef BOOST_DEDUCED_TYPENAME METAFUNCTION_BASE \
< \
Tag,SymmetricType \
\
>::type value_type; \
\
typedef BOOST_DEDUCED_TYPENAME mpl::if_< is_const<SymmetricType>, \
\
BOOST_DEDUCED_TYPENAME call_traits<value_type>::const_reference, \
\
BOOST_DEDUCED_TYPENAME call_traits<value_type>::reference \
\
>::type type; \
}; \
\
}
/*===========================================================================*/
/******************************************************************************
BIMAP SYMMETRIC ACCESS IMPLEMENTATION
*******************************************************************************
namespace detail {
template< class Tag, class SymmetricType >
typename result_of::NAME<Tag,SymmetricType>::type
NAME( Tag , const Relation & );
} // namespace detail
******************************************************************************/
/*===========================================================================*/
#define BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER( \
\
NAME, \
TP_SYMMETRIC, \
PARAMETER_NAME, \
LEFT_BODY, \
RIGHT_BODY \
) \
\
namespace detail { \
\
\
\
template< class TP_SYMMETRIC > \
BOOST_DEDUCED_TYPENAME result_of::NAME \
< \
::boost::bimaps::relation::member_at::left,TP_SYMMETRIC \
\
>::type \
\
NAME( ::boost::bimaps::relation::member_at::left, \
TP_SYMMETRIC & PARAMETER_NAME ) \
{ \
LEFT_BODY; \
} \
\
template< class TP_SYMMETRIC > \
BOOST_DEDUCED_TYPENAME result_of::NAME \
< \
::boost::bimaps::relation::member_at::right,TP_SYMMETRIC \
\
>::type \
\
NAME( ::boost::bimaps::relation::member_at::right, \
TP_SYMMETRIC & PARAMETER_NAME ) \
{ \
RIGHT_BODY; \
} \
\
}
/*===========================================================================*/
/******************************************************************************
BIMAP RELATION ACCESS INTERFACE
*******************************************************************************
template< class Tag, class SymmetricType >
typename result_of::NAME<Tag,SymmetricType>::type
NAME( const SymmetricType & );
******************************************************************************/
/*===========================================================================*/
#define BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER( \
\
NAME \
) \
\
template< class Tag, class SymmetricType > \
BOOST_DEDUCED_TYPENAME result_of::NAME<Tag,SymmetricType>::type \
NAME( SymmetricType & s ) \
{ \
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support:: \
member_with_tag \
< \
Tag,SymmetricType \
\
>::type member_at_tag; \
\
return detail::NAME(member_at_tag(),s); \
}
/*===========================================================================*/
#endif // BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP

View File

@@ -0,0 +1,103 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/detail/metadata_access_builder.hpp
/// \brief Define macros to help building metafunctions
#ifndef BOOST_BIMAP_RELATION_DETAIL_METADATA_ACCESS_BUILDER_HPP
#define BOOST_BIMAP_RELATION_DETAIL_METADATA_ACCESS_BUILDER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/support/is_tag_of_member_at.hpp>
#include <boost/bimap/detail/debug/static_error.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/preprocessor/cat.hpp>
/******************************************************************************
BIMAP SYMMETRIC METADATA ACCESS INTERFACE
*******************************************************************************
template< class Tag, class SymmetricType >
struct NAME
{
typedef -unspecified- type;
};
******************************************************************************/
/*===========================================================================*/
#define BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER( \
\
NAME, \
METADATA_BY_LEFT, \
METADATA_BY_RIGHT \
) \
\
template \
< \
class Tag, \
class SymmetricType, \
class Enable = void \
> \
struct NAME \
{ \
BOOST_BIMAP_STATIC_ERROR( \
BOOST_PP_CAT(NAME,_FAILURE), \
(SymmetricType,Tag) \
); \
}; \
\
template< class Tag, class SymmetricType > \
struct NAME \
< \
Tag, SymmetricType, \
BOOST_DEDUCED_TYPENAME enable_if \
< \
::boost::bimaps::relation::support::is_tag_of_member_at_left \
< \
Tag, \
SymmetricType \
> \
\
>::type \
> \
{ \
typedef BOOST_DEDUCED_TYPENAME SymmetricType::METADATA_BY_LEFT type; \
}; \
\
template< class Tag, class SymmetricType > \
struct NAME \
< \
Tag, SymmetricType, \
BOOST_DEDUCED_TYPENAME enable_if \
< \
::boost::bimaps::relation::support::is_tag_of_member_at_right \
< \
Tag, \
SymmetricType \
> \
\
>::type \
> \
{ \
typedef BOOST_DEDUCED_TYPENAME SymmetricType::METADATA_BY_RIGHT type; \
};
/*===========================================================================*/
#endif // BOOST_BIMAP_RELATION_DETAIL_METADATA_ACCES_BUILDER_HPP

View File

@@ -0,0 +1,83 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/detail/mutant.hpp
/// \brief Mutate functions to extract views of mutant classes.
#ifndef BOOST_BIMAP_RELATION_DETAIL_MUTANT_HPP
#define BOOST_BIMAP_RELATION_DETAIL_MUTANT_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/debug/static_error.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/utility.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/not.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost {
namespace bimaps {
namespace relation {
/// \brief Relation details, mutant idiom and symmetrical metafunctions builders.
namespace detail {
//@{
/// \brief Converts a mutant class to a view with zero overhead.
/**
This function is a safe wrapper around reinterpret_cast. It checks at
compile time that the desired view is supported by the mutant class.
See also mutant, can_mutate_in.
\ingroup mutant_group
**/
template< class View, class Type >
BOOST_DEDUCED_TYPENAME enable_if< mpl::not_< is_const< Type > >,
View&
>::type mutate( Type & m )
{
BOOST_MPL_ASSERT((
::boost::mpl::contains<BOOST_DEDUCED_TYPENAME Type::mutant_views,View>
));
return *reinterpret_cast< View* >(boost::addressof(m));
}
template< class View, class Type >
BOOST_DEDUCED_TYPENAME enable_if< is_const< Type >,
const View&
>::type mutate( Type & m )
{
BOOST_MPL_ASSERT((
::boost::mpl::contains<BOOST_DEDUCED_TYPENAME Type::mutant_views,View>
));
return *reinterpret_cast< const View* >(boost::addressof(m));
}
//@}
} // namespace detail
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_DETAIL_MUTANT_HPP

View File

@@ -0,0 +1,105 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/detail/static_access_builder.hpp
/// \brief Define macros to help building metafunctions
#ifndef BOOST_BIMAP_RELATION_DETAIL_STATIC_ACCESS_BUILDER_HPP
#define BOOST_BIMAP_RELATION_DETAIL_STATIC_ACCESS_BUILDER_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/support/is_tag_of_member_at.hpp>
#include <boost/bimap/detail/debug/static_error.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/preprocessor/cat.hpp>
/******************************************************************************
BIMAP SYMMETRIC STATIC ACCESS INTERFACE
*******************************************************************************
template< class Tag, class SYMETRIC_TYPE >
struct NAME
{
-UNDEFINED BODY-;
};
******************************************************************************/
/*===========================================================================*/
#define BOOST_BIMAP_SYMMETRIC_STATIC_ACCESS_BUILDER( \
\
NAME, \
SYMMETRIC_TYPE, \
LEFT_BODY, \
RIGHT_BODY \
) \
\
template \
< \
class Tag, \
class SYMMETRIC_TYPE, \
class Enable = void \
> \
struct NAME \
{ \
BOOST_BIMAP_STATIC_ERROR( \
BOOST_PP_CAT(NAME,_FAILURE), \
(SYMMETRIC_TYPE,Tag) \
); \
}; \
\
template< class Tag, class SYMMETRIC_TYPE > \
struct NAME \
< \
Tag, SYMMETRIC_TYPE, \
BOOST_DEDUCED_TYPENAME enable_if \
< \
::boost::bimaps::relation::support::is_tag_of_member_at_left \
< \
Tag, \
SYMMETRIC_TYPE \
> \
\
>::type \
> \
{ \
LEFT_BODY; \
}; \
\
template< class Tag, class SYMMETRIC_TYPE > \
struct NAME \
< \
Tag, SYMMETRIC_TYPE, \
BOOST_DEDUCED_TYPENAME enable_if \
< \
::boost::bimaps::relation::support::is_tag_of_member_at_right \
< \
Tag, \
SYMMETRIC_TYPE \
> \
\
>::type \
> \
{ \
RIGHT_BODY; \
};
/*===========================================================================*/
#endif // BOOST_BIMAP_RELATION_DETAIL_STATIC_ACCES_BUILDER_HPP

View File

@@ -0,0 +1,102 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/detail/to_mutable_relation_functor.hpp
/// \brief functors to convert types to mutable relations
#ifndef BOOST_BIMAP_RELATION_DETAIL_TO_MUTABLE_RELATION_FUNCTOR_HPP
#define BOOST_BIMAP_RELATION_DETAIL_TO_MUTABLE_RELATION_FUNCTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/support/pair_type_by.hpp>
#include <boost/bimap/relation/detail/mutant.hpp>
#include <boost/bimap/relation/mutant_relation.hpp>
namespace boost {
namespace bimaps {
namespace relation {
namespace detail {
/// \brief Functor used in map views
template< class Tag, class Relation >
struct pair_to_relation_functor
{
const Relation
operator()(const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
pair_type_by<Tag,Relation>::type & p) const
{
return Relation(p);
}
};
template< class Tag, class TA, class TB, class Info >
struct pair_to_relation_functor<
Tag,::boost::bimaps::relation::mutant_relation<TA,TB,Info,true> >
{
typedef ::boost::bimaps::relation::mutant_relation<TA,TB,Info,true> Relation;
Relation &
operator()( BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
pair_type_by<Tag,Relation>::type & p ) const
{
return ::boost::bimaps::relation::detail::mutate<Relation>(p);
}
const Relation &
operator()( const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
pair_type_by<Tag,Relation>::type & p) const
{
return ::boost::bimaps::relation::detail::mutate<Relation>(p);
}
};
/// \brief Used in set views
template< class Relation >
struct get_mutable_relation_functor
{
const Relation
operator()( const BOOST_DEDUCED_TYPENAME Relation::above_view & r ) const
{
return Relation(r);
}
};
template< class TA, class TB, class Info >
struct get_mutable_relation_functor< ::boost::bimaps::relation::mutant_relation<TA,TB,Info,true> >
{
typedef ::boost::bimaps::relation::mutant_relation<TA,TB,Info,true> Relation;
Relation &
operator()( BOOST_DEDUCED_TYPENAME Relation::above_view & r ) const
{
return ::boost::bimaps::relation::detail::mutate<Relation>(r);
}
const Relation &
operator()( const BOOST_DEDUCED_TYPENAME Relation::above_view & r ) const
{
return ::boost::bimaps::relation::detail::mutate<Relation>(r);
}
};
} // namespace detail
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_DETAIL_TO_MUTABLE_RELATION_FUNCTOR_HPP

View File

@@ -0,0 +1,72 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/member_at.hpp
/// \brief Defines the tags for the member_at::side idiom
#ifndef BOOST_BIMAP_RELATION_MEMBER_AT_HPP
#define BOOST_BIMAP_RELATION_MEMBER_AT_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
namespace boost {
namespace bimaps {
namespace relation {
/// \brief member_at::side idiom to access relation values and types using metaprogramming.
/**
This tags are used to specify which member you want to acces when using a metafunction over
a symmetrical type. The idea is to be able to write code like:
\code
result_of::get<member_at::left,relation>::type data = get<member_at::left>(rel);
\endcode
The relation class supports this idiom even when the elements are tagged. This is useful
because a user can decide to start tagging in any moment of the development.
See also member_with_tag, is_tag_of_member_at_left, is_tag_of_member_at_right, get
value_type_of, pair_by, pair_type_by.
\ingroup relation_group
**/
namespace member_at {
/// \brief Member at left tag
/**
See also member_at, rigth.
**/
struct left {};
/// \brief Member at right tag
/**
See also member_at, left.
**/
struct right {};
/// \brief Member info tag
/**
See also member_at, left, right.
**/
struct info {};
}
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_MEMBER_AT_HPP

View File

@@ -0,0 +1,430 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/mutant_relation.hpp
/// \brief Defines the mutant_relation class
#ifndef BOOST_BIMAP_RELATION_MUTANT_RELATION_HPP
#define BOOST_BIMAP_RELATION_MUTANT_RELATION_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/operators.hpp>
#include <boost/call_traits.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/functional/hash/hash.hpp>
#include <boost/mpl/aux_/na.hpp>
// Boost.Bimap
#include <boost/bimap/tags/tagged.hpp>
#include <boost/bimap/tags/support/default_tagged.hpp>
#include <boost/bimap/tags/support/tag_of.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/bimap/relation/member_at.hpp>
#include <boost/bimap/relation/detail/mutant.hpp>
#include <boost/bimap/relation/structured_pair.hpp>
#include <boost/bimap/relation/symmetrical_base.hpp>
#include <boost/bimap/relation/support/get.hpp>
namespace boost {
namespace bimaps {
namespace relation {
namespace detail {
// This class is included so structured_pair and mutant_relation share
// exactly the same class layout
template< class LeftType, class RightType, bool force_mutable >
class relation_storage :
public symmetrical_base<LeftType,RightType,force_mutable>
{
typedef symmetrical_base<LeftType,RightType,force_mutable> base_;
typedef relation_storage storage_;
public:
typedef relation_storage<LeftType,RightType,false> non_mutable_storage;
typedef ::boost::mpl::vector2
<
relation_storage< LeftType, RightType, true >,
relation_storage< LeftType, RightType, false >
> mutant_views;
//@{
/// data
BOOST_DEDUCED_TYPENAME base_::left_value_type left;
BOOST_DEDUCED_TYPENAME base_::right_value_type right;
//@}
relation_storage() {}
relation_storage(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::left_value_type
>::param_type l,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::right_value_type
>::param_type r)
: left(l), right(r) {}
BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left() { return left; }
const BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left()const { return left; }
BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right() { return right; }
const BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right()const { return right; }
};
template< class TA, class TB, class Info, bool force_mutable >
class relation_info_hook : public
::boost::bimaps::relation::detail::relation_storage<TA,TB,force_mutable>
{
typedef ::boost::bimaps::relation::detail::
relation_storage<TA,TB,force_mutable> base_;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
default_tagged<Info,member_at::info>::type tagged_info_type;
public:
typedef BOOST_DEDUCED_TYPENAME tagged_info_type::value_type info_type;
typedef BOOST_DEDUCED_TYPENAME tagged_info_type::tag info_tag;
info_type info;
protected:
relation_info_hook() {}
relation_info_hook( BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::left_value_type
>::param_type l,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::right_value_type
>::param_type r,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
info_type
>::param_type i = info_type() )
: base_(l,r), info(i) {}
template< class Relation >
relation_info_hook( const Relation & rel ) :
base_(rel.left,rel.right),
info(rel.info) {}
template< class Relation >
void change_to( const Relation & rel )
{
base_::left = rel.left ;
base_::right = rel.right;
info = rel.info ;
}
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
template< class Archive >
void serialize(Archive & ar, const unsigned int version)
{
ar & ::boost::serialization::make_nvp("left" , base_::left );
ar & ::boost::serialization::make_nvp("right", base_::right);
ar & ::boost::serialization::make_nvp("info" , info );
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
template< class TA, class TB, bool force_mutable>
class relation_info_hook<TA,TB,::boost::mpl::na,force_mutable> :
public ::boost::bimaps::relation::detail::relation_storage<TA,TB,force_mutable>
{
typedef ::boost::bimaps::relation::detail::
relation_storage<TA,TB,force_mutable> base_;
public:
typedef ::boost::mpl::na info_type;
typedef member_at::info info_tag;
protected:
relation_info_hook() {}
relation_info_hook( BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::left_value_type
>::param_type l,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::right_value_type
>::param_type r)
: base_(l,r) {}
template< class Relation >
relation_info_hook( const Relation & rel ) :
base_(rel.left,rel.right) {}
template< class Relation >
void change_to( const Relation & rel )
{
base_::left = rel.left ;
base_::right = rel.right;
}
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
template< class Archive >
void serialize(Archive & ar, const unsigned int version)
{
ar & ::boost::serialization::make_nvp("left" , base_::left );
ar & ::boost::serialization::make_nvp("right", base_::right);
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
} // namespace detail
/// \brief Abstraction of a related pair of values, that extends the std::pair class.
/**
The mutant_relation is a mutant class. A mutant class can mutate
with zero overhead in other classes that are called views.
Each view has to be StorageCompatible with the base class
of the mutant. Note that all the views have the following
storage structure:
\verbatim
__________
| |
| TA |
|__________|
| |
| TB |
|__________|
\endverbatim
See also select_relation, standard_relation.
\ingroup relation_group
**/
template< class TA, class TB, class Info = ::boost::mpl::na, bool force_mutable = false >
class mutant_relation : public
::boost::bimaps::relation::detail::
relation_info_hook<TA,TB,Info,force_mutable>
{
typedef ::boost::bimaps::relation::detail::
relation_info_hook<TA,TB,Info,force_mutable> base_;
public:
// We have to know the type of the base where the types are
// defined because Boost.MultiIndex requires it.
typedef ::boost::bimaps::relation::detail::
relation_storage<TA,TB,force_mutable> storage_base;
/// Above view, non mutable view of the relation
typedef mutant_relation<TA,TB,Info,false> above_view;
//@{
/// A signature compatible std::pair that is a view of the relation.
typedef structured_pair< TA, TB, Info, normal_layout > left_pair;
typedef structured_pair< TB, TA, Info, mirror_layout > right_pair;
//@}
typedef ::boost::mpl::vector4
<
left_pair,
right_pair,
mutant_relation< TA, TB, Info, true >,
mutant_relation< TA, TB, Info, false >
> mutant_views;
mutant_relation() {}
mutant_relation(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_:: left_value_type
>::param_type l,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::right_value_type
>::param_type r) :
base_(l,r) {}
mutant_relation(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_:: left_value_type
>::param_type l,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::right_value_type
>::param_type r,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::info_type
>::param_type i) :
base_(l,r,i) {}
mutant_relation(const mutant_relation<TA,TB,Info,false> & rel) :
base_(rel) {}
mutant_relation(const mutant_relation<TA,TB,Info,true> & rel) :
base_(rel) {}
// Operators
template< bool FM >
mutant_relation& operator=(const mutant_relation<TA,TB,Info,FM> & rel)
{
base_::change_to(rel);
return *this;
}
// The following functions are redundant if you only consider this class.
// They are included to make easier the construction of the get and the
// pair_by metafunction. Remember that not all compiler supports the mutant
// idiom.
left_pair & get_left_pair()
{
return ::boost::bimaps::relation::detail::mutate<left_pair>(*this);
}
const left_pair & get_left_pair() const
{
return ::boost::bimaps::relation::detail::mutate<left_pair>(*this);
}
right_pair & get_right_pair()
{
return ::boost::bimaps::relation::detail::mutate<right_pair>(*this);
}
const right_pair & get_right_pair() const
{
return ::boost::bimaps::relation::detail::mutate<right_pair>(*this);
}
above_view & get_view()
{
return ::boost::bimaps::relation::detail::mutate<above_view>(*this);
}
const above_view & get_view() const
{
return ::boost::bimaps::relation::detail::mutate<above_view>(*this);
}
template< class Tag >
const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
result_of::get<Tag,const mutant_relation>::type
get(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag)) const
{
return ::boost::bimaps::relation::support::get<Tag>(*this);
}
template< class Tag >
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
result_of::get<Tag,mutant_relation>::type
get(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag))
{
return ::boost::bimaps::relation::support::get<Tag>(*this);
}
#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
private:
friend class ::boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
base_::serialize(ar,version);
}
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION
};
// hash value
template< class FirstType, class SecondType, bool FM >
std::size_t hash_value(const detail::relation_storage<FirstType,SecondType,FM> & r)
{
std::size_t seed = 0;
::boost::hash_combine(seed, r. left );
::boost::hash_combine(seed, r.right );
return seed;
}
// mutant_relation - mutant_relation
template< class FirstType, class SecondType, bool FM1, bool FM2 >
bool operator==(const detail::relation_storage<FirstType,SecondType,FM1> & a,
const detail::relation_storage<FirstType,SecondType,FM2> & b)
{
return ( ( a.left == b.left ) &&
( a.right == b.right ) );
}
template< class FirstType, class SecondType, bool FM1, bool FM2 >
bool operator!=(const detail::relation_storage<FirstType,SecondType,FM1> & a,
const detail::relation_storage<FirstType,SecondType,FM2> & b)
{
return ! ( a == b );
}
template< class FirstType, class SecondType, bool FM1, bool FM2 >
bool operator<(const detail::relation_storage<FirstType,SecondType,FM1> & a,
const detail::relation_storage<FirstType,SecondType,FM2> & b)
{
return ( ( a.left < b.left ) ||
(( a.left == b.left ) && ( a.right < b.right )));
}
template< class FirstType, class SecondType, bool FM1, bool FM2 >
bool operator<=(const detail::relation_storage<FirstType,SecondType,FM1> & a,
const detail::relation_storage<FirstType,SecondType,FM2> & b)
{
return ( ( a.left < b.left ) ||
(( a.left == b.left ) && ( a.right <= b.right )));
}
template< class FirstType, class SecondType, bool FM1, bool FM2 >
bool operator>(const detail::relation_storage<FirstType,SecondType,FM1> & a,
const detail::relation_storage<FirstType,SecondType,FM2> & b)
{
return ( ( a.left > b.left ) ||
(( a.left == b.left ) && ( a.right > b.right )));
}
template< class FirstType, class SecondType, bool FM1, bool FM2 >
bool operator>=(const detail::relation_storage<FirstType,SecondType,FM1> & a,
const detail::relation_storage<FirstType,SecondType,FM2> & b)
{
return ( ( a.left > b.left ) ||
(( a.left == b.left ) && ( a.right >= b.right )));
}
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_MUTANT_RELATION_HPP

View File

@@ -0,0 +1,72 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/pair_layout.hpp
/// \brief Tags for pair layouts
#ifndef BOOST_BIMAP_RELATION_PAIR_LAYOUT_HPP
#define BOOST_BIMAP_RELATION_PAIR_LAYOUT_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
namespace boost {
namespace bimaps {
namespace relation {
//@{
/// \brief Tag for normal layout. ( A,B -> A,B )
struct normal_layout {};
/// \brief Tag for mirror layout. ( A,B -> B,A )
struct mirror_layout {};
//@}
/** \struct boost::bimaps::relation::inverse_layout
\brief Metafunction to obtain the inverse of a layout.
\code
template< class Layout >
struct inverse_layout
{
typedef {InverseLayout} type;
};
\endcode
See also normal_layout, mirror_layout.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Layout >
struct inverse_layout
{
typedef normal_layout type;
};
template<>
struct inverse_layout< normal_layout >
{
typedef mirror_layout type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_DETAIL_PAIR_LAYOUT_HPP

View File

@@ -0,0 +1,508 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/structured_pair.hpp
/// \brief Defines the structured_pair class.
#ifndef BOOST_BIMAP_RELATION_STRUCTURED_PAIR_HPP
#define BOOST_BIMAP_RELATION_STRUCTURED_PAIR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <utility>
#include <boost/type_traits/remove_const.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/call_traits.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/bimap/detail/debug/static_error.hpp>
#include <boost/bimap/relation/pair_layout.hpp>
#include <boost/bimap/relation/symmetrical_base.hpp>
#include <boost/bimap/relation/support/get.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
namespace boost {
namespace bimaps {
namespace relation {
namespace detail {
/// \brief Storage definition of the left view of a mutant relation.
/**
See also storage_finder, mirror_storage.
**/
template< class FirstType, class SecondType >
class normal_storage :
public symmetrical_base<FirstType,SecondType>
{
typedef symmetrical_base<FirstType,SecondType> base_;
public:
typedef normal_storage storage_;
typedef BOOST_DEDUCED_TYPENAME base_::left_value_type first_type;
typedef BOOST_DEDUCED_TYPENAME base_::right_value_type second_type;
first_type first;
second_type second;
normal_storage() {}
normal_storage(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
first_type >::param_type f,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
second_type>::param_type s)
: first(f), second(s) {}
BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left() { return first; }
const BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left()const { return first; }
BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right() { return second; }
const BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right()const { return second; }
};
/// \brief Storage definition of the right view of a mutant relation.
/**
See also storage_finder, normal_storage.
**/
template< class FirstType, class SecondType >
class mirror_storage :
public symmetrical_base<SecondType,FirstType>
{
typedef symmetrical_base<SecondType,FirstType> base_;
public:
typedef mirror_storage storage_;
typedef BOOST_DEDUCED_TYPENAME base_::left_value_type second_type;
typedef BOOST_DEDUCED_TYPENAME base_::right_value_type first_type;
second_type second;
first_type first;
mirror_storage() {}
mirror_storage(BOOST_DEDUCED_TYPENAME ::boost::call_traits<first_type >::param_type f,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<second_type >::param_type s)
: second(s), first(f) {}
BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left() { return second; }
const BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left()const { return second; }
BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right() { return first; }
const BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right()const { return first; }
};
/** \struct boost::bimaps::relation::storage_finder
\brief Obtain the a storage with the correct layout.
\code
template< class FirstType, class SecondType, class Layout >
struct storage_finder
{
typedef {normal/mirror}_storage<FirstType,SecondType> type;
};
\endcode
See also normal_storage, mirror_storage.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template
<
class FirstType,
class SecondType,
class Layout
>
struct storage_finder
{
typedef normal_storage<FirstType,SecondType> type;
};
template
<
class FirstType,
class SecondType
>
struct storage_finder<FirstType,SecondType,mirror_layout>
{
typedef mirror_storage<FirstType,SecondType> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class TA, class TB, class Info, class Layout >
class pair_info_hook :
public ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type base_;
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
default_tagged<Info,member_at::info>::type tagged_info_type;
public:
typedef BOOST_DEDUCED_TYPENAME tagged_info_type::value_type info_type;
typedef BOOST_DEDUCED_TYPENAME tagged_info_type::tag info_tag;
info_type info;
protected:
pair_info_hook() {}
pair_info_hook( BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::first_type
>::param_type f,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::second_type
>::param_type s,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
info_type
>::param_type i = info_type() )
: base_(f,s), info(i) {}
template< class Pair >
pair_info_hook( const Pair & p) :
base_(p.first,p.second),
info(p.info) {}
template< class Pair >
void change_to( const Pair & p )
{
base_::first = p.first ;
base_::second = p.second;
info = p.info ;
}
void clear_info()
{
info = info_type();
};
};
template< class TA, class TB, class Layout>
class pair_info_hook<TA,TB,::boost::mpl::na,Layout> :
public ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type base_;
public:
typedef ::boost::mpl::na info_type;
typedef member_at::info info_tag;
protected:
pair_info_hook() {}
pair_info_hook( BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::first_type
>::param_type f,
BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::second_type
>::param_type s)
: base_(f,s) {}
template< class Pair >
pair_info_hook( const Pair & p ) :
base_(p.first,p.second) {}
template< class Pair >
void change_to( const Pair & p )
{
base_::first = p.first ;
base_::second = p.second;
}
void clear_info() {};
};
} // namespace detail
template< class TA, class TB, class Info, bool FM >
class mutant_relation;
/// \brief A std::pair signature compatible class that allows you to control
/// the internal structure of the data.
/**
This class allows you to specify the order in wich the two data types will be
in the layout of the class.
**/
template< class FirstType, class SecondType, class Info, class Layout = normal_layout >
class structured_pair :
public ::boost::bimaps::relation::detail::pair_info_hook
<
FirstType, SecondType,
Info,
Layout
>
{
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::detail::pair_info_hook
<
FirstType, SecondType,
Info,
Layout
> base_;
public:
typedef ::boost::mpl::vector3<
structured_pair< FirstType, SecondType, Info, normal_layout >,
structured_pair< FirstType, SecondType, Info, mirror_layout >,
BOOST_DEDUCED_TYPENAME ::boost::mpl::if_<
BOOST_DEDUCED_TYPENAME ::boost::is_same<Layout, normal_layout>::type,
mutant_relation< FirstType, SecondType, Info, true >,
mutant_relation< SecondType, FirstType, Info, true >
>::type
> mutant_views;
structured_pair() {}
structured_pair(BOOST_DEDUCED_TYPENAME boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::first_type >::param_type f,
BOOST_DEDUCED_TYPENAME boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::second_type >::param_type s)
: base_(f,s) {}
structured_pair(BOOST_DEDUCED_TYPENAME boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::first_type >::param_type f,
BOOST_DEDUCED_TYPENAME boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::second_type >::param_type s,
BOOST_DEDUCED_TYPENAME boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::info_type >::param_type i)
: base_(f,s,i) {}
template< class OtherLayout >
structured_pair(
const structured_pair<FirstType,SecondType,Info,OtherLayout> & p)
: base_(p) {}
template< class OtherLayout >
structured_pair& operator=(
const structured_pair<FirstType,SecondType,OtherLayout> & p)
{
base_::change_to(p);
return *this;
}
template< class First, class Second >
structured_pair(const std::pair<First,Second> & p) :
base_(p.first,p.second)
{}
template< class First, class Second >
structured_pair& operator=(const std::pair<First,Second> & p)
{
base_::first = p.first;
base_::second = p.second;
base_::clear_info();
return *this;
}
template< class Tag >
const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
result_of::get<Tag,const structured_pair>::type
get(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag)) const
{
return ::boost::bimaps::relation::support::get<Tag>(*this);
}
template< class Tag >
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
result_of::get<Tag,structured_pair>::type
get(BOOST_EXPLICIT_TEMPLATE_TYPE(Tag))
{
return ::boost::bimaps::relation::support::get<Tag>(*this);
}
};
// structured_pair - structured_pair
template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
bool operator==(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
const structured_pair<FirstType,SecondType,Info,Layout2> & b)
{
return ( ( a.first == b.first ) &&
( a.second == b.second ) );
}
template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
bool operator!=(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
const structured_pair<FirstType,SecondType,Info,Layout2> & b)
{
return ! ( a == b );
}
template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
bool operator<(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
const structured_pair<FirstType,SecondType,Info,Layout2> & b)
{
return ( ( a.first < b.first ) ||
(( a.first == b.first ) && ( a.second < b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
bool operator<=(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
const structured_pair<FirstType,SecondType,Info,Layout2> & b)
{
return ( ( a.first < b.first ) ||
(( a.first == b.first ) && ( a.second <= b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
bool operator>(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
const structured_pair<FirstType,SecondType,Info,Layout2> & b)
{
return ( ( a.first > b.first ) ||
(( a.first == b.first ) && ( a.second > b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
bool operator>=(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
const structured_pair<FirstType,SecondType,Info,Layout2> & b)
{
return ( ( a.first > b.first ) ||
(( a.first == b.first ) && ( a.second >= b.second )));
}
// structured_pair - std::pair
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator==(const structured_pair<FirstType,SecondType,Info,Layout> & a,
const std::pair<F,S> & b)
{
return ( ( a.first == b.first ) &&
( a.second == b.second ) );
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator!=(const structured_pair<FirstType,SecondType,Info,Layout> & a,
const std::pair<F,S> & b)
{
return ! ( a == b );
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator<(const structured_pair<FirstType,SecondType,Info,Layout> & a,
const std::pair<F,S> & b)
{
return ( ( a.first < b.first ) ||
(( a.first == b.first ) && ( a.second < b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator<=(const structured_pair<FirstType,SecondType,Info,Layout> & a,
const std::pair<F,S> & b)
{
return ( ( a.first < b.first ) ||
(( a.first == b.first ) && ( a.second <= b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator>(const structured_pair<FirstType,SecondType,Info,Layout> & a,
const std::pair<F,S> & b)
{
return ( ( a.first > b.first ) ||
(( a.first == b.first ) && ( a.second > b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator>=(const structured_pair<FirstType,SecondType,Info,Layout> & a,
const std::pair<F,S> & b)
{
return ( ( a.first > b.first ) ||
(( a.first == b.first ) && ( a.second >= b.second )));
}
// std::pair - sturctured_pair
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator==(const std::pair<F,S> & a,
const structured_pair<FirstType,SecondType,Info,Layout> & b)
{
return ( ( a.first == b.first ) &&
( a.second == b.second ) );
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator!=(const std::pair<F,S> & a,
const structured_pair<FirstType,SecondType,Info,Layout> & b)
{
return ! ( a == b );
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator<(const std::pair<F,S> & a,
const structured_pair<FirstType,SecondType,Info,Layout> & b)
{
return ( ( a.first < b.first ) ||
(( a.first == b.first ) && ( a.second < b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator<=(const std::pair<F,S> & a,
const structured_pair<FirstType,SecondType,Info,Layout> & b)
{
return ( ( a.first < b.first ) ||
(( a.first == b.first ) && ( a.second <= b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator>(const std::pair<F,S> & a,
const structured_pair<FirstType,SecondType,Info,Layout> & b)
{
return ( ( a.first > b.first ) ||
(( a.first == b.first ) && ( a.second > b.second )));
}
template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
bool operator>=(const std::pair<F,S> & a,
const structured_pair<FirstType,SecondType,Info,Layout> & b)
{
return ( ( a.first > b.first ) ||
(( a.first == b.first ) && ( a.second >= b.second )));
}
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_STRUCTURED_PAIR_HPP

View File

@@ -0,0 +1,110 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/data_extractor.hpp
/// \brief Data extraction functor.
#ifndef BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
#include <functional>
/** \struct boost::bimaps::relation::support::data_extractor
\brief Data extraction functor.
\ingroup relation_group
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
template< class Tag, class Relation >
struct data_extractor_implementation;
template< class Relation >
struct data_extractor_implementation< member_at::left, Relation > :
public std::unary_function<Relation,BOOST_DEDUCED_TYPENAME Relation::left_value_type>
{
BOOST_DEDUCED_TYPENAME Relation::left_value_type const &
operator()(Relation const & rel) const
{
return rel.left;
}
BOOST_DEDUCED_TYPENAME Relation::left_value_type &
operator()(Relation & rel) const
{
return rel.left;
}
};
template< class Relation >
struct data_extractor_implementation< member_at::right, Relation > :
public std::unary_function<Relation,BOOST_DEDUCED_TYPENAME Relation::right_value_type>
{
BOOST_DEDUCED_TYPENAME Relation::right_value_type const &
operator()(Relation const & rel) const
{
return rel.right;
}
BOOST_DEDUCED_TYPENAME Relation::right_value_type &
operator()(Relation & rel) const
{
return rel.right;
}
};
template< class Tag, class Relation >
struct data_extractor
{
typedef data_extractor_implementation
<
BOOST_DEDUCED_TYPENAME member_with_tag<Tag,Relation>::type,
Relation
> type;
};
template< class Relation >
struct both_keys_extractor
{
typedef BOOST_DEDUCED_TYPENAME Relation::storage_base result_type;
const result_type & operator()(const Relation & rel) const
{
return rel;
}
result_type & operator()( Relation & rel) const
{
return rel;
}
};
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP

View File

@@ -0,0 +1,140 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/get.hpp
/// \brief get<tag>(r) function
#ifndef BOOST_BIMAP_RELATION_SUPPORT_GET_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_GET_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/support/value_type_of.hpp>
#include <boost/bimap/relation/detail/access_builder.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_const.hpp>
#ifdef BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
/** \brief Gets a pair view of the relation.
\ingroup relation_group
**/
template< class Tag, class SymmetricType >
BOOST_DEDUCED_TYPENAME result_of::get<Tag,SymmetricType>::type
get( SymmetricType & );
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
// Since it is very error-prone to directly write the hole bunch
// of relation accesor. They are buil from litle macro blocks that
// are both more readable, leading to self docummenting code and a
// lot more easier to understand and mantain.
// It is very important to note that the three building blocks have
// to laid in the same namespace in order to work. There is also
// important to keep them in order.
// The forward declaration are not necesary but they help a lot to
// the reader, as they undercover what is the signature of the
// result code.
// In the end, it is not quicker to do it in this way because you
// write a lot. But this code has no complexity at all and almost
// every word writed is for documentation.
// Result of
// -------------------------------------------------------------------------
/*
namespace result_of {
template< class Tag, class Relation >
struct get<Tag,Relation>;
{
typedef -unspecified- type;
};
} // namespace result_of
*/
BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER
(
get,
value_type_of
)
// Implementation
// -------------------------------------------------------------------------
BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER
(
get,
SymmetricType,
st,
return st.get_left(),
return st.get_right()
)
namespace detail {
template< class SymmetricType >
BOOST_DEDUCED_TYPENAME result_of::get<
::boost::bimaps::relation::member_at::info, SymmetricType >::type
get(::boost::bimaps::relation::member_at::info, SymmetricType & rel)
{
return rel.info;
}
} // namespace detail
// Interface
//----------------------------------------------------------------------------
BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER
(
get
)
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_RELATION_SUPPORT_GET_HPP

View File

@@ -0,0 +1,85 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/get_pair_functor.hpp
/// \brief get_pair_functor definition
#ifndef BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/support/pair_by.hpp>
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
/// \brief A Functor that takes a relation as a parameter an return the desired view.
/**
This functor is included to help users of the relation class when using
stl algorithms.
See also member_at, pair_by().
\ingroup relation_group
**/
template< class Tag, class Relation >
struct get_pair_functor
{
BOOST_DEDUCED_TYPENAME result_of::pair_by<Tag,Relation>::type
operator()( Relation & r ) const
{
return pair_by<Tag>(r);
}
BOOST_DEDUCED_TYPENAME result_of::pair_by<Tag,const Relation>::type
operator()( const Relation & r ) const
{
return pair_by<Tag>(r);
}
};
/// \brief A Functor that takes a relation as a parameter an return the above view.
/**
\ingroup relation_group
**/
template< class Relation >
struct get_above_view_functor
{
BOOST_DEDUCED_TYPENAME Relation::above_view &
operator()( Relation & r ) const
{
return r.get_view();
}
const BOOST_DEDUCED_TYPENAME Relation::above_view &
operator()( const Relation & r ) const
{
return r.get_view();
}
};
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP

View File

@@ -0,0 +1,181 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/is_tag_of_member_at.hpp
/// \brief is_tag_of_member_at<tag,relation> metafunction
#ifndef BOOST_BIMAP_RELATION_SUPPORT_IS_TAG_OF_MEMBER_AT_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_IS_TAG_OF_MEMBER_AT_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/member_at.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/bimap/relation/support/member_with_tag.hpp>
/** \struct boost::bimaps::relation::support::is_tag_of_member_at_left
\brief Metafunction to test if a user tag is refering to the left member.
\code
template< class Tag, class Relation >
struct is_tag_of_member_at_left : {true_|false_} {};
\endcode
This metafunction is somewhat redundant with member_with_tag, but it is included
because it is a lot easier to metaprogram with it. The result type is the
same that:
\code
is_same< member_with_tag<Tag,Relation>::type , member_at::left >::type
\endcode
See also member_with_tag, member_at, is_tag_of_member_at_right.
\ingroup relation_group
**/
/** \struct boost::bimaps::relation::support::is_tag_of_member_at_right
\brief Metafunction to test if a user tag is refering to the left member.
\code
template< class Tag, class Relation >
struct is_tag_of_member_at_right : {true_|false_} {};
\endcode
This metafunction is somewhat redundat with member_with_tag, but it is included
because it is a lot easier to metaprogram with it. The result type is the
same that:
\code
is_same< member_with_tag<Tag,Relation>::type , member_at::right >::type
\endcode
See also member_with_tag, member_at, is_tag_of_member_at_left.
\ingroup relation_group
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
// Metafunction is_tag_of_member_at_left
// Easiear metaprogramming
template
<
class Tag,
class Relation,
class Enable = void
>
struct is_tag_of_member_at_left :
::boost::mpl::false_ {};
template< class Tag, class Relation >
struct is_tag_of_member_at_left
<
Tag, Relation,
BOOST_DEDUCED_TYPENAME enable_if
<
is_same
<
BOOST_DEDUCED_TYPENAME member_with_tag<Tag,Relation>::type,
member_at::left
>
>::type
> :
::boost::mpl::true_ {};
// Metafunction is_tag_of_member_at_right
// Easiear metaprogramming
template
<
class Tag,
class Relation,
class Enable = void
>
struct is_tag_of_member_at_right :
::boost::mpl::false_ {};
template< class Tag, class Relation >
struct is_tag_of_member_at_right
<
Tag, Relation,
BOOST_DEDUCED_TYPENAME enable_if
<
is_same
<
BOOST_DEDUCED_TYPENAME member_with_tag<Tag,Relation>::type,
member_at::right
>
>::type
> :
::boost::mpl::true_ {};
// Metafunction is_tag_of_member_at_info
// Easiear metaprogramming
template
<
class Tag,
class Relation,
class Enable = void
>
struct is_tag_of_member_at_info :
::boost::mpl::false_ {};
template< class Tag, class Relation >
struct is_tag_of_member_at_info
<
Tag, Relation,
BOOST_DEDUCED_TYPENAME enable_if
<
is_same
<
BOOST_DEDUCED_TYPENAME member_with_tag<Tag,Relation>::type,
member_at::info
>
>::type
> :
::boost::mpl::true_ {};
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_RELATION_SUPPORT_IS_TAG_OF_MEMBER_AT_HPP

View File

@@ -0,0 +1,180 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/member_with_tag.hpp
/// \brief member_with_tag<tag,relation> metafunction
#ifndef BOOST_BIMAP_RELATION_SUPPORT_MEMBER_WITH_TAG_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_MEMBER_WITH_TAG_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/member_at.hpp>
#include <boost/bimap/detail/debug/static_error.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/and.hpp>
/** \struct boost::bimaps::relation::support::member_with_tag
\brief Metafunction to convert user tags to the member_at idiom.
\code
template< class Tag, class Relation >
struct member_with_tag
{
typedef member_at::{side} type;
};
\endcode
We have to allow that all the metafunctions that works with tags
and retrieves data from a Relation will work with member_at idiom
even if the type was tagged. This will be great for the user,
because he can choose to tag a member after he is using the
relation and the code will still work.
If we perform this check in every metafunction it will be very
tedious and error prone, so instead of that all metafunctions
that works with relations first call this metafunction that
convert the tag to a member_at tag.
See also member_at, is_tag_of_member_at_left, is_tag_of_member_at_right.
\ingroup relation_group
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
template
<
class Tag,
class Relation,
class Enable = void
>
struct member_with_tag
{
BOOST_BIMAP_STATIC_ERROR( MEMBER_WITH_TAG_FAILURE, (Relation,Tag) );
};
template< class Relation >
struct member_with_tag
<
member_at::left, Relation, void
>
{
typedef member_at::left type;
};
template< class Relation >
struct member_with_tag
<
member_at::right, Relation, void
>
{
typedef member_at::right type;
};
template< class Relation >
struct member_with_tag
<
member_at::info, Relation, void
>
{
typedef member_at::info type;
};
template< class Tag, class Relation >
struct member_with_tag
<
Tag, Relation,
BOOST_DEDUCED_TYPENAME enable_if
<
mpl::and_
<
mpl::not_< is_same<Tag,member_at::left> >,
is_same
<
Tag,
BOOST_DEDUCED_TYPENAME Relation::left_tag
>
>
>::type
>
{
typedef member_at::left type;
};
template< class Tag, class Relation >
struct member_with_tag
<
Tag,
Relation,
BOOST_DEDUCED_TYPENAME enable_if
<
mpl::and_
<
mpl::not_< is_same<Tag,member_at::right> >,
is_same
<
Tag,
BOOST_DEDUCED_TYPENAME Relation::right_tag
>
>
>::type
>
{
typedef member_at::right type;
};
template< class Tag, class Relation >
struct member_with_tag
<
Tag, Relation,
BOOST_DEDUCED_TYPENAME enable_if
<
mpl::and_
<
mpl::not_< is_same<Tag,member_at::info> >,
is_same
<
Tag,
BOOST_DEDUCED_TYPENAME Relation::info_tag
>
>
>::type
>
{
typedef member_at::info type;
};
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_RELATION_SUPPORT_MEMBER_WITH_TAG_HPP

View File

@@ -0,0 +1,61 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/opposite_tag.hpp
/// \brief Metafunction to obtain the opposite tag in a relation.
#ifndef BOOST_BIMAP_RELATION_SUPPORT_OPPOSITE_TAG_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_OPPOSITE_TAG_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
/** \struct boost::bimaps::relation::support::opposite_tag
\brief Metafunction to obtain the opposite tag in a relation.
\code
template< class Tag, class Relation >
struct opposite_tag
{
typedef {OppositeTag} type;
};
\endcode
\ingroup relation_group
**/
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
// Implementation of const pair reference type by metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
opossite_tag,
right_tag,
left_tag
)
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_SUPPORT_OPPOSITE_TAG_HPP

View File

@@ -0,0 +1,120 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/pair_by.hpp
/// \brief pair_by<member>(r) function
#ifndef BOOST_BIMAP_RELATION_SUPPORT_PAIR_BY_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_PAIR_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/support/pair_type_by.hpp>
#include <boost/bimap/relation/detail/access_builder.hpp>
#ifdef BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
/** \brief Gets a pair view of the relation.
\ingroup relation_group
**/
template< class Tag, class Relation >
BOOST_DEDUCED_TYPENAME result_of::pair_by<Tag,Relation>::type
pair_by( Relation & rel );
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
// Since it is very error-prone to directly write the hole bunch
// of relation accesor. They are buil from litle macro blocks that
// are both more readable, leading to self docummenting code and a
// lot more easier to understand and mantain.
// It is very important to note that the three building blocks have
// to laid in the same namespace in order to work. There is also
// important to keep them in order.
// The forward declaration are not necesary but they help a lot to
// the reader, as they undercover what is the signature of the
// result code.
// In the end, it is not quicker to do it in this way because you
// write a lot. But this code has no complexity at all and almost
// every word writed is for documentation.
// Result of
// -------------------------------------------------------------------------
/*
namespace result_of {
template< class Tag, class Relation >
struct pair_by<Tag,Relation>;
{
typedef -unspecified- type;
};
} // namespace result_of
*/
BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER
(
pair_by,
pair_type_by
)
// Implementation
// -------------------------------------------------------------------------
BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER
(
pair_by,
Relation,
rel,
return rel.get_left_pair(),
return rel.get_right_pair()
)
// Interface
// --------------------------------------------------------------------------
BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER
(
pair_by
)
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXIGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_RELATION_SUPPORT_PAIR_BY_HPP

View File

@@ -0,0 +1,62 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/pair_type_by.hpp
/// \brief pair_type_by<tag,relation> metafunction
#ifndef BOOST_BIMAP_RELATION_SUPPORT_PAIR_TYPE_BY_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_PAIR_TYPE_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
/** \struct boost::bimaps::relation::support::pair_type_by
\brief Metafunction to obtain the view type indexed by one of the sides.
\code
template< class Tag, class Relation >
struct pair_type_by
{
typedef {signature-compatible with std::pair} type;
};
\endcode
See also member_at, pair_by().
\ingroup relation_group
**/
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
// Implementation of pair type by metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
pair_type_by,
left_pair,
right_pair
)
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_SUPPORT_PAIR_BY_TYPE_HPP

View File

@@ -0,0 +1,91 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/support/value_type_of.hpp
/// \brief value_type_of<tag,relation> metafunction
#ifndef BOOST_BIMAP_RELATION_SUPPORT_VALUE_TYPE_OF_HPP
#define BOOST_BIMAP_RELATION_SUPPORT_VALUE_TYPE_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
/** \struct boost::bimaps::relation::support::value_type_of
\brief Metafunction to obtain the value type of one of the sides.
\code
template< class Tag, class Relation >
struct value_type_of
{
typedef typename Relation::{side}_type type;
};
\endcode
See also member_at, get().
\ingroup relation_group
**/
namespace boost {
namespace bimaps {
namespace relation {
namespace support {
// Metafunction value_type_of
/*
template< class Tag, class Relation >
struct value_type_of
{
typedef -unspecified- type;
};
*/
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
value_type_of,
left_value_type,
right_value_type
)
// Add support for info tags to value_type_of
template< class Tag, class SymmetricType >
struct value_type_of
<
Tag, SymmetricType,
BOOST_DEDUCED_TYPENAME enable_if
<
::boost::bimaps::relation::support::is_tag_of_member_at_info
<
Tag,
SymmetricType
>
>::type
>
{
typedef BOOST_DEDUCED_TYPENAME SymmetricType::info_type type;
};
} // namespace support
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_SUPPORT_VALUE_TYPE_OF_HPP

View File

@@ -0,0 +1,97 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file relation/symmetrical_base.hpp
/// \brief Base class for symmetrical types
#ifndef BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP
#define BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/remove_const.hpp>
// Boost.Bimap
#include <boost/bimap/tags/tagged.hpp>
#include <boost/bimap/tags/support/default_tagged.hpp>
#include <boost/bimap/relation/member_at.hpp>
namespace boost {
namespace bimaps {
namespace relation {
/// \brief Base of symetrical tagged types.
/**
**/
template< class TA, class TB, bool force_mutable = false >
class symmetrical_base
{
public:
typedef BOOST_DEDUCED_TYPENAME tags::support::default_tagged
<
TA,
member_at::left
>::type tagged_left_type;
typedef BOOST_DEDUCED_TYPENAME tags::support::default_tagged
<
TB,
member_at::right
>::type tagged_right_type;
public:
//@{
/// The type stored in the relation
typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< force_mutable,
BOOST_DEDUCED_TYPENAME ::boost::remove_const<
BOOST_DEDUCED_TYPENAME tagged_left_type::value_type >::type,
BOOST_DEDUCED_TYPENAME tagged_left_type::value_type
>::type left_value_type;
typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< force_mutable,
BOOST_DEDUCED_TYPENAME ::boost::remove_const<
BOOST_DEDUCED_TYPENAME tagged_right_type::value_type >::type,
BOOST_DEDUCED_TYPENAME tagged_right_type::value_type
>::type right_value_type;
//@}
//@{
/// The tag of the member. By default it is \c member_at::{side}
typedef BOOST_DEDUCED_TYPENAME tagged_left_type ::tag left_tag;
typedef BOOST_DEDUCED_TYPENAME tagged_right_type::tag right_tag;
//@}
};
} // namespace relation
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP

206
test/external/boost/bimap/set_of.hpp vendored Normal file
View File

@@ -0,0 +1,206 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file set_of.hpp
/// \brief Include support for set constrains for the bimap container
#ifndef BOOST_BIMAP_SET_OF_HPP
#define BOOST_BIMAP_SET_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <functional>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/concept_check.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
#include <boost/bimap/detail/generate_index_binder.hpp>
#include <boost/bimap/detail/generate_view_binder.hpp>
#include <boost/bimap/detail/generate_relation_binder.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/bimap/views/map_view.hpp>
#include <boost/bimap/views/set_view.hpp>
namespace boost {
namespace bimaps {
/// \brief Set Type Specification
/**
This struct is used to specify a set specification.
It is not a container, it is just a metaprogramming facility to
express the type of a set. Generally, this specification will
be used in other place to create a container.
It has the same syntax that an std::set instantiation, except
that the allocator cannot be specified. The rationale behind
this difference is that the allocator is not part of the set
type specification, rather it is a container configuration
parameter.
The first parameter is the type of the objects in the set, and
the second one is a Functor that compares them.
Bimap binding metafunctions can be used with this class in
the following way:
\code
using namespace support;
BOOST_STATIC_ASSERT( is_set_type_of< set_of<Type> >::value )
BOOST_STATIC_ASSERT
(
is_same
<
set_of<Type,KeyCompare>::index_bind
<
KeyExtractor,
Tag
>::type,
ordered_unique< tag<Tag>, KeyExtractor, KeyCompare >
>::value
)
typedef bimap
<
set_of<Type>, RightKeyType
> bimap_with_left_type_as_set;
BOOST_STATIC_ASSERT
(
is_same
<
set_of<Type>::map_view_bind
<
member_at::left,
bimap_with_left_type_as_set
>::type,
map_view< member_at::left, bimap_with_left_type_as_set >
>::value
)
\endcode
See also set_of_relation.
**/
template
<
class KeyType,
class KeyCompare = std::less< BOOST_DEDUCED_TYPENAME
::boost::bimaps::tags::support::value_type_of<KeyType>::type >
>
struct set_of : public ::boost::bimaps::detail::set_type_of_tag
{
/// User type, can be tagged
typedef KeyType user_type;
/// Type of the object that will be stored in the set
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
value_type_of<user_type>::type value_type;
/// Functor that compare two keys
typedef KeyCompare key_compare;
struct lazy_concept_checked
{
BOOST_CLASS_REQUIRE ( value_type,
boost, AssignableConcept );
BOOST_CLASS_REQUIRE4( key_compare, bool, value_type, value_type,
boost, BinaryFunctionConcept );
typedef set_of type;
};
BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
// binds to
multi_index::ordered_unique,
// with
key_compare
)
BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
// binds to
views::map_view
)
BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
// binds to
views::set_view
)
typedef mpl::bool_<false> mutable_key;
};
/// \brief Set Of Relation Specification
/**
This struct is similar to set_of but it is bind logically to a
relation. It is used in the bimap instantiation to specify the
desired type of the main view. This struct implements internally
a metafunction named bind_to that manages the quite complicated
task of finding the right type of the set for the relation.
\code
template<class Relation>
struct bind_to
{
typedef -unspecified- type;
};
\endcode
See also set_of, is_set_type_of_relation.
**/
template< class KeyCompare = std::less< _relation > >
struct set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
{
/// Functor that compare two keys
typedef KeyCompare key_compare;
BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(
// binds to
set_of,
// with
key_compare
)
typedef mpl::bool_<false> left_mutable_key;
typedef mpl::bool_<false> right_mutable_key;
};
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_SET_OF_HPP

View File

@@ -0,0 +1,73 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file support/data_type_by.hpp
/// \brief Metafunction to access the data types of a bimap
#ifndef BOOST_BIMAP_SUPPORT_DATA_TYPE_BY_HPP
#define BOOST_BIMAP_SUPPORT_DATA_TYPE_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
/** \struct boost::bimaps::support::data_type_by
\brief Metafunction to obtain the data type of one of the sides in a bimap
The tag parameter can be either a user defined tag or \c member_at::{side}.
This is the actual data type stored in the bimap.
\code
template< class Tag, class Bimap >
struct data_type_by
{
typedef typename Bimap::{side}_data_type type;
};
\endcode
The following holds:
\code
BOOST_STATIC_ASSERT
(
is_same< data_type_by< member_at::left, bimap<A,B> >::type, A >::value
)
\endcode
See also member_at.
\ingroup bimap_group
**/
namespace boost {
namespace bimaps {
namespace support {
// Implementation of data type of metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
data_type_by,
left_data_type,
right_data_type
)
} // namespace support
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_SUPPORT_DATA_TYPE_BY_HPP

View File

@@ -0,0 +1,228 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file support/iterator_type_by.hpp
/// \brief Metafunctions to access the iterator types of a bimap
#ifndef BOOST_BIMAP_SUPPORT_ITERATOR_TYPE_BY_HPP
#define BOOST_BIMAP_SUPPORT_ITERATOR_TYPE_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
#include <boost/bimap/relation/detail/static_access_builder.hpp>
#include <boost/bimap/relation/support/pair_type_by.hpp>
#include <boost/bimap/detail/map_view_iterator.hpp>
/** \struct boost::bimaps::support::iterator_type_by
\brief Metafunction to obtain the iterator type of the map view by one of the sides.
\code
template< class Tag, class Bimap >
struct iterator_type_by
{
typedef -unspecified- type;
};
template< class Tag, class Bimap >
struct const_iterator_type_by
{
typedef -unspecified- type;
};
template< class Tag, class Bimap >
struct reverse_iterator_type_by
{
typedef -unspecified- type;
};
template< class Tag, class Bimap >
struct const_reverse_iterator_type_by
{
typedef -unspecified- type;
};
template< class Tag, class Bimap >
struct local_iterator_type_by
{
typedef -unspecified- type;
};
template< class Tag, class Bimap >
struct const_local_iterator_type_by
{
typedef -unspecified- type;
};
\endcode
See also member_at.
\ingroup bimap_group
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace support {
// Implementation of iterator type by metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
iterator_type_by,
left_iterator,
right_iterator
)
// Implementation of const iterator type by metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
const_iterator_type_by,
left_const_iterator,
right_const_iterator
)
// Implementation of reverse iterator type by metafunction
BOOST_BIMAP_SYMMETRIC_STATIC_ACCESS_BUILDER
(
core_reverse_iterator_type_by,
BimapCore,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::left_tag>
::type::reverse_iterator type,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::right_tag>
::type::reverse_iterator type
)
template< class Tag, class BimapCore >
struct reverse_iterator_type_by
{
typedef ::boost::bimaps::detail::map_view_iterator
<
Tag,
BOOST_DEDUCED_TYPENAME BimapCore::relation,
BOOST_DEDUCED_TYPENAME core_reverse_iterator_type_by<Tag,BimapCore>::type
> type;
};
// Implementation of const reverse iterator type by metafunction
BOOST_BIMAP_SYMMETRIC_STATIC_ACCESS_BUILDER
(
core_const_reverse_iterator_type_by,
BimapCore,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::left_tag>
::type::const_reverse_iterator type,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::right_tag>
::type::const_reverse_iterator type
)
template< class Tag, class BimapCore >
struct const_reverse_iterator_type_by
{
typedef ::boost::bimaps::detail::map_view_iterator
<
Tag,
BOOST_DEDUCED_TYPENAME BimapCore::relation,
BOOST_DEDUCED_TYPENAME core_const_reverse_iterator_type_by<Tag,BimapCore>::type
> type;
};
// Implementation of local iterator type by metafunction
BOOST_BIMAP_SYMMETRIC_STATIC_ACCESS_BUILDER
(
core_local_iterator_type_by,
BimapCore,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::left_tag>
::type::local_iterator type,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::right_tag>
::type::local_iterator type
)
template< class Tag, class BimapCore >
struct local_iterator_type_by
{
typedef ::boost::bimaps::detail::map_view_iterator
<
Tag,
BOOST_DEDUCED_TYPENAME BimapCore::relation,
BOOST_DEDUCED_TYPENAME core_local_iterator_type_by<Tag,BimapCore>::type
> type;
};
// Implementation of const local iterator type by metafunction
BOOST_BIMAP_SYMMETRIC_STATIC_ACCESS_BUILDER
(
core_const_local_iterator_type_by,
BimapCore,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::left_tag>
::type::const_local_iterator type,
typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE
index<BOOST_DEDUCED_TYPENAME BimapCore::right_tag>
::type::const_local_iterator type
)
template< class Tag, class BimapCore >
struct const_local_iterator_type_by
{
typedef ::boost::bimaps::detail::map_view_iterator
<
Tag,
BOOST_DEDUCED_TYPENAME BimapCore::relation,
BOOST_DEDUCED_TYPENAME core_const_local_iterator_type_by<Tag,BimapCore>::type
> type;
};
} // namespace support
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_SUPPORT_ITERATOR_TYPE_BY_HPP

View File

@@ -0,0 +1,64 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file support/key_type_by.hpp
/// \brief Metafunction to access the set types of a bimap
#ifndef BOOST_BIMAP_SUPPORT_KEY_TYPE_BY_HPP
#define BOOST_BIMAP_SUPPORT_KEY_TYPE_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
/** \struct boost::bimaps::support::key_type_by
\brief Metafunction to obtain the key type of one of the sides in a bimap
The tag parameter can be either a user defined tag or \c member_at::{side}.
The returned type is one of the {SetType}_of definition classes.
\code
template< class Tag, class Bimap >
struct key_type_by
{
typedef typename Bimap::{side}_key_type type;
};
\endcode
See also member_at.
\ingroup bimap_group
**/
namespace boost {
namespace bimaps {
namespace support {
// Implementation of key type type of metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
key_type_by,
left_key_type,
right_key_type
)
} // namespace support
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_SUPPORT_KEY_TYPE_BY_HPP

View File

@@ -0,0 +1,46 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file support/lambda.hpp
/// \brief Placeholders definition to help in bimap modify function
#ifndef BOOST_BIMAP_SUPPORT_LAMBDA_HPP
#define BOOST_BIMAP_SUPPORT_LAMBDA_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/lambda/lambda.hpp>
namespace boost {
namespace bimaps {
namespace {
/*
boost::lambda::placeholder1_type & _first = boost::lambda::_1;
boost::lambda::placeholder2_type & _second = boost::lambda::_2;
boost::lambda::placeholder1_type & _left = boost::lambda::_1;
boost::lambda::placeholder2_type & _right = boost::lambda::_2;
*/
boost::lambda::placeholder1_type & _key = boost::lambda::_1;
boost::lambda::placeholder1_type & _data = boost::lambda::_1;
}
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_SUPPORT_LAMBDA_HPP

View File

@@ -0,0 +1,132 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file support/map_by.hpp
/// \brief map_by<tag>(b) function
#ifndef BOOST_BIMAP_SUPPORT_MAP_BY_HPP
#define BOOST_BIMAP_SUPPORT_MAP_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/support/map_type_by.hpp>
#include <boost/bimap/relation/detail/access_builder.hpp>
#ifdef BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace support {
/** \brief Gets a map view of a bidirectional map
Convertible to \c map_type_by<Tag,Bimap>::type
Instead of using \c map_type_by<Tag,Bimap>::type this functions use
\b Boost.call_traits to find the best way to return this value. To help
the user of this function the following metafunction is provided
\code
namespace result_of {
template< class Tag, class Bimap >
struct map_by( Bimap & b );
} // namespace result_of
\endcode
See also member_at, value_type_of.
\ingroup bimap_group
**/
template< class Tag, class Bimap >
BOOST_DEDUCED_TYPENAME result_of::map_by<Tag,Bimap>::type
map_by( Bimap & b );
} // namespace support
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
#ifndef BOOST_BIMAP_DOXIGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace support {
// Since it is very error-prone to directly write the hole bunch
// of relation accesor. They are buil from litle macro blocks that
// are both more readable, leading to self docummenting code and a
// lot more easier to understand and mantain.
// It is very important to note that the three building blocks have
// to laid in the same namespace in order to work. There is also
// important to keep them in order.
// The forward declaration are not necesary but they help a lot to
// the reader, as they undercover what is the signature of the
// result code.
// In the end, it is not quicker to do it in this way because you
// write a lot. But this code has no complexity at all and almost
// every word writed is for documentation.
// Result of
// -------------------------------------------------------------------------
/*
namespace result_of {
template< class Tag, class Bimap >
struct map_by<Tag,Bimap>;
{
typedef -unspecified- type;
};
} // namespace result_of
*/
BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER
(
map_by,
map_type_by
)
// Implementation
// -------------------------------------------------------------------------
BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER
(
map_by,
Bimap,
b,
return b.left,
return b.right
)
// Interface
// --------------------------------------------------------------------------
BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER
(
map_by
)
} // namespace support
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXIGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_SUPPORT_MAP_BY_HPP

View File

@@ -0,0 +1,65 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file support/map_type_by.hpp
/// \brief Metafunction to access the map view types of a bimap
#ifndef BOOST_BIMAP_SUPPORT_MAP_TYPE_BY_HPP
#define BOOST_BIMAP_SUPPORT_MAP_TYPE_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
/** \struct boost::bimaps::support::map_type_by
\brief Metafunction to obtain the map view type of a bimap indexed by one of the sides.
The tag parameter can be either a user defined tag or \c member_at::{side}.
The returned type is signature-compatible with std::pair.
\code
template< class Tag, class Bimap >
struct map_type_by
{
typedef typename Bimap::{side}_map_type type;
};
\endcode
See also member_at.
\ingroup bimap_group
**/
namespace boost {
namespace bimaps {
namespace support {
// Implementation of map type by metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
map_type_by,
left_map,
right_map
)
} // namespace support
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_SUPPORT_MAP_TYPE_BY_HPP

View File

@@ -0,0 +1,65 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file support/value_type_by.hpp
/// \brief Metafunction to access the value types (std::pair compatibles) of a bimap
#ifndef BOOST_BIMAP_SUPPORT_VALUE_TYPE_BY_HPP
#define BOOST_BIMAP_SUPPORT_VALUE_TYPE_BY_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/relation/detail/metadata_access_builder.hpp>
/** \struct boost::bimaps::support::value_type_by
\brief Metafunction to obtain the value type of a bimap indexed by one of the sides.
The tag parameter can be either a user defined tag or \c member_at::{side}.
The returned type is signature-compatible with std::pair.
\code
template< class Tag, class Bimap >
struct value_type_by
{
typedef typename Bimap::{side}_value_type type;
};
\endcode
See also member_at.
\ingroup bimap_group
**/
namespace boost {
namespace bimaps {
namespace support {
// Implementation of value type by metafunction
BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER
(
value_type_by,
left_value_type,
right_value_type
)
} // namespace support
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_SUPPORT_VALUE_TYPE_BY_HPP

View File

@@ -0,0 +1,70 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file tags/support/apply_to_value_type.hpp
/// \brief Similar to mpl::apply but for tagged types.
#ifndef BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP
#define BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/tags/tagged.hpp>
#include <boost/mpl/apply.hpp>
/** \struct boost::bimaps::tags::support::apply_to_value_type
\brief Higger order metafunction similar to mpl::apply but for tagged types.
\code
template< class Metafunction, class TaggedType >
struct apply_to_value_type
{
typedef tagged
<
Metafuntion< value_type_of< TaggedType >::type >::type,
tag_of< TaggedType >::type
> type;
};
\endcode
This higher order metafunctions is very useful, and it can be used with lambda
expresions.
See also tagged.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace tags {
namespace support {
template < class F, class TaggedType >
struct apply_to_value_type;
template < class F, class ValueType, class Tag >
struct apply_to_value_type<F, tagged<ValueType,Tag> >
{
typedef BOOST_DEDUCED_TYPENAME mpl::apply< F, ValueType >::type new_value_type;
typedef tagged< new_value_type, Tag > type;
};
} // namespace support
} // namespace tags
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP

View File

@@ -0,0 +1,73 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file tags/support/default_tagged.hpp
/// \brief Weak tagging
#ifndef BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP
#define BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/tags/tagged.hpp>
/** \struct boost::bimaps::tags::support::default_tagged
\brief Weak tagging metafunction
\code
template< class Type, class Tag >
struct default_tagged
{
typedef {TaggedType} type;
};
\endcode
If the type is not tagged, this metafunction returns a tagged type with the
default tag. If it is tagged, the returns the type unchanged.
See also tagged, overwrite_tagged.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace tags {
namespace support {
// Default Tagging
// A metafunction that create a tagged type with a default tag value.
template< class Type, class DefaultTag >
struct default_tagged
{
typedef tagged<Type,DefaultTag> type;
};
template< class Type, class OldTag, class NewTag >
struct default_tagged< tagged< Type, OldTag >, NewTag >
{
typedef tagged<Type,OldTag> type;
};
} // namespace support
} // namespace tags
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP

View File

@@ -0,0 +1,64 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file tags/support/is_tagged.hpp
/// \brief type_traits extension
#ifndef BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP
#define BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/bimap/tags/tagged.hpp>
/** \struct boost::bimaps::tags::support::is_tagged
\brief Type trait to check if a type is tagged.
\code
template< class Type >
struct is_tagged
{
typedef {mpl::true_/mpl::false_} type;
};
\endcode
See also tagged.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace tags {
namespace support {
// is_tagged metafunction
template< class Type >
struct is_tagged :
::boost::mpl::false_ {};
template< class Type, class Tag >
struct is_tagged< tagged< Type, Tag > > :
::boost::mpl::true_ {};
} // namespace support
} // namespace tags
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP

View File

@@ -0,0 +1,73 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file tags/support/overwrite_tagged.hpp
/// \brief Hard tagging
#ifndef BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP
#define BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/tags/tagged.hpp>
/** \struct boost::bimaps::tags::support::overwrite_tagged
\brief Hard tagging metafunction
\code
template< class Type, class Tag >
struct overwrite_tagged
{
typedef {TaggedType} type;
};
\endcode
If the type is not tagged, this metafunction returns a tagged type with the
passed tag. If it is tagged it returns a new tagged type with the tag replaced
by the one passed as a parameter.
See also tagged, default_tagged.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace tags {
namespace support {
// Change the tag
template< class Type, class NewTag >
struct overwrite_tagged
{
typedef tagged<Type,NewTag> type;
};
template< class Type, class OldTag, class NewTag >
struct overwrite_tagged< tagged< Type, OldTag >, NewTag >
{
typedef tagged<Type,NewTag> type;
};
} // namespace support
} // namespace tags
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP

View File

@@ -0,0 +1,75 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file tags/support/tag_of.hpp
/// \brief Safe way to acces the tag of a type
#ifndef BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP
#define BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/tags/tagged.hpp>
#include <boost/bimap/detail/debug/static_error.hpp>
/** \struct boost::bimaps::tags::support::tag_of
\brief Metafunction to obtain the tag of a type.
\code
template< class TaggedType >
struct tag_of
{
typedef {Tag} type;
};
\endcode
If the type is not tagged you will get a compile timer error with the following message:
\verbatim
USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, TaggedType
\endverbatim
See also tagged, value_type_of.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace tags {
namespace support {
// tag_of metafunction
template< class Type >
struct tag_of
{
BOOST_BIMAP_STATIC_ERROR( USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, (Type) );
};
template< class Type, class Tag >
struct tag_of< tagged< Type, Tag > >
{
typedef Tag type;
};
} // namespace support
} // namespace tags
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP

View File

@@ -0,0 +1,74 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file tags/support/value_type_of.hpp
/// \brief Consistent way to access the value type of a tagged or untagged type.
#ifndef BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP
#define BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/tags/tagged.hpp>
/** \struct boost::bimaps::tags::support::value_type_of
\brief Metafunction to work with tagged and untagged type uniformly
\code
template< class Type >
struct value_type_of
{
typedef {UntaggedType} type;
};
\endcode
If the type is tagged this metafunction returns Type::value_type, and if it is not
tagged it return the same type. This allows to work consistenly with tagged and
untagged types.
See also tagged, tag_of.
**/
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace boost {
namespace bimaps {
namespace tags {
namespace support {
// value_type_of metafunction
template< class Type >
struct value_type_of
{
typedef Type type;
};
template< class Type, class Tag >
struct value_type_of< tagged< Type, Tag > >
{
typedef Type type;
};
} // namespace support
} // namespace tags
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
#endif // BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP

View File

@@ -0,0 +1,107 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file tags/tagged.hpp
/// \brief Defines the tagged class
#ifndef BOOST_BIMAP_TAGS_TAGGED_HPP
#define BOOST_BIMAP_TAGS_TAGGED_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
namespace boost {
namespace bimaps {
/// \brief A light non-invasive idiom to tag a type.
/**
There are a lot of ways of tagging a type. The standard library for example
defines tags (empty structs) that are then inherited by the tagged class. To
support built-in types and other types that simple cannot inherit from the
tag, the standard builds another level of indirection. An example of this is
the type_traits metafunction. This approach is useful if the tags are intended
to be used in the library internals, and if the user does not have to create
new tagged types often.
Boost.MultiIndex is an example of a library that defines a tagged idiom that
is better suited to the user. As an option, in the indexed by declaration
of a multi-index container a user can \b attach a tag to each index, so it
can be referred by it instead of by the index number. It is a very user
friendly way of specifying a tag but is very invasive from the library writer's
point of view. Each index must now support this additional parameter. Maybe
not in the case of the multi-index container, but in simpler classes
the information of the tags is used by the father class rather than by the
tagged types.
\b tagged is a light non-invasive idiom to tag a type. It is very intuitive
and user-friendly. With the use of the defined metafunctions the library
writer can enjoy the coding too.
**/
namespace tags {
/// \brief The tag holder
/**
The idea is to add a level of indirection to the type being tagged. With this
class you wrapped a type and apply a tag to it. The only thing to remember is
that if you write
\code
typedef tagged<type,tag> taggedType;
\endcode
Then instead to use directly the tagged type, in order to access it you have
to write \c taggedType::value_type. The tag can be obtained using \c taggedType::tag.
The idea is not to use this metadata directly but rather using the metafunctions
that are defined in the support namespace. With this metafunctions you can work
with tagged and untagged types in a consistent way. For example, the following
code is valid:
\code
BOOST_STATIC_ASSERT( is_same< value_type_of<taggedType>, value_type_of<type> >::value );
\endcode
The are other useful metafunctions there too.
See also value_type_of, tag_of, is_tagged, apply_to_value_type.
\ingroup tagged_group
**/
template< class Type, class Tag >
struct tagged
{
typedef Type value_type;
typedef Tag tag;
};
} // namespace tags
} // namespace bimaps
} // namespace boost
/** \namespace boost::bimaps::tags::support
\brief Metafunctions to work with tagged types.
This metafunctions aims to make easier the manage of tagged types. They are all mpl
compatible metafunctions and can be used with lambda expresions.
The metafunction value_type_of and tag_of get the data in a tagged type in a secure
and consistent way.
default_tagged and overwrite_tagged allows to work with the tag of a tagged type,
and apply_to_value_type is a higher order metafunction that allow the user to change
the type of a TaggedType.
**/
#endif // BOOST_BIMAP_TAGS_TAGGED_HPP

View File

@@ -0,0 +1,150 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file unconstrained_set_of.hpp
/// \brief Include support for set constrains for the bimap container
#ifndef BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP
#define BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/concept_check.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/bimap/detail/generate_index_binder.hpp>
#include <boost/bimap/detail/generate_view_binder.hpp>
#include <boost/bimap/detail/generate_relation_binder.hpp>
#include <boost/bimap/views/unconstrained_map_view.hpp>
#include <boost/bimap/views/unconstrained_set_view.hpp>
namespace boost {
namespace bimaps {
/// \brief Set Type Specification
/**
This struct is used to specify a set specification.
It is not a container, it is just a metaprogramming facility to
express the type of a set. Generally, this specification will
be used in other place to create a container.
The first parameter is the type of the objects in the set.
\code
using namespace support;
BOOST_STATIC_ASSERT( is_set_type_of< unconstrained_set_of<Type> >::value )
\endcode
See also unconstrained_set_of_relation.
**/
template
<
class KeyType
>
struct unconstrained_set_of : public ::boost::bimaps::detail::set_type_of_tag
{
/// User type, can be tagged
typedef KeyType user_type;
/// Type of the object that will be stored in the container
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
value_type_of<user_type>::type value_type;
struct lazy_concept_checked
{
BOOST_CLASS_REQUIRE ( value_type,
boost, AssignableConcept );
typedef unconstrained_set_of type;
};
BOOST_BIMAP_GENERATE_INDEX_BINDER_FAKE
BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
// binds to
views::unconstrained_map_view
)
BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
// binds to
views::unconstrained_set_view
)
typedef mpl::bool_<true> mutable_key;
};
/// \brief Set Of Relation Specification
/**
This struct is similar to unconstrained_set_of but it is bind
logically to a relation. It is used in the bimap instantiation to
specify the desired type of the main view.
See also unconstrained_set_of, is_set_type_of_relation.
**/
struct unconstrained_set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
{
BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
// binds to
unconstrained_set_of
)
typedef mpl::bool_<true> left_mutable_key;
typedef mpl::bool_<true> right_mutable_key;
};
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
namespace detail {
template<class T>
struct is_unconstrained_set_of :
::boost::mpl::false_ {};
template<class T>
struct is_unconstrained_set_of< unconstrained_set_of<T> > :
::boost::mpl::true_ {};
} // namespace detail
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
} // namespace bimaps
} // namespace boost
/** \struct boost::bimaps::detail::is_unconstrained_set_of
\brief Trait to check if a type is unconstrained_set_of.
\code
template< class T >
struct is_unconstrained_set_of;
\endcode
**/
#endif // BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP

View File

@@ -0,0 +1,233 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file unordered_multiset_of.hpp
/// \brief Include support for unordered_multiset constrains for the bimap container
#ifndef BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP
#define BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <cstdlib>
#include <functional>
#include <boost/functional/hash.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/concept_check.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/bimap/detail/generate_index_binder.hpp>
#include <boost/bimap/detail/generate_view_binder.hpp>
#include <boost/bimap/detail/generate_relation_binder.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/bimap/views/unordered_multimap_view.hpp>
#include <boost/bimap/views/unordered_multiset_view.hpp>
namespace boost {
namespace bimaps {
/// \brief Set Type Specification
/**
This struct is used to specify an unordered_multiset specification.
It is not a container, it is just a metaprogramming facility to
express the type of a set. Generally, this specification will
be used in other place to create a container.
It has the same syntax that an tr1::unordered_multiset instantiation,
except that the allocator cannot be specified. The rationale behind
this difference is that the allocator is not part of the
unordered_multiset type specification, rather it is a container
configuration parameter.
The first parameter is the type of the objects in the set, the
second one is a Hash Functor that takes objects of this type, and
the third one is a Functor that compares them for equality.
Bimap binding metafunctions can be used with this class in
the following way:
\code
using namespace support;
BOOST_STATIC_ASSERT( is_set_type_of< unordered_multiset_of<Type> >::value )
BOOST_STATIC_ASSERT
(
is_same
<
compute_index_type
<
unordered_multiset_of<Type,HashFunctor,EqualKey>,
KeyExtractor,
Tag
>::type
,
hashed_nonunique< tag<Tag>, KeyExtractor, HashFunctor, EqualKey >
>::value
)
typedef bimap
<
unordered_multiset_of<Type>, RightKeyType
> bimap_with_left_type_as_unordered_multiset;
BOOST_STATIC_ASSERT
(
is_same
<
compute_map_view_type
<
member_at::left,
bimap_with_left_type_as_unordered_multiset
>::type,
unordered_multimap_view
<
member_at::left,
bimap_with_left_type_as_unordered_multiset
>
>::value
)
\endcode
See also unordered_multiset_of_relation.
**/
template
<
class KeyType,
class HashFunctor = hash< BOOST_DEDUCED_TYPENAME
::boost::bimaps::tags::support::value_type_of<KeyType>::type >,
class EqualKey = std::equal_to< BOOST_DEDUCED_TYPENAME
::boost::bimaps::tags::support::value_type_of<KeyType>::type >
>
struct unordered_multiset_of : public ::boost::bimaps::detail::set_type_of_tag
{
/// User type, can be tagged
typedef KeyType user_type;
/// Type of the object that will be stored in the container
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
value_type_of<user_type>::type value_type;
/// Hash Functor that takes value_type objects
typedef HashFunctor hasher;
/// Functor that compare two value_type objects for equality
typedef EqualKey key_equal;
struct lazy_concept_checked
{
BOOST_CLASS_REQUIRE ( value_type,
boost, AssignableConcept );
BOOST_CLASS_REQUIRE3( hasher, std::size_t, value_type,
boost, UnaryFunctionConcept );
BOOST_CLASS_REQUIRE4( key_equal, bool, value_type, value_type,
boost, BinaryFunctionConcept );
typedef unordered_multiset_of type;
};
BOOST_BIMAP_GENERATE_INDEX_BINDER_2CP(
// binds to
multi_index::hashed_non_unique,
// with
hasher,
key_equal
)
BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
// binds to
views::unordered_multimap_view
)
BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
// binds to
views::unordered_multiset_view
)
typedef mpl::bool_<false> mutable_key;
};
/// \brief Set Of Relation Specification
/**
This struct is similar to unordered_multiset_of but it is bind logically
to a relation. It is used in the bimap instantiation to specify the
desired type of the main view. This struct implements internally
a metafunction named bind_to that manages the quite complicated
task of finding the right type of the set for the relation.
\code
template<class Relation>
struct bind_to
{
typedef -unspecified- type;
};
\endcode
See also unordered_multiset_of, is_set_type_of_relation.
**/
template
<
class HashFunctor = hash< _relation >,
class EqualKey = std::equal_to< _relation >
>
struct unordered_multiset_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
{
/// Hash Functor that takes value_type objects
typedef HashFunctor hasher;
/// Functor that compare two value_type objects for equality
typedef EqualKey key_equal;
BOOST_BIMAP_GENERATE_RELATION_BINDER_2CP(
// binds to
unordered_multiset_of,
// with
hasher,
key_equal
)
typedef mpl::bool_<false> left_mutable_key;
typedef mpl::bool_<false> right_mutable_key;
};
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP

View File

@@ -0,0 +1,230 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file unordered_set_of.hpp
/// \brief Include support for unordered_set constrains for the bimap container
#ifndef BOOST_BIMAP_UNORDERED_SET_OF_HPP
#define BOOST_BIMAP_UNORDERED_SET_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <functional>
#include <boost/functional/hash.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/concept_check.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/bimap/detail/generate_index_binder.hpp>
#include <boost/bimap/detail/generate_view_binder.hpp>
#include <boost/bimap/detail/generate_relation_binder.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/bimap/views/unordered_map_view.hpp>
#include <boost/bimap/views/unordered_set_view.hpp>
namespace boost {
namespace bimaps {
/// \brief Set Type Specification
/**
This struct is used to specify an unordered_set specification.
It is not a container, it is just a metaprogramming facility to
express the type of a set. Generally, this specification will
be used in other place to create a container.
It has the same syntax that an tr1::unordered_set instantiation,
except that the allocator cannot be specified. The rationale behind
this difference is that the allocator is not part of the
unordered_set type specification, rather it is a container
configuration parameter.
The first parameter is the type of the objects in the set, the
second one is a Hash Functor that takes objects of this type, and
the third one is a Functor that compares them for equality.
Bimap binding metafunctions can be used with this class in
the following way:
\code
using namespace support;
BOOST_STATIC_ASSERT( is_set_type_of< unordered_set_of<Type> >::value )
BOOST_STATIC_ASSERT
(
is_same
<
unordered_set_of<Type,HashFunctor,EqualKey>::index_bind
<
KeyExtractor,
Tag
>::type,
hashed_unique< tag<Tag>, KeyExtractor, HashFunctor, EqualKey >
>::value
)
typedef bimap
<
unordered_set_of<Type>, RightKeyType
> bimap_with_left_type_as_unordered_set;
BOOST_STATIC_ASSERT
(
is_same
<
unordered_set_of<Type>::map_view_bind
<
member_at::left,
bimap_with_left_type_as_unordered_set
>::type,
unordered_map_view
<
member_at::left,
bimap_with_left_type_as_unordered_set
>
>::value
)
\endcode
See also unordered_set_of_relation.
**/
template
<
class KeyType,
class HashFunctor = hash< BOOST_DEDUCED_TYPENAME
::boost::bimaps::tags::support::value_type_of<KeyType>::type >,
class EqualKey = std::equal_to< BOOST_DEDUCED_TYPENAME
::boost::bimaps::tags::support::value_type_of<KeyType>::type >
>
struct unordered_set_of : public ::boost::bimaps::detail::set_type_of_tag
{
/// User type, can be tagged
typedef KeyType user_type;
/// Type of the object that will be stored in the container
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
value_type_of<user_type>::type value_type;
/// Hash Functor that takes value_type objects
typedef HashFunctor hasher;
/// Functor that compare two value_type objects for equality
typedef EqualKey key_equal;
struct lazy_concept_checked
{
BOOST_CLASS_REQUIRE ( value_type,
boost, AssignableConcept );
BOOST_CLASS_REQUIRE3( hasher, std::size_t, value_type,
boost, UnaryFunctionConcept );
BOOST_CLASS_REQUIRE4( key_equal, bool, value_type, value_type,
boost, BinaryFunctionConcept );
typedef unordered_set_of type;
};
BOOST_BIMAP_GENERATE_INDEX_BINDER_2CP(
// binds to
multi_index::hashed_unique,
// with
hasher,
key_equal
)
BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
// binds to
views::unordered_map_view
)
BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
// binds to
views::unordered_set_view
)
typedef mpl::bool_<false> mutable_key;
};
/// \brief Set Of Relation Specification
/**
This struct is similar to unordered_set_of but it is bind logically to
a relation. It is used in the bimap instantiation to specify the
desired type of the main view. This struct implements internally
a metafunction named bind_to that manages the quite complicated
task of finding the right type of the set for the relation.
\code
template<class Relation>
struct bind_to
{
typedef -unspecified- type;
};
\endcode
See also unordered_set_of, is_set_type_of_relation.
**/
template
<
class HashFunctor = hash< _relation >,
class EqualKey = std::equal_to< _relation >
>
struct unordered_set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
{
/// Hash Functor that takes value_type objects
typedef HashFunctor hasher;
/// Functor that compare two value_type objects for equality
typedef EqualKey key_equal;
BOOST_BIMAP_GENERATE_RELATION_BINDER_2CP(
// binds to
unordered_set_of,
// with
hasher,
key_equal
)
typedef mpl::bool_<false> left_mutable_key;
typedef mpl::bool_<false> right_mutable_key;
};
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_UNORDERED_SET_OF_HPP

186
test/external/boost/bimap/vector_of.hpp vendored Normal file
View File

@@ -0,0 +1,186 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file vector_of.hpp
/// \brief Include support for vector constrains for the bimap container
#ifndef BOOST_BIMAP_VECTOR_OF_HPP
#define BOOST_BIMAP_VECTOR_OF_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/detail/user_interface_config.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/concept_check.hpp>
#include <boost/bimap/detail/concept_tags.hpp>
#include <boost/bimap/tags/support/value_type_of.hpp>
#include <boost/bimap/detail/generate_index_binder.hpp>
#include <boost/bimap/detail/generate_view_binder.hpp>
#include <boost/bimap/detail/generate_relation_binder.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <boost/bimap/views/vector_map_view.hpp>
#include <boost/bimap/views/vector_set_view.hpp>
namespace boost {
namespace bimaps {
/// \brief Set Type Specification
/**
This struct is used to specify a set specification.
It is not a container, it is just a metaprogramming facility to
express the type of a set. Generally, this specification will
be used in other place to create a container.
It has the same syntax that an std::vector instantiation, except
that the allocator cannot be specified. The rationale behind
this difference is that the allocator is not part of the set
type specification, rather it is a container configuration
parameter.
The first parameter is the type of the objects in the set, and
the second one is a Functor that compares them.
Bimap binding metafunctions can be used with this class in
the following way:
\code
using namespace support;
BOOST_STATIC_ASSERT( is_set_type_of< vector_of<Type> >::value )
BOOST_STATIC_ASSERT
(
is_same
<
vector_of<Type>::index_bind
<
KeyExtractor,
Tag
>::type,
random_access< tag<Tag>, KeyExtractor >
>::value
)
typedef bimap
<
vector_of<Type>, RightKeyType
> bimap_with_left_type_as_vector;
BOOST_STATIC_ASSERT
(
is_same
<
vector_of<Type>::map_view_bind
<
member_at::left,
bimap_with_left_type_as_vector
>::type,
vector_map_view< member_at::left, bimap_with_left_type_as_vector >
>::value
)
\endcode
See also vector_of_relation.
**/
template< class Type >
struct vector_of : public ::boost::bimaps::detail::set_type_of_tag
{
/// User type, can be tagged
typedef Type user_type;
/// Type of the object that will be stored in the vector
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
value_type_of<user_type>::type value_type;
struct lazy_concept_checked
{
BOOST_CLASS_REQUIRE ( value_type,
boost, AssignableConcept );
typedef vector_of type;
};
BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP_NO_EXTRACTOR(
// binds to
multi_index::random_access
)
BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
// binds to
views::vector_map_view
)
BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
// binds to
views::vector_set_view
)
typedef mpl::bool_<true> mutable_key;
};
/// \brief Set Of Relation Specification
/**
This struct is similar to vector_of but it is bind logically to a
relation. It is used in the bimap instantiation to specify the
desired type of the main view. This struct implements internally
a metafunction named bind_to that manages the quite complicated
task of finding the right type of the set for the relation.
\code
template<class Relation>
struct bind_to
{
typedef -unspecified- type;
};
\endcode
See also vector_of, is_set_type_of_relation.
**/
struct vector_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
{
BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
// binds to
vector_of
)
typedef mpl::bool_<true> left_mutable_key;
typedef mpl::bool_<true> right_mutable_key;
};
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VECTOR_OF_HPP

View File

@@ -0,0 +1,182 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/list_map_view.hpp
/// \brief View of a side of a bimap.
#ifndef BOOST_BIMAP_VIEWS_LIST_MAP_VIEW_HPP
#define BOOST_BIMAP_VIEWS_LIST_MAP_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/list_map_adaptor.hpp>
#include <boost/bimap/relation/support/pair_by.hpp>
#include <boost/bimap/support/iterator_type_by.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
#include <boost/bimap/relation/support/data_extractor.hpp>
#include <boost/bimap/relation/detail/to_mutable_relation_functor.hpp>
namespace boost {
namespace bimaps {
namespace views {
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
template< class Tag, class BimapType >
struct list_map_view_base
{
typedef ::boost::bimaps::container_adaptor::list_map_adaptor
<
BOOST_DEDUCED_TYPENAME BimapType::core_type::BOOST_NESTED_TEMPLATE index<Tag>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
iterator_type_by<Tag,BimapType>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
const_iterator_type_by<Tag,BimapType>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
reverse_iterator_type_by<Tag,BimapType>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
const_reverse_iterator_type_by<Tag,BimapType>::type,
::boost::bimaps::container_adaptor::support::iterator_facade_to_base
<
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
iterator_type_by<Tag,BimapType>::type,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
const_iterator_type_by<Tag,BimapType>::type
>,
::boost::mpl::na,
::boost::mpl::na,
::boost::bimaps::relation::detail::
pair_to_relation_functor<Tag, BOOST_DEDUCED_TYPENAME BimapType::relation >,
::boost::bimaps::relation::support::
get_pair_functor<Tag, BOOST_DEDUCED_TYPENAME BimapType::relation >,
BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::data_extractor
<
Tag,
BOOST_DEDUCED_TYPENAME BimapType::relation
>::type
> type;
};
#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
/// \brief View of a side of a bimap.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core.
See also const_list_map_view.
**/
template< class Tag, class BimapType >
class list_map_view
:
public list_map_view_base<Tag,BimapType>::type,
public ::boost::bimaps::detail::
map_view_base< list_map_view<Tag,BimapType>,Tag,BimapType >
{
typedef BOOST_DEDUCED_TYPENAME list_map_view_base<Tag,BimapType>::type base_;
BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(list_map_view,Tag,BimapType)
public:
typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
list_map_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) :
base_(c) {}
list_map_view & operator=(const list_map_view & v)
{
this->base() = v.base();
return *this;
}
BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(base_)
BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(base_)
// Rearrange Operations
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator i)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
);
}
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator first,
BOOST_DEDUCED_TYPENAME base_::iterator last)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
);
}
};
} // namespace views
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
/*===========================================================================*/
namespace detail {
template< class Tag, class BimapType >
struct left_map_view_extra_typedefs< ::boost::bimaps::views::list_map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::list_map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
};
template< class Tag, class BimapType >
struct right_map_view_extra_typedefs< ::boost::bimaps::views::list_map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::list_map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
};
} // namespace detail
/*===========================================================================*/
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
/*===========================================================================*/
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_LIST_MAP_VIEW_HPP

View File

@@ -0,0 +1,109 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/list_set_view.hpp
/// \brief View of a side of a bimap that is signature compatible with std::list.
#ifndef BOOST_BIMAP_VIEWS_LIST_SET_VIEW_HPP
#define BOOST_BIMAP_VIEWS_LIST_SET_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/list_adaptor.hpp>
#include <boost/bimap/detail/set_view_base.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a bimap that is signature compatible with std::list.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::list.
See also const_list_set_view.
**/
template< class CoreIndex >
class list_set_view
:
public BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR(
list_adaptor,
CoreIndex,
reverse_iterator, const_reverse_iterator
),
public ::boost::bimaps::detail::
set_view_base< list_set_view< CoreIndex >, CoreIndex >
{
BOOST_BIMAP_SET_VIEW_BASE_FRIEND(list_set_view,CoreIndex)
typedef BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR(
list_adaptor,
CoreIndex,
reverse_iterator, const_reverse_iterator
) base_;
public:
list_set_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) :
base_(c) {}
list_set_view & operator=(const list_set_view & v)
{
this->base() = v.base();
return *this;
}
BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(base_)
BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(base_)
// Rearrange Operations
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator i)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
);
}
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator first,
BOOST_DEDUCED_TYPENAME base_::iterator last)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
);
}
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_LIST_SET_VIEW_HPP

View File

@@ -0,0 +1,156 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/map_view.hpp
/// \brief View of a side of a bimap that is signature compatible with std::map.
#ifndef BOOST_BIMAP_VIEWS_MAP_VIEW_HPP
#define BOOST_BIMAP_VIEWS_MAP_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/map_adaptor.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a side of a bimap that is signature compatible with std::map.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::map.
See also const_map_view.
**/
template< class Tag, class BimapType >
class map_view
:
public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
map_adaptor,
Tag,BimapType,
reverse_iterator_type_by,const_reverse_iterator_type_by
),
public ::boost::bimaps::detail::
map_view_base< map_view<Tag,BimapType>,Tag,BimapType >,
public ::boost::bimaps::detail::
unique_map_view_access< map_view<Tag,BimapType>, Tag, BimapType>::type
{
typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
map_adaptor,
Tag,BimapType,
reverse_iterator_type_by,const_reverse_iterator_type_by
) base_;
BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(map_view,Tag,BimapType)
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
unique_map_view_access<
map_view<Tag,BimapType>, Tag, BimapType
>::type unique_map_view_access_;
public:
typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
map_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) : base_(c) {}
using unique_map_view_access_::at;
using unique_map_view_access_::operator[];
BOOST_BIMAP_MAP_VIEW_RANGE_IMPLEMENTATION(base_)
map_view & operator=(const map_view & v)
{
this->base() = v.base();
return *this;
}
// It can be used enable_if here but the error message when there
// is no info is very clear like this
template< class CompatibleKey >
const info_type & info_at(const CompatibleKey& k) const
{
BOOST_DEDUCED_TYPENAME base_::const_iterator iter = this->find(k);
if( iter == this->end() )
{
::boost::throw_exception(
std::out_of_range("bimap<>: invalid key")
);
}
return iter->info;
}
template< class CompatibleKey >
info_type & info_at(const CompatibleKey& k)
{
BOOST_DEDUCED_TYPENAME base_::iterator iter = this->find(k);
if( iter == this->end() )
{
::boost::throw_exception(
std::out_of_range("bimap<>: invalid key")
);
}
return iter->info;
}
};
} // namespace views
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,key_compare)
/*===========================================================================*/
namespace detail {
template< class Tag, class BimapType >
struct left_map_view_extra_typedefs< ::boost::bimaps::views::map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
};
template< class Tag, class BimapType >
struct right_map_view_extra_typedefs< ::boost::bimaps::views::map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
};
} // namespace detail
/*===========================================================================*/
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
/*===========================================================================*/
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_MAP_VIEW_HPP

View File

@@ -0,0 +1,123 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/multimap_view.hpp
/// \brief View of a side of a bimap that is signature compatible with std::multimap.
#ifndef BOOST_BIMAP_VIEWS_MULTIMAP_VIEW_HPP
#define BOOST_BIMAP_VIEWS_MULTIMAP_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/multimap_adaptor.hpp>
#include <boost/bimap/detail/non_unique_views_helper.hpp>
#include <boost/bimap/support/iterator_type_by.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a side of a bimap that is signature compatible with std::multimap.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::multimap.
See also const_multimap_view.
**/
template< class Tag, class BimapType >
class multimap_view
:
public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
multimap_adaptor,
Tag,BimapType,
reverse_iterator_type_by,const_reverse_iterator_type_by
),
public ::boost::bimaps::detail::
map_view_base< multimap_view<Tag,BimapType>,Tag,BimapType >
{
typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
multimap_adaptor,
Tag,BimapType,
reverse_iterator_type_by,const_reverse_iterator_type_by
) base_;
BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(multimap_view,Tag,BimapType)
public:
typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
multimap_view(BOOST_DEDUCED_TYPENAME base_::base_type & c)
: base_(c) {}
BOOST_BIMAP_MAP_VIEW_RANGE_IMPLEMENTATION(base_)
multimap_view & operator=(const multimap_view & v)
{
this->base() = v.base();
return *this;
}
BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS
};
} // namespace views
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,key_compare)
/*===========================================================================*/
namespace detail {
template< class Tag, class BimapType >
struct left_map_view_extra_typedefs< ::boost::bimaps::views::multimap_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::multimap_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
};
template< class Tag, class BimapType >
struct right_map_view_extra_typedefs< ::boost::bimaps::views::multimap_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::multimap_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
};
} // namespace detail
/*===========================================================================*/
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
/*===========================================================================*/
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_MAP_VIEW_HPP

View File

@@ -0,0 +1,110 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/multiset_view.hpp
/// \brief View of a bimap that is signature compatible with std::multiset.
#ifndef BOOST_BIMAP_VIEWS_MULTISET_VIEW_HPP
#define BOOST_BIMAP_VIEWS_MULTISET_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/multiset_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
#include <boost/bimap/detail/non_unique_views_helper.hpp>
#include <boost/bimap/detail/set_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a bimap that is signature compatible with std::multiset.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::multiset.
See also const_multiset_view.
**/
template< class CoreIndex >
class multiset_view
:
public BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
multiset_adaptor,
CoreIndex,
reverse_iterator,
const_reverse_iterator
),
public ::boost::bimaps::detail::
set_view_base< multiset_view< CoreIndex >, CoreIndex >
{
BOOST_BIMAP_SET_VIEW_BASE_FRIEND(multiset_view, CoreIndex)
typedef BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
multiset_adaptor,
CoreIndex,
reverse_iterator,
const_reverse_iterator
) base_;
public:
multiset_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) : base_(c) {}
/*
template< class LowerBounder, class UpperBounder >
std::pair<BOOST_DEDUCED_TYPENAME base_::const_iterator,
BOOST_DEDUCED_TYPENAME base_::const_iterator>
range(LowerBounder lower,UpperBounder upper) const
{
return this->base().range(
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
LowerBounder,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( lower, this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>() ),
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
UpperBounder,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( upper, this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
*/
multiset_view & operator=(const multiset_view & v)
{
this->base() = v.base(); return *this;
}
BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_MULTISET_VIEW_HPP

View File

@@ -0,0 +1,106 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/set_view.hpp
/// \brief View of a bimap that is signature compatible with std::set.
#ifndef BOOST_BIMAP_VIEWS_SET_VIEW_HPP
#define BOOST_BIMAP_VIEWS_SET_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/set_adaptor.hpp>
#include <boost/bimap/detail/set_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a bimap that is signature compatible with std::set.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::set.
See also const_set_view.
**/
template< class CoreIndex >
class set_view
:
public BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
set_adaptor,
CoreIndex,
reverse_iterator, const_reverse_iterator
),
public ::boost::bimaps::detail::
set_view_base< set_view< CoreIndex >, CoreIndex >
{
typedef BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
set_adaptor,
CoreIndex,
reverse_iterator, const_reverse_iterator
) base_;
BOOST_BIMAP_SET_VIEW_BASE_FRIEND(set_view,CoreIndex)
public:
set_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) : base_(c) {}
/*
template< class LowerBounder, class UpperBounder >
std::pair<BOOST_DEDUCED_TYPENAME base_::const_iterator,
BOOST_DEDUCED_TYPENAME base_::const_iterator>
range(LowerBounder lower,UpperBounder upper) const
{
return this->base().range(
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
LowerBounder,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( lower, this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>() ),
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
UpperBounder,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( upper, this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
*/
set_view & operator=(const set_view & v)
{
this->base() = v.base();
return *this;
}
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_SET_VIEW_HPP

View File

@@ -0,0 +1,44 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/unconstrained_map_view.hpp
/// \brief Unconstrained view of a side of a bimap.
#ifndef BOOST_BIMAP_VIEWS_UNCONSTRAINED_MAP_VIEW_HPP
#define BOOST_BIMAP_VIEWS_UNCONSTRAINED_MAP_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief Unconstrained view of a side of a bimap.
template< class Tag, class BimapType>
class unconstrained_map_view
{
public:
template< class T >
unconstrained_map_view(const T & t) {}
typedef void reference;
typedef void const_reference;
typedef void info_type;
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_UNCONSTRAINED_MAP_VIEW_HPP

View File

@@ -0,0 +1,42 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/unconstrained_set_view.hpp
/// \brief Unconstrained view of a bimap.
#ifndef BOOST_BIMAP_VIEWS_UNCONSTRAINED_SET_VIEW_HPP
#define BOOST_BIMAP_VIEWS_UNCONSTRAINED_SET_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief Unconstrained view of a bimap.
template< class CoreIndex >
class unconstrained_set_view
{
public:
template< class T >
unconstrained_set_view(const T & t) {}
typedef void iterator;
typedef void const_iterator;
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_UNCONSTRAINED_SET_VIEW_HPP

View File

@@ -0,0 +1,174 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/unordered_map_view.hpp
/// \brief View of a side of a bimap that is signature compatible with tr1::unordered_map.
#ifndef BOOST_BIMAP_VIEWS_UNOREDERED_MAP_VIEW_HPP
#define BOOST_BIMAP_VIEWS_UNOREDERED_MAP_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <utility>
#include <boost/bimap/container_adaptor/unordered_map_adaptor.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief Map View of a bimap, signature compatible with tr1::unordered_map.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a tr1::unordered_map.
See also const_unordered_map_view.
**/
template< class Tag, class BimapType >
class unordered_map_view
:
public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
unordered_map_adaptor,
Tag,BimapType,
local_iterator_type_by,const_local_iterator_type_by
),
public ::boost::bimaps::detail::map_view_base<
unordered_map_view<Tag,BimapType>,Tag,BimapType >,
public ::boost::bimaps::detail::
unique_map_view_access<
unordered_map_view<Tag,BimapType>, Tag, BimapType>::type
{
typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
unordered_map_adaptor,
Tag,BimapType,
local_iterator_type_by,const_local_iterator_type_by
) base_;
BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(unordered_map_view,Tag,BimapType)
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
unique_map_view_access<
unordered_map_view<Tag,BimapType>, Tag, BimapType
>::type unique_map_view_access_;
public:
typedef std::pair<
BOOST_DEDUCED_TYPENAME base_::iterator,
BOOST_DEDUCED_TYPENAME base_::iterator
> range_type;
typedef std::pair<
BOOST_DEDUCED_TYPENAME base_::const_iterator,
BOOST_DEDUCED_TYPENAME base_::const_iterator
> const_range_type;
typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
unordered_map_view(BOOST_DEDUCED_TYPENAME base_::base_type & c)
: base_(c) {}
using unique_map_view_access_::at;
using unique_map_view_access_::operator[];
unordered_map_view & operator=(const unordered_map_view & v)
{
this->base() = v.base();
return *this;
}
// It can be used enable_if here but the error message when there
// is no info is very clear like this
template< class CompatibleKey >
const info_type & info_at(const CompatibleKey& k) const
{
BOOST_DEDUCED_TYPENAME base_::const_iterator iter = this->find(k);
if( iter == this->end() )
{
::boost::throw_exception(
std::out_of_range("bimap<>: invalid key")
);
}
return iter->info;
}
template< class CompatibleKey >
info_type & info_at(const CompatibleKey& k)
{
BOOST_DEDUCED_TYPENAME base_::iterator iter = this->find(k);
if( iter == this->end() )
{
::boost::throw_exception(
std::out_of_range("bimap<>: invalid key")
);
}
return iter->info;
}
};
} // namespace views
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,local_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_local_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,hasher) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,key_equal)
/*===========================================================================*/
namespace detail {
template< class Tag, class BimapType >
struct left_map_view_extra_typedefs< ::boost::bimaps::views::unordered_map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::unordered_map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
};
template< class Tag, class BimapType >
struct right_map_view_extra_typedefs< ::boost::bimaps::views::unordered_map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::unordered_map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
};
} // namespace detail
/*===========================================================================*/
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
/*===========================================================================*/
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_UNOREDERED_MAP_VIEW_HPP

View File

@@ -0,0 +1,136 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/unordered_multimap_view.hpp
/// \brief View of a side of a bimap that is signature compatible with tr1::unordered_multimap.
#ifndef BOOST_BIMAP_VIEWS_UNOREDERED_MULTIMAP_VIEW_HPP
#define BOOST_BIMAP_VIEWS_UNOREDERED_MULTIMAP_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <utility>
#include <boost/bimap/container_adaptor/unordered_multimap_adaptor.hpp>
#include <boost/bimap/detail/non_unique_views_helper.hpp>
#include <boost/bimap/support/iterator_type_by.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a side of a bimap that is signature compatible with tr1::unordered_multimap.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a tr1::unordered_multimap.
See also const_unordered_multimap_view.
**/
template< class Tag, class BimapType >
class unordered_multimap_view
:
public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
unordered_multimap_adaptor,
Tag,BimapType,
local_iterator_type_by,const_local_iterator_type_by
),
public ::boost::bimaps::detail::map_view_base<
unordered_multimap_view<Tag,BimapType>,Tag,BimapType >
{
typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
unordered_multimap_adaptor,
Tag,BimapType,
local_iterator_type_by,const_local_iterator_type_by
) base_;
BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(unordered_multimap_view,Tag,BimapType)
public:
typedef std::pair<
BOOST_DEDUCED_TYPENAME base_::iterator,
BOOST_DEDUCED_TYPENAME base_::iterator
> range_type;
typedef std::pair<
BOOST_DEDUCED_TYPENAME base_::const_iterator,
BOOST_DEDUCED_TYPENAME base_::const_iterator
> const_range_type;
typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
unordered_multimap_view(BOOST_DEDUCED_TYPENAME base_::base_type & c)
: base_(c) {}
BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS
unordered_multimap_view & operator=(const unordered_multimap_view & v)
{
this->base() = v.base();
return *this;
}
};
} // namespace views
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,local_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_local_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_range_type) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,hasher) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,key_equal)
/*===========================================================================*/
namespace detail {
template< class Tag, class BimapType >
struct left_map_view_extra_typedefs< ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
};
template< class Tag, class BimapType >
struct right_map_view_extra_typedefs< ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
};
} // namespace detail
/*===========================================================================*/
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
/*===========================================================================*/
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_UNOREDERED_MULTIMAP_VIEW_HPP

View File

@@ -0,0 +1,83 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/unordered_multiset_view.hpp
/// \brief View of a bimap that is signature compatible with tr1::unordered_multiset.
#ifndef BOOST_BIMAP_VIEWS_UNORDERED_MULTISET_VIEW_HPP
#define BOOST_BIMAP_VIEWS_UNORDERED_MULTISET_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/unordered_multiset_adaptor.hpp>
#include <boost/bimap/detail/non_unique_views_helper.hpp>
#include <boost/bimap/detail/set_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a bimap that is signature compatible with std::unordered_multiset.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::unordered_multiset.
See also const_unordered_multiset_view.
**/
template< class CoreIndex >
class unordered_multiset_view
:
public BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
unordered_multiset_adaptor,
CoreIndex,
local_iterator,
const_local_iterator
),
public ::boost::bimaps::detail::
set_view_base< unordered_multiset_view< CoreIndex >, CoreIndex >
{
BOOST_BIMAP_SET_VIEW_BASE_FRIEND(unordered_multiset_view,CoreIndex)
typedef BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
unordered_multiset_adaptor,
CoreIndex,
local_iterator,
const_local_iterator
) base_;
public:
unordered_multiset_view(BOOST_DEDUCED_TYPENAME base_::base_type & c)
: base_(c) {}
BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS
unordered_multiset_view & operator=(const unordered_multiset_view & v)
{
this->base() = v.base();
return *this;
}
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_UNORDERED_MULTISET_VIEW_HPP

View File

@@ -0,0 +1,78 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/unordered_set_view.hpp
/// \brief View of a bimap that is signature compatible with tr1::unordered_set.
#ifndef BOOST_BIMAP_VIEWS_UNORDERED_SET_VIEW_HPP
#define BOOST_BIMAP_VIEWS_UNORDERED_SET_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/unordered_set_adaptor.hpp>
#include <boost/bimap/detail/set_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a bimap that is signature compatible with std::unordered_set.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::unordered_set.
See also const_unordered_set_view.
**/
template< class CoreIndex >
class unordered_set_view
:
public BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
unordered_set_adaptor,
CoreIndex,
local_iterator,
const_local_iterator
),
public ::boost::bimaps::detail::
set_view_base< unordered_set_view< CoreIndex >, CoreIndex >
{
BOOST_BIMAP_SET_VIEW_BASE_FRIEND(unordered_set_view,CoreIndex)
typedef BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR(
unordered_set_adaptor,
CoreIndex,
local_iterator,
const_local_iterator
) base_;
public:
unordered_set_view(BOOST_DEDUCED_TYPENAME base_::base_type & c)
: base_(c) {}
unordered_set_view & operator=(const unordered_set_view & v)
{
this->base() = v.base();
return *this;
}
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_UNORDERED_SET_VIEW_HPP

View File

@@ -0,0 +1,306 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/vector_map_view.hpp
/// \brief View of a side of a bimap.
#ifndef BOOST_BIMAP_VIEWS_VECTOR_MAP_VIEW_HPP
#define BOOST_BIMAP_VIEWS_VECTOR_MAP_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/vector_map_adaptor.hpp>
#include <boost/bimap/support/iterator_type_by.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
#include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a side of a bimap.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core.
See also const_map_view.
**/
template< class Tag, class BimapType >
class vector_map_view
:
public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
vector_map_adaptor,
Tag,BimapType,
reverse_iterator_type_by, const_reverse_iterator_type_by
),
public ::boost::bimaps::detail::
map_view_base< vector_map_view<Tag,BimapType>,Tag,BimapType >
{
typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
vector_map_adaptor,
Tag,BimapType,
reverse_iterator_type_by, const_reverse_iterator_type_by
) base_;
BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(vector_map_view,Tag,BimapType)
typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::data_extractor
<
Tag,
BOOST_DEDUCED_TYPENAME BimapType::relation
>::type key_from_base_value;
public:
typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
vector_map_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) :
base_(c) {}
vector_map_view & operator=(const vector_map_view & v)
{
this->base() = v.base();
return *this;
}
BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(base_)
BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(base_)
// Lists operations
void splice(BOOST_DEDUCED_TYPENAME base_::iterator position, vector_map_view & x)
{
this->base().splice(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
x.base()
);
}
void splice(BOOST_DEDUCED_TYPENAME base_::iterator position,
vector_map_view & x,
BOOST_DEDUCED_TYPENAME base_::iterator i)
{
this->base().splice(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
x.base(),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
);
}
void splice(BOOST_DEDUCED_TYPENAME base_::iterator position,
vector_map_view & x,
BOOST_DEDUCED_TYPENAME base_::iterator first,
BOOST_DEDUCED_TYPENAME base_::iterator last)
{
this->base().splice(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
x.base(),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
);
}
void remove(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type value)
{
this->base().remove(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_to_base>()(value)
);
}
template< class Predicate >
void remove_if(Predicate pred)
{
this->base().remove_if(
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
Predicate,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
key_from_base_value
>( pred, key_from_base_value() )
);
}
void unique()
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::equal_to<BOOST_DEDUCED_TYPENAME base_::key_type>,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
key_from_base_value
>(std::equal_to<BOOST_DEDUCED_TYPENAME base_::key_type>(),
key_from_base_value() )
);
}
template< class BinaryPredicate >
void unique(BinaryPredicate binary_pred)
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
BinaryPredicate,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
key_from_base_value
>( binary_pred, key_from_base_value() )
);
}
void merge(vector_map_view & x)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<BOOST_DEDUCED_TYPENAME base_::key_type>,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
key_from_base_value
>( std::less<BOOST_DEDUCED_TYPENAME base_::key_type>(),
key_from_base_value() )
);
}
template< class Compare >
void merge(vector_map_view & x, Compare comp)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
key_from_base_value
>( comp, key_from_base_value() )
);
}
void sort()
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<BOOST_DEDUCED_TYPENAME base_::key_type>,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
key_from_base_value
>( std::less<BOOST_DEDUCED_TYPENAME base_::key_type>(),
key_from_base_value() )
);
}
template< class Compare >
void sort(Compare comp)
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
key_from_base_value
>( comp, key_from_base_value() )
);
}
void reverse()
{
this->base().reverse();
}
// Rearrange Operations
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator i)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
);
}
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator first,
BOOST_DEDUCED_TYPENAME base_::iterator last)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
);
}
};
} // namespace views
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
/*===========================================================================*/
/*===========================================================================*/
#define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
/*===========================================================================*/
namespace detail {
template< class Tag, class BimapType >
struct left_map_view_extra_typedefs< ::boost::bimaps::views::vector_map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::vector_map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
};
template< class Tag, class BimapType >
struct right_map_view_extra_typedefs< ::boost::bimaps::views::vector_map_view<Tag,BimapType> >
{
private: typedef ::boost::bimaps::views::vector_map_view<Tag,BimapType> map_view_;
public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
};
} // namespace detail
/*===========================================================================*/
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
#undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
/*===========================================================================*/
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_VECTOR_MAP_VIEW_HPP

View File

@@ -0,0 +1,279 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
/// \file views/vector_set_view.hpp
/// \brief View of a side of a bimap that is signature compatible with std::vector.
#ifndef BOOST_BIMAP_VIEWS_VECTOR_SET_VIEW_HPP
#define BOOST_BIMAP_VIEWS_VECTOR_SET_VIEW_HPP
#if defined(_MSC_VER) && (_MSC_VER>=1200)
#pragma once
#endif
#include <boost/config.hpp>
#include <boost/bimap/container_adaptor/vector_adaptor.hpp>
#include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
#include <boost/bimap/detail/set_view_base.hpp>
#include <boost/bimap/detail/map_view_base.hpp>
namespace boost {
namespace bimaps {
namespace views {
/// \brief View of a bimap that is signature compatible with std::vector.
/**
This class uses container_adaptor and iterator_adaptor to wrapped a index of the
multi_index bimap core so it can be used as a std::vector.
See also const_set_view.
**/
template< class CoreIndex >
class vector_set_view
:
public BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR(
vector_adaptor,
CoreIndex,
reverse_iterator, const_reverse_iterator
),
public ::boost::bimaps::detail::
set_view_base< vector_set_view< CoreIndex >, CoreIndex >
{
BOOST_BIMAP_SET_VIEW_BASE_FRIEND(vector_set_view,CoreIndex)
typedef BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR(
vector_adaptor,
CoreIndex,
reverse_iterator, const_reverse_iterator
) base_;
public:
vector_set_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) :
base_(c) {}
vector_set_view & operator=(const vector_set_view & v)
{
this->base() = v.base();
return *this;
}
BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(base_)
BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(base_)
// List operations
void splice(BOOST_DEDUCED_TYPENAME base_::iterator position,
vector_set_view & x)
{
this->base().splice(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
x.base()
);
}
void splice(BOOST_DEDUCED_TYPENAME base_::iterator position,
vector_set_view & x,
BOOST_DEDUCED_TYPENAME base_::iterator i)
{
this->base().splice(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
x.base(),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
);
}
void splice(BOOST_DEDUCED_TYPENAME base_::iterator position,
vector_set_view & x,
BOOST_DEDUCED_TYPENAME base_::iterator first,
BOOST_DEDUCED_TYPENAME base_::iterator last)
{
this->base().splice(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
x.base(),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
);
}
void remove(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
BOOST_DEDUCED_TYPENAME base_::value_type >::param_type value)
{
this->base().remove(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_to_base>()(value)
);
}
template<typename Predicate>
void remove_if(Predicate pred)
{
this->base().remove_if(
::boost::bimaps::container_adaptor::detail::unary_check_adaptor
<
Predicate,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( pred, this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
void unique()
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::equal_to<BOOST_DEDUCED_TYPENAME base_::value_type>,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>(
std::equal_to<BOOST_DEDUCED_TYPENAME base_::value_type>(),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
)
);
}
template< class BinaryPredicate >
void unique(BinaryPredicate binary_pred)
{
this->base().unique(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
BinaryPredicate,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( binary_pred,
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
)
);
}
void merge(vector_set_view & x)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>(
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>(),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
)
);
}
template< class Compare >
void merge(vector_set_view & x, Compare comp)
{
this->base().merge(x.base(),
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( comp, this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
void sort()
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>(
std::less<BOOST_DEDUCED_TYPENAME base_::value_type>(),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>()
)
);
}
template< class Compare >
void sort(Compare comp)
{
this->base().sort(
::boost::bimaps::container_adaptor::detail::comparison_adaptor
<
Compare,
BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
BOOST_DEDUCED_TYPENAME base_::value_from_base
>( comp, this->template functor<
BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
);
}
void reverse()
{
this->base().reverse();
}
// Rearrange Operations
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator i)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
);
}
void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
BOOST_DEDUCED_TYPENAME base_::iterator first,
BOOST_DEDUCED_TYPENAME base_::iterator last)
{
this->base().relocate(
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
this->template functor<
BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
);
}
};
} // namespace views
} // namespace bimaps
} // namespace boost
#endif // BOOST_BIMAP_VIEWS_VECTOR_SET_VIEW_HPP