Chris@16
|
1 /* Copyright 2003-2008 Joaquin M Lopez Munoz.
|
Chris@16
|
2 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
3 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5 *
|
Chris@16
|
6 * See http://www.boost.org/libs/multi_index for library home page.
|
Chris@16
|
7 */
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef BOOST_MULTI_INDEX_DETAIL_UNBOUNDED_HPP
|
Chris@16
|
10 #define BOOST_MULTI_INDEX_DETAIL_UNBOUNDED_HPP
|
Chris@16
|
11
|
Chris@16
|
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
|
Chris@16
|
13 #pragma once
|
Chris@16
|
14 #endif
|
Chris@16
|
15
|
Chris@16
|
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
|
Chris@16
|
17 #include <boost/detail/workaround.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 namespace boost{
|
Chris@16
|
20
|
Chris@16
|
21 namespace multi_index{
|
Chris@16
|
22
|
Chris@16
|
23 /* dummy type and variable for use in ordered_index::range() */
|
Chris@16
|
24
|
Chris@16
|
25 #if BOOST_WORKAROUND(BOOST_MSVC,<1300)
|
Chris@16
|
26 /* The default branch actually works for MSVC 6.0, but seems like
|
Chris@16
|
27 * this implementation of unbounded improves the performance of ordered
|
Chris@16
|
28 * indices! This behavior is hard to explain and probably a test artifact,
|
Chris@16
|
29 * but it does not hurt to have the workaround anyway.
|
Chris@16
|
30 */
|
Chris@16
|
31
|
Chris@16
|
32 namespace detail{struct unbounded_type{};}
|
Chris@16
|
33
|
Chris@16
|
34 namespace{
|
Chris@16
|
35
|
Chris@16
|
36 static detail::unbounded_type unbounded_obj=detail::unbounded_type();
|
Chris@16
|
37 static detail::unbounded_type& unbounded=unbounded_obj;
|
Chris@16
|
38
|
Chris@16
|
39 } /* unnamed */
|
Chris@16
|
40 #else
|
Chris@16
|
41 /* ODR-abiding technique shown at the example attached to
|
Chris@16
|
42 * http://lists.boost.org/Archives/boost/2006/07/108355.php
|
Chris@16
|
43 */
|
Chris@16
|
44
|
Chris@16
|
45 namespace detail{class unbounded_helper;}
|
Chris@16
|
46
|
Chris@16
|
47 detail::unbounded_helper unbounded(detail::unbounded_helper);
|
Chris@16
|
48
|
Chris@16
|
49 namespace detail{
|
Chris@16
|
50
|
Chris@16
|
51 class unbounded_helper
|
Chris@16
|
52 {
|
Chris@16
|
53 unbounded_helper(){}
|
Chris@16
|
54 unbounded_helper(const unbounded_helper&){}
|
Chris@16
|
55 friend unbounded_helper multi_index::unbounded(unbounded_helper);
|
Chris@16
|
56 };
|
Chris@16
|
57
|
Chris@16
|
58 typedef unbounded_helper (*unbounded_type)(unbounded_helper);
|
Chris@16
|
59
|
Chris@16
|
60 } /* namespace multi_index::detail */
|
Chris@16
|
61
|
Chris@16
|
62 inline detail::unbounded_helper unbounded(detail::unbounded_helper)
|
Chris@16
|
63 {
|
Chris@16
|
64 return detail::unbounded_helper();
|
Chris@16
|
65 }
|
Chris@16
|
66 #endif
|
Chris@16
|
67
|
Chris@16
|
68 /* tags used in the implementation of range */
|
Chris@16
|
69
|
Chris@16
|
70 namespace detail{
|
Chris@16
|
71
|
Chris@16
|
72 struct none_unbounded_tag{};
|
Chris@16
|
73 struct lower_unbounded_tag{};
|
Chris@16
|
74 struct upper_unbounded_tag{};
|
Chris@16
|
75 struct both_unbounded_tag{};
|
Chris@16
|
76
|
Chris@16
|
77 } /* namespace multi_index::detail */
|
Chris@16
|
78
|
Chris@16
|
79 } /* namespace multi_index */
|
Chris@16
|
80
|
Chris@16
|
81 } /* namespace boost */
|
Chris@16
|
82
|
Chris@16
|
83 #endif
|