unconstrained_set_of.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 unconstrained_set_of.hpp
  9. /// \brief Include support for set constrains for the bimap container
  10. #ifndef BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP
  11. #define BOOST_BIMAP_UNCONSTRAINED_SET_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/bimap/views/unconstrained_map_view.hpp>
  25. #include <boost/bimap/views/unconstrained_set_view.hpp>
  26. namespace boost {
  27. namespace bimaps {
  28. /// \brief Set Type Specification
  29. /**
  30. This struct is used to specify a set specification.
  31. It is not a container, it is just a metaprogramming facility to
  32. express the type of a set. Generally, this specification will
  33. be used in other place to create a container.
  34. The first parameter is the type of the objects in the set.
  35. \code
  36. using namespace support;
  37. BOOST_STATIC_ASSERT( is_set_type_of< unconstrained_set_of<Type> >::value )
  38. \endcode
  39. See also unconstrained_set_of_relation.
  40. **/
  41. template
  42. <
  43. class KeyType
  44. >
  45. struct unconstrained_set_of : public ::boost::bimaps::detail::set_type_of_tag
  46. {
  47. /// User type, can be tagged
  48. typedef KeyType user_type;
  49. /// Type of the object that will be stored in the container
  50. typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
  51. value_type_of<user_type>::type value_type;
  52. struct lazy_concept_checked
  53. {
  54. BOOST_CLASS_REQUIRE ( value_type,
  55. boost, AssignableConcept );
  56. typedef unconstrained_set_of type;
  57. };
  58. BOOST_BIMAP_GENERATE_INDEX_BINDER_FAKE
  59. BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
  60. // binds to
  61. views::unconstrained_map_view
  62. )
  63. BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
  64. // binds to
  65. views::unconstrained_set_view
  66. )
  67. typedef mpl::bool_<true> mutable_key;
  68. };
  69. /// \brief Set Of Relation Specification
  70. /**
  71. This struct is similar to unconstrained_set_of but it is bind
  72. logically to a relation. It is used in the bimap instantiation to
  73. specify the desired type of the main view.
  74. See also unconstrained_set_of, is_set_type_of_relation.
  75. **/
  76. struct unconstrained_set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
  77. {
  78. BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
  79. // binds to
  80. unconstrained_set_of
  81. )
  82. typedef mpl::bool_<true> left_mutable_key;
  83. typedef mpl::bool_<true> right_mutable_key;
  84. };
  85. #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  86. namespace detail {
  87. template<class T>
  88. struct is_unconstrained_set_of :
  89. ::boost::mpl::false_ {};
  90. template<class T>
  91. struct is_unconstrained_set_of< unconstrained_set_of<T> > :
  92. ::boost::mpl::true_ {};
  93. } // namespace detail
  94. #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  95. } // namespace bimaps
  96. } // namespace boost
  97. /** \struct boost::bimaps::detail::is_unconstrained_set_of
  98. \brief Trait to check if a type is unconstrained_set_of.
  99. \code
  100. template< class T >
  101. struct is_unconstrained_set_of;
  102. \endcode
  103. **/
  104. #endif // BOOST_BIMAP_UNCONSTRAINED_SET_OF_HPP