indexed_by.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright 2003-2013 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)
  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. #define BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
  29. #endif
  30. #if BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE<BOOST_MPL_LIMIT_VECTOR_SIZE
  31. #define BOOST_MULTI_INDEX_INDEXED_BY_SIZE \
  32. BOOST_MULTI_INDEX_LIMIT_INDEXED_BY_SIZE
  33. #else
  34. #define BOOST_MULTI_INDEX_INDEXED_BY_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
  35. #endif
  36. #define BOOST_MULTI_INDEX_INDEXED_BY_TEMPLATE_PARM(z,n,var) \
  37. typename BOOST_PP_CAT(var,n) BOOST_PP_EXPR_IF(n,=mpl::na)
  38. namespace boost{
  39. namespace multi_index{
  40. template<
  41. BOOST_PP_ENUM(
  42. BOOST_MULTI_INDEX_INDEXED_BY_SIZE,
  43. BOOST_MULTI_INDEX_INDEXED_BY_TEMPLATE_PARM,T)
  44. >
  45. struct indexed_by:
  46. mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_MULTI_INDEX_INDEXED_BY_SIZE,T)>
  47. {
  48. };
  49. } /* namespace multi_index */
  50. } /* namespace boost */
  51. #undef BOOST_MULTI_INDEX_INDEXED_BY_TEMPLATE_PARM
  52. #undef BOOST_MULTI_INDEX_INDEXED_BY_SIZE
  53. #endif