Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:34:18

0001 // Boost.Bimap
0002 //
0003 // Copyright (c) 2006-2007 Matias Capeletto
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 /// \file set_of.hpp
0010 /// \brief Include support for set constrains for the bimap container
0011 
0012 #ifndef BOOST_BIMAP_SET_OF_HPP
0013 #define BOOST_BIMAP_SET_OF_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 #include <boost/bimap/detail/user_interface_config.hpp>
0022 
0023 #include <functional>
0024 #include <boost/mpl/bool.hpp>
0025 #include <boost/mpl/aux_/na.hpp>
0026 
0027 #include <boost/concept_check.hpp>
0028 
0029 #include <boost/bimap/detail/concept_tags.hpp>
0030 
0031 #include <boost/bimap/detail/generate_index_binder.hpp>
0032 #include <boost/bimap/detail/generate_view_binder.hpp>
0033 #include <boost/bimap/detail/generate_relation_binder.hpp>
0034 
0035 #include <boost/bimap/tags/support/value_type_of.hpp>
0036 
0037 #include <boost/multi_index/ordered_index.hpp>
0038 
0039 #include <boost/bimap/views/map_view.hpp>
0040 #include <boost/bimap/views/set_view.hpp>
0041 
0042 namespace boost {
0043 namespace bimaps {
0044 
0045 /// \brief Set Type Specification
0046 /**
0047 This struct is used to specify a set specification.
0048 It is not a container, it is just a metaprogramming facility to
0049 express the type of a set. Generally, this specification will
0050 be used in other place to create a container.
0051 It has the same syntax that an std::set instantiation, except
0052 that the allocator cannot be specified. The rationale behind
0053 this difference is that the allocator is not part of the set
0054 type specification, rather it is a container configuration
0055 parameter.
0056 The first parameter is the type of the objects in the set, and
0057 the second one is a Functor that compares them.
0058 Bimap binding metafunctions can be used with this class in
0059 the following way:
0060 
0061 \code
0062 using namespace support;
0063 
0064 BOOST_STATIC_ASSERT( is_set_type_of< set_of<Type> >::value )
0065 
0066 BOOST_STATIC_ASSERT
0067 (
0068      is_same
0069      <
0070         set_of<Type,KeyCompare>::index_bind
0071         <
0072             KeyExtractor,
0073             Tag
0074 
0075         >::type,
0076 
0077         ordered_unique< tag<Tag>, KeyExtractor, KeyCompare >
0078 
0079     >::value
0080 )
0081 
0082 typedef bimap
0083 <
0084     set_of<Type>, RightKeyType
0085 
0086 > bimap_with_left_type_as_set;
0087 
0088 BOOST_STATIC_ASSERT
0089 (
0090     is_same
0091     <
0092         set_of<Type>::map_view_bind
0093         <
0094             member_at::left,
0095             bimap_with_left_type_as_set
0096 
0097         >::type,
0098 
0099         map_view< member_at::left, bimap_with_left_type_as_set >
0100 
0101     >::value
0102 )
0103 
0104 \endcode
0105 
0106 See also set_of_relation.
0107                                                                         **/
0108 
0109 template
0110 <
0111     class KeyType,
0112     class KeyCompare = std::less< BOOST_DEDUCED_TYPENAME 
0113         ::boost::bimaps::tags::support::value_type_of<KeyType>::type >
0114 >
0115 struct set_of : public ::boost::bimaps::detail::set_type_of_tag
0116 {
0117     /// User type, can be tagged
0118     typedef KeyType user_type;
0119 
0120     /// Type of the object that will be stored in the set
0121     typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
0122         value_type_of<user_type>::type value_type;
0123 
0124     /// Functor that compare two keys
0125     typedef KeyCompare key_compare;
0126 
0127     struct lazy_concept_checked
0128     {
0129         BOOST_CLASS_REQUIRE ( value_type,
0130                               boost, AssignableConcept );
0131 
0132         BOOST_CLASS_REQUIRE4( key_compare, bool, value_type, value_type,
0133                               boost, BinaryFunctionConcept );
0134 
0135         typedef set_of type;
0136     };
0137 
0138     BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
0139 
0140         // binds to
0141         multi_index::ordered_unique,
0142 
0143         // with
0144         key_compare
0145     )
0146 
0147     BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
0148 
0149         // binds to
0150         views::map_view
0151     )
0152 
0153     BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
0154 
0155         // binds to
0156         views::set_view
0157     )
0158 
0159     typedef mpl::bool_<false> mutable_key;
0160 };
0161 
0162 
0163 /// \brief Set Of Relation Specification
0164 /**
0165 This struct is similar to set_of but it is bind logically to a
0166 relation. It is used in the bimap instantiation to specify the
0167 desired type of the main view. This struct implements internally
0168 a metafunction named bind_to that manages the quite complicated
0169 task of finding the right type of the set for the relation.
0170 
0171 \code
0172 template<class Relation>
0173 struct bind_to
0174 {
0175     typedef -unspecified- type;
0176 };
0177 \endcode
0178 
0179 See also set_of, is_set_type_of_relation.
0180                                                                 **/
0181 
0182 template< class KeyCompare = std::less< _relation > >
0183 struct set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
0184 {
0185     /// Functor that compare two keys
0186     typedef KeyCompare key_compare;
0187 
0188     BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(
0189 
0190         // binds to
0191         set_of,
0192 
0193         // with
0194         key_compare
0195     )
0196 
0197     typedef mpl::bool_<false>  left_mutable_key;
0198     typedef mpl::bool_<false> right_mutable_key;
0199 };
0200 
0201 } // namespace bimaps
0202 } // namespace boost
0203 
0204 
0205 #endif // BOOST_BIMAP_SET_OF_HPP
0206