[857] | 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)
|
---|
| 5 | *
|
---|
| 6 | * See http://www.boost.org/libs/multi_index for library home page.
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | #ifndef BOOST_MULTI_INDEX_TAG_HPP
|
---|
| 10 | #define BOOST_MULTI_INDEX_TAG_HPP
|
---|
| 11 |
|
---|
| 12 | #if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
---|
| 13 | #pragma once
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 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>
|
---|
| 26 |
|
---|
| 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.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 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.)
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 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
|
---|
| 39 | #else
|
---|
| 40 | #define BOOST_MULTI_INDEX_LIMIT_TAG_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
|
---|
| 41 | #endif
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
| 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
|
---|
| 46 | #else
|
---|
| 47 | #define BOOST_MULTI_INDEX_TAG_SIZE BOOST_MPL_LIMIT_VECTOR_SIZE
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 | namespace boost{
|
---|
| 51 |
|
---|
| 52 | namespace multi_index{
|
---|
| 53 |
|
---|
| 54 | namespace detail{
|
---|
| 55 |
|
---|
| 56 | struct tag_marker{};
|
---|
| 57 |
|
---|
| 58 | template<typename T>
|
---|
| 59 | struct is_tag
|
---|
| 60 | {
|
---|
| 61 | BOOST_STATIC_CONSTANT(bool,value=(is_base_and_derived<tag_marker,T>::value));
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 | } /* namespace multi_index::detail */
|
---|
| 65 |
|
---|
| 66 | template<
|
---|
| 67 | BOOST_PP_ENUM_BINARY_PARAMS(
|
---|
| 68 | BOOST_MULTI_INDEX_TAG_SIZE,
|
---|
| 69 | typename T,
|
---|
| 70 | =mpl::na BOOST_PP_INTERCEPT)
|
---|
| 71 | >
|
---|
| 72 | struct tag:private detail::tag_marker
|
---|
| 73 | {
|
---|
| 74 | /* The mpl::transform pass produces shorter symbols (without
|
---|
| 75 | * trailing mpl::na's.)
|
---|
| 76 | */
|
---|
| 77 |
|
---|
| 78 | typedef typename mpl::transform<
|
---|
| 79 | mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_MULTI_INDEX_TAG_SIZE,T)>,
|
---|
| 80 | mpl::identity<mpl::_1>
|
---|
| 81 | >::type type;
|
---|
| 82 |
|
---|
| 83 | BOOST_STATIC_ASSERT(detail::no_duplicate_tags<type>::value);
|
---|
| 84 | };
|
---|
| 85 |
|
---|
| 86 | } /* namespace multi_index */
|
---|
| 87 |
|
---|
| 88 | } /* namespace boost */
|
---|
| 89 |
|
---|
| 90 | #undef BOOST_MULTI_INDEX_TAG_SIZE
|
---|
| 91 |
|
---|
| 92 | #endif
|
---|