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

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