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

Revision 857, 2.2 KB checked in by igarcia, 19 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_INDEX_PROXY_HPP
10#define BOOST_MULTI_INDEX_DETAIL_INDEX_PROXY_HPP
11
12#if defined(_MSC_VER)&&(_MSC_VER>=1200)
13#pragma once
14#endif
15
16#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
17#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
18#include <boost/detail/workaround.hpp>
19
20#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
21#include <algorithm>
22#include <boost/multi_index/detail/index_iterator_fwd.hpp>
23#include <boost/multi_index/detail/safe_mode.hpp>
24
25namespace boost{
26
27namespace multi_index{
28
29namespace detail{
30
31/* In safe mode, index iterators are derived from safe_iterator<Index>,
32 * where Index is the type of the index where the iterator belongs. Due
33 * to the long symbol names of indices, MSVC++ 6.0 often issues a
34 * LNK1179 (duplicate comdat) error. To workaround this problem,
35 * index_proxy is used instead. index_proxy<Node> acts as an index
36 * over nodes of type Node in all aspects relevant to safe_iterator, and
37 * its shorter symbol name makes life easier for MSVC++ 6.0.
38 */
39
40template<typename Node>
41class index_proxy:public safe_container<index_proxy<Node> >
42{
43protected:
44  index_proxy(Node* header_):header(header_){}
45
46  void swap(index_proxy<Node>& x)
47  {
48    std::swap(header,x.header);
49    safe_container<index_proxy<Node> >::swap(x);
50  }
51
52public:
53  typedef index_iterator<Node> iterator;
54  typedef index_iterator<Node> const_iterator;
55
56  index_iterator<Node> begin()const
57  {
58    return index_iterator<Node>(
59      Node::begin(header),const_cast<index_proxy*>(this));
60  }
61
62  index_iterator<Node> end()const
63  {
64    return index_iterator<Node>(
65      Node::end(header),const_cast<index_proxy*>(this));
66  }
67
68private:
69  Node* header;
70};
71
72} /* namespace multi_index::detail */
73
74} /* namespace multi_index */
75
76} /* namespace boost */
77
78#endif /* workaround */
79
80#endif /* BOOST_MULTI_INDEX_ENABLE_SAFE_MODE */
81
82#endif
Note: See TracBrowser for help on using the repository browser.