list_of.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. /// \file list_of.hpp
  9. /// \brief Include support for list constrains for the bimap container
  10. #ifndef BOOST_BIMAP_LIST_OF_HPP
  11. #define BOOST_BIMAP_LIST_OF_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. #include <boost/bimap/detail/user_interface_config.hpp>
  17. #include <boost/mpl/bool.hpp>
  18. #include <boost/concept_check.hpp>
  19. #include <boost/bimap/detail/concept_tags.hpp>
  20. #include <boost/bimap/tags/support/value_type_of.hpp>
  21. #include <boost/bimap/detail/generate_index_binder.hpp>
  22. #include <boost/bimap/detail/generate_view_binder.hpp>
  23. #include <boost/bimap/detail/generate_relation_binder.hpp>
  24. #include <boost/multi_index/sequenced_index.hpp>
  25. #include <boost/bimap/views/list_map_view.hpp>
  26. #include <boost/bimap/views/list_set_view.hpp>
  27. namespace boost {
  28. namespace bimaps {
  29. /// \brief Set Type Specification
  30. /**
  31. This struct is used to specify a set specification.
  32. It is not a container, it is just a metaprogramming facility to
  33. express the type of a set. Generally, this specification will
  34. be used in other place to create a container.
  35. It has the same syntax that an std::list instantiation, except
  36. that the allocator cannot be specified. The rationale behind
  37. this difference is that the allocator is not part of the set
  38. type specification, rather it is a container configuration
  39. parameter.
  40. \code
  41. using namespace support;
  42. BOOST_STATIC_ASSERT( is_set_type_of< list_of<Type> >::value )
  43. BOOST_STATIC_ASSERT
  44. (
  45. is_same
  46. <
  47. list_of<Type>::index_bind
  48. <
  49. KeyExtractor,
  50. Tag
  51. >::type,
  52. sequenced< tag<Tag>, KeyExtractor >
  53. >::value
  54. )
  55. typedef bimap
  56. <
  57. list_of<Type>, RightKeyType
  58. > bimap_with_left_type_as_list;
  59. BOOST_STATIC_ASSERT
  60. (
  61. is_same
  62. <
  63. list_of<Type>::map_view_bind
  64. <
  65. member_at::left,
  66. bimap_with_left_type_as_list
  67. >::type,
  68. list_map_view< member_at::left, bimap_with_left_type_as_list >
  69. >::value
  70. )
  71. \endcode
  72. See also list_of_relation.
  73. **/
  74. template< class Type >
  75. struct list_of : public ::boost::bimaps::detail::set_type_of_tag
  76. {
  77. /// User type, can be tagged
  78. typedef Type user_type;
  79. /// Type of the object that will be stored in the list
  80. typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
  81. value_type_of<user_type>::type value_type;
  82. struct lazy_concept_checked
  83. {
  84. BOOST_CLASS_REQUIRE ( value_type,
  85. boost, AssignableConcept );
  86. typedef list_of type;
  87. };
  88. BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP_NO_EXTRACTOR(
  89. // binds to
  90. multi_index::sequenced
  91. )
  92. BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
  93. // binds to
  94. views::list_map_view
  95. )
  96. BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
  97. // binds to
  98. views::list_set_view
  99. )
  100. typedef mpl::bool_<true> mutable_key;
  101. };
  102. /// \brief List Of Relation Specification
  103. /**
  104. This struct is similar to list_of but it is bind logically to a
  105. relation. It is used in the bimap instantiation to specify the
  106. desired type of the main view. This struct implements internally
  107. a metafunction named bind_to that manages the quite complicated
  108. task of finding the right type of the set for the relation.
  109. \code
  110. template<class Relation>
  111. struct bind_to
  112. {
  113. typedef -unspecified- type;
  114. };
  115. \endcode
  116. See also list_of, is_set_type_of_relation.
  117. **/
  118. struct list_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
  119. {
  120. BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
  121. // binds to
  122. list_of
  123. )
  124. typedef mpl::bool_<true> left_mutable_key;
  125. typedef mpl::bool_<true> right_mutable_key;
  126. };
  127. } // namespace bimaps
  128. } // namespace boost
  129. #endif // BOOST_BIMAP_LIST_OF_HPP