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)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_TAG_HPP
10 #define BOOST_MULTI_INDEX_TAG_HPP
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/multi_index/detail/no_duplicate_tags.hpp>
18 #include <boost/mpl/identity.hpp>
19 #include <boost/mpl/transform.hpp>
20 #include <boost/mpl/vector.hpp>
21 #include <boost/preprocessor/facilities/intercept.hpp>
22 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
23 #include <boost/preprocessor/repetition/enum_params.hpp>
24 #include <boost/static_assert.hpp>
25 #include <boost/type_traits/is_base_and_derived.hpp>
27 /* A wrapper of mpl::vector used to hide MPL from the user.
28 * tag contains types used as tag names for indices in get() functions.
31 /* This user_definable macro limits the number of elements of a tag;
32 * useful for shortening resulting symbol names (MSVC++ 6.0, for instance,
33 * has problems coping with very long symbol names.)
36 #if !defined(BOOST_MULTI_INDEX_LIMIT_TAG_SIZE)
37 #define BOOST_MULTI_INDEX_LIMIT_TAG_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
40 #if BOOST_MULTI_INDEX_LIMIT_TAG_SIZE<BOOST_MPL_LIMIT_VECTOR_SIZE
41 #define BOOST_MULTI_INDEX_TAG_SIZE BOOST_MULTI_INDEX_LIMIT_TAG_SIZE
43 #define BOOST_MULTI_INDEX_TAG_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
48 namespace multi_index{
57 BOOST_STATIC_CONSTANT(bool,value=(is_base_and_derived<tag_marker,T>::value));
60 } /* namespace multi_index::detail */
63 BOOST_PP_ENUM_BINARY_PARAMS(
64 BOOST_MULTI_INDEX_TAG_SIZE,
66 =mpl::na BOOST_PP_INTERCEPT)
68 struct tag:private detail::tag_marker
70 /* The mpl::transform pass produces shorter symbols (without
71 * trailing mpl::na's.)
74 typedef typename mpl::transform<
75 mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_MULTI_INDEX_TAG_SIZE,T)>,
76 mpl::identity<mpl::_1>
79 BOOST_STATIC_ASSERT(detail::no_duplicate_tags<type>::value);
82 } /* namespace multi_index */
84 } /* namespace boost */
86 #undef BOOST_MULTI_INDEX_TAG_SIZE