1 // Boost.Bimap 2 // 3 // Copyright (c) 2006-2007 Matias Capeletto 4 // 5 // Distributed under the Boost Software License, Version 1.0. 6 // (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 /// \file unconstrained_set_of.hpp 10 /// \brief Include support for set constrains for the bimap container 11 12 #ifndef BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP 13 #define BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP 14 15 #if defined(_MSC_VER) 16 #pragma once 17 #endif 18 19 #include <boost/config.hpp> 20 21 #include <boost/bimap/detail/user_interface_config.hpp> 22 23 #include <boost/mpl/bool.hpp> 24 25 #include <boost/concept_check.hpp> 26 27 #include <boost/bimap/detail/concept_tags.hpp> 28 29 #include <boost/bimap/tags/support/value_type_of.hpp> 30 31 #include <boost/bimap/detail/generate_index_binder.hpp> 32 #include <boost/bimap/detail/generate_view_binder.hpp> 33 #include <boost/bimap/detail/generate_relation_binder.hpp> 34 35 #include <boost/bimap/views/unconstrained_map_view.hpp> 36 #include <boost/bimap/views/unconstrained_set_view.hpp> 37 38 namespace boost { 39 namespace bimaps { 40 41 /// \brief Set Type Specification 42 /** 43 This struct is used to specify a set specification. 44 It is not a container, it is just a metaprogramming facility to 45 express the type of a set. Generally, this specification will 46 be used in other place to create a container. 47 The first parameter is the type of the objects in the set. 48 49 \code 50 51 using namespace support; 52 53 BOOST_STATIC_ASSERT( is_set_type_of< unconstrained_set_of<Type> >::value ) 54 55 \endcode 56 57 See also unconstrained_set_of_relation. 58 **/ 59 60 template 61 < 62 class KeyType 63 > 64 struct unconstrained_set_of : public ::boost::bimaps::detail::set_type_of_tag 65 { 66 /// User type, can be tagged 67 typedef KeyType user_type; 68 69 /// Type of the object that will be stored in the container 70 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support:: 71 value_type_of<user_type>::type value_type; 72 73 struct lazy_concept_checked 74 { 75 BOOST_CLASS_REQUIRE ( value_type, 76 boost, AssignableConcept ); 77 78 typedef unconstrained_set_of type; 79 }; 80 81 BOOST_BIMAP_GENERATE_INDEX_BINDER_FAKE 82 83 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER( 84 85 // binds to 86 views::unconstrained_map_view 87 ) 88 89 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER( 90 91 // binds to 92 views::unconstrained_set_view 93 ) 94 95 typedef mpl::bool_<true> mutable_key; 96 }; 97 98 /// \brief Set Of Relation Specification 99 /** 100 This struct is similar to unconstrained_set_of but it is bind 101 logically to a relation. It is used in the bimap instantiation to 102 specify the desired type of the main view. 103 104 See also unconstrained_set_of, is_set_type_of_relation. 105 **/ 106 107 struct unconstrained_set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag 108 { 109 110 BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP( 111 112 // binds to 113 unconstrained_set_of 114 ) 115 116 typedef mpl::bool_<true> left_mutable_key; 117 typedef mpl::bool_<true> right_mutable_key; 118 }; 119 120 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 121 122 namespace detail { 123 124 template<class T> 125 struct is_unconstrained_set_of : 126 ::boost::mpl::false_ {}; 127 128 template<class T> 129 struct is_unconstrained_set_of< unconstrained_set_of<T> > : 130 ::boost::mpl::true_ {}; 131 132 } // namespace detail 133 134 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 135 136 } // namespace bimaps 137 } // namespace boost 138 139 140 /** \struct boost::bimaps::detail::is_unconstrained_set_of 141 \brief Trait to check if a type is unconstrained_set_of. 142 \code 143 template< class T > 144 struct is_unconstrained_set_of; 145 \endcode 146 **/ 147 148 149 #endif // BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP 150 151