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