indexed_by.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright 2003-2008 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_INDEXED_BY_HPP
  9. #define BOOST_MULTI_INDEX_INDEXED_BY_HPP
  10. #if defined(_MSC_VER)&&(_MSC_VER>=1200)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/mpl/vector.hpp>
  15. #include <boost/preprocessor/cat.hpp>
  16. #include <boost/preprocessor/control/expr_if.hpp>
  17. #include <boost/preprocessor/repetition/enum.hpp>
  18. #include <boost/preprocessor/repetition/enum_params.hpp>
  19. /* An alias to mpl::vector used to hide MPL from the user.
  20. * indexed_by contains the index specifiers for instantiation
  21. * of a multi_index_container.
  22. */
  23. /* This user_definable macro limits the number of elements of an index list;
  24. * useful for shortening resulting symbol names (MSVC++ 6.0, for instance,
  25. * has problems coping with very long symbol names.)
  26. */
  27. #if !defined(BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE)
  28. #if defined(BOOST_MSVC)&&(BOOST_MSVC<1300)
  29. #define BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE 5
  30. #else
  31. #define BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
  32. #endif
  33. #endif
  34. #if BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE<BOOST_MPL_LIMIT_VECTOR_SIZE
  35. #define BOOST_MULTI_INDEX_INDEXED_BY_SIZE \
  36. BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE
  37. #else
  38. #define BOOST_MULTI_INDEX_INDEXED_BY_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
  39. #endif
  40. #define BOOST_MULTI_INDEX_INDEXED_BY_TEMPLATE_PARM(z,n,var) \
  41. typename BOOST_PP_CAT(var,n) BOOST_PP_EXPR_IF(n,=mpl::na)
  42. namespace boost{
  43. namespace multi_index{
  44. template<
  45. BOOST_PP_ENUM(
  46. BOOST_MULTI_INDEX_INDEXED_BY_SIZE,
  47. BOOST_MULTI_INDEX_INDEXED_BY_TEMPLATE_PARM,T)
  48. >
  49. struct indexed_by:
  50. mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_MULTI_INDEX_INDEXED_BY_SIZE,T)>
  51. {
  52. };
  53. } /* namespace multi_index */
  54. } /* namespace boost */
  55. #undef BOOST_MULTI_INDEX_INDEXED_BY_TEMPLATE_PARM
  56. #undef BOOST_MULTI_INDEX_INDEXED_BY_SIZE
  57. #endif