source: NonGTP/Boost/boost/multi_index/detail/base_type.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 18 years ago (diff)
Line 
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_DETAIL_BASE_TYPE_HPP
10#define BOOST_MULTI_INDEX_DETAIL_BASE_TYPE_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/detail/workaround.hpp>
18#include <boost/mpl/at.hpp>
19#include <boost/mpl/apply.hpp>
20#include <boost/mpl/size.hpp>
21#include <boost/multi_index/detail/index_base.hpp>
22#include <boost/multi_index/detail/is_index_list.hpp>
23#include <boost/multi_index/detail/msvc_index_specifier.hpp>
24#include <boost/static_assert.hpp>
25
26namespace boost{
27
28namespace multi_index{
29
30namespace detail{
31
32/* MPL machinery to construct a linear hierarchy of indices out of
33 * a index list.
34 */
35
36#if BOOST_WORKAROUND(BOOST_MSVC,<1310)
37struct index_applier
38{
39  template<typename IndexSpecifierMeta,typename SuperMeta>
40  struct apply:
41    msvc_index_specifier<IndexSpecifierMeta::type>::
42      template result_index_class<SuperMeta>
43  {
44  };
45};
46#else
47struct index_applier
48{
49  template<typename IndexSpecifierMeta,typename Super>
50  struct apply
51  {
52    typedef typename IndexSpecifierMeta::type        index_specifier;
53    typedef typename index_specifier::
54      BOOST_NESTED_TEMPLATE index_class<Super>::type type;
55  };
56};
57#endif
58
59template<int N,typename Value,typename IndexSpecifierList,typename Allocator>
60struct nth_layer
61{
62  BOOST_STATIC_CONSTANT(int,length=mpl::size<IndexSpecifierList>::value);
63
64  typedef typename  mpl::eval_if_c<
65    N==length,
66    mpl::identity<index_base<Value,IndexSpecifierList,Allocator> >,
67    mpl::apply2<
68      index_applier,
69      mpl::at_c<IndexSpecifierList,N>,
70      nth_layer<N+1,Value,IndexSpecifierList,Allocator>
71    >
72  >::type type;
73};
74
75template<typename Value,typename IndexSpecifierList,typename Allocator>
76struct multi_index_base_type:nth_layer<0,Value,IndexSpecifierList,Allocator>
77{
78  BOOST_STATIC_ASSERT(detail::is_index_list<IndexSpecifierList>::value);
79};
80
81} /* namespace multi_index::detail */
82
83} /* namespace multi_index */
84
85} /* namespace boost */
86
87#endif
Note: See TracBrowser for help on using the repository browser.