1/* Copyright 2003-2021 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_DETAIL_INDEX_ACCESS_SEQUENCE_HPP
10#define BOOST_MULTI_INDEX_DETAIL_INDEX_ACCESS_SEQUENCE_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/if.hpp>
18#include <boost/mpl/size.hpp>
19#include <boost/multi_index_container_fwd.hpp>
20
21namespace boost{
22
23namespace multi_index{
24
25namespace detail{
26
27/* Successive access to the indices of a multi_index_container. Used as dst in
28 * backbone function extract_(x,dst) to retrieve the destination indices
29 * where iterators referring to x must be transferred to (in merging
30 * operations).
31 */
32
33template<typename MultiIndexContainer,int N=0>
34struct index_access_sequence;
35
36struct index_access_sequence_terminal
37{
38 index_access_sequence_terminal(void*){}
39};
40
41template<typename MultiIndexContainer,int N>
42struct index_access_sequence_normal
43{
44 MultiIndexContainer* p;
45
46 index_access_sequence_normal(MultiIndexContainer* p_):p(p_){}
47
48 typename nth_index<MultiIndexContainer,N>::type&
49 get(){return p->template get<N>();}
50
51 index_access_sequence<MultiIndexContainer,N+1>
52 next(){return index_access_sequence<MultiIndexContainer,N+1>(p);}
53};
54
55template<typename MultiIndexContainer,int N>
56struct index_access_sequence_base:
57 mpl::if_c<
58 N<mpl::size<typename MultiIndexContainer::index_type_list>::type::value,
59 index_access_sequence_normal<MultiIndexContainer,N>,
60 index_access_sequence_terminal
61 >
62{};
63
64template<typename MultiIndexContainer,int N>
65struct index_access_sequence:
66 index_access_sequence_base<MultiIndexContainer,N>::type
67{
68 typedef typename index_access_sequence_base<
69 MultiIndexContainer,N>::type super;
70
71 index_access_sequence(MultiIndexContainer* p):super(p){}
72};
73
74} /* namespace multi_index::detail */
75
76} /* namespace multi_index */
77
78} /* namespace boost */
79
80#endif
81