ordered_index.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* Copyright 2003-2015 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/multi_index for library home page.
  7. */
  8. #ifndef BOOST_MULTI_INDEX_ORDERED_INDEX_HPP
  9. #define BOOST_MULTI_INDEX_ORDERED_INDEX_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/multi_index/detail/ord_index_impl.hpp>
  15. #include <boost/multi_index/ordered_index_fwd.hpp>
  16. namespace boost{
  17. namespace multi_index{
  18. namespace detail{
  19. /* no augment policy for plain ordered indices */
  20. struct null_augment_policy
  21. {
  22. template<typename OrderedIndexImpl>
  23. struct augmented_interface
  24. {
  25. typedef OrderedIndexImpl type;
  26. };
  27. template<typename OrderedIndexNodeImpl>
  28. struct augmented_node
  29. {
  30. typedef OrderedIndexNodeImpl type;
  31. };
  32. template<typename Pointer> static void add(Pointer,Pointer){}
  33. template<typename Pointer> static void remove(Pointer,Pointer){}
  34. template<typename Pointer> static void copy(Pointer,Pointer){}
  35. template<typename Pointer> static void rotate_left(Pointer,Pointer){}
  36. template<typename Pointer> static void rotate_right(Pointer,Pointer){}
  37. #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
  38. /* invariant stuff */
  39. template<typename Pointer> static bool invariant(Pointer){return true;}
  40. #endif
  41. };
  42. } /* namespace multi_index::detail */
  43. /* ordered_index specifiers */
  44. template<typename Arg1,typename Arg2,typename Arg3>
  45. struct ordered_unique
  46. {
  47. typedef typename detail::ordered_index_args<
  48. Arg1,Arg2,Arg3> index_args;
  49. typedef typename index_args::tag_list_type::type tag_list_type;
  50. typedef typename index_args::key_from_value_type key_from_value_type;
  51. typedef typename index_args::compare_type compare_type;
  52. template<typename Super>
  53. struct node_class
  54. {
  55. typedef detail::ordered_index_node<detail::null_augment_policy,Super> type;
  56. };
  57. template<typename SuperMeta>
  58. struct index_class
  59. {
  60. typedef detail::ordered_index<
  61. key_from_value_type,compare_type,
  62. SuperMeta,tag_list_type,detail::ordered_unique_tag,
  63. detail::null_augment_policy> type;
  64. };
  65. };
  66. template<typename Arg1,typename Arg2,typename Arg3>
  67. struct ordered_non_unique
  68. {
  69. typedef detail::ordered_index_args<
  70. Arg1,Arg2,Arg3> index_args;
  71. typedef typename index_args::tag_list_type::type tag_list_type;
  72. typedef typename index_args::key_from_value_type key_from_value_type;
  73. typedef typename index_args::compare_type compare_type;
  74. template<typename Super>
  75. struct node_class
  76. {
  77. typedef detail::ordered_index_node<detail::null_augment_policy,Super> type;
  78. };
  79. template<typename SuperMeta>
  80. struct index_class
  81. {
  82. typedef detail::ordered_index<
  83. key_from_value_type,compare_type,
  84. SuperMeta,tag_list_type,detail::ordered_non_unique_tag,
  85. detail::null_augment_policy> type;
  86. };
  87. };
  88. } /* namespace multi_index */
  89. } /* namespace boost */
  90. #endif