1 /* Copyright 2003-2005 Joaquín M López Muñoz.
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
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
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 #if defined(BOOST_MSVC)&&(BOOST_MSVC<1300)
38 #define BOOST_MULTI_INDEX_LIMIT_TAG_SIZE 3
40 #define BOOST_MULTI_INDEX_LIMIT_TAG_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
44 #if BOOST_MULTI_INDEX_LIMIT_TAG_SIZE<BOOST_MPL_LIMIT_VECTOR_SIZE
45 #define BOOST_MULTI_INDEX_TAG_SIZE BOOST_MULTI_INDEX_LIMIT_TAG_SIZE
47 #define BOOST_MULTI_INDEX_TAG_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
52 namespace multi_index{
61 BOOST_STATIC_CONSTANT(bool,value=(is_base_and_derived<tag_marker,T>::value));
64 } /* namespace multi_index::detail */
67 BOOST_PP_ENUM_BINARY_PARAMS(
68 BOOST_MULTI_INDEX_TAG_SIZE,
70 =mpl::na BOOST_PP_INTERCEPT)
72 struct tag:private detail::tag_marker
74 /* The mpl::transform pass produces shorter symbols (without
75 * trailing mpl::na's.)
78 typedef typename mpl::transform<
79 mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_MULTI_INDEX_TAG_SIZE,T)>,
80 mpl::identity<mpl::_1>
83 BOOST_STATIC_ASSERT(detail::no_duplicate_tags<type>::value);
86 } /* namespace multi_index */
88 } /* namespace boost */
90 #undef BOOST_MULTI_INDEX_TAG_SIZE