1 |
|
---|
2 | #ifndef BOOST_MPL_MULTISET_AUX_ITEM_HPP_INCLUDED
|
---|
3 | #define BOOST_MPL_MULTISET_AUX_ITEM_HPP_INCLUDED
|
---|
4 |
|
---|
5 | // Copyright Aleksey Gurtovoy 2003-2004
|
---|
6 | //
|
---|
7 | // Distributed under the Boost Software License, Version 1.0.
|
---|
8 | // (See accompanying file LICENSE_1_0.txt or copy at
|
---|
9 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
10 | //
|
---|
11 | // See http://www.boost.org/libs/mpl for documentation.
|
---|
12 |
|
---|
13 | // $Source: /cvsroot/boost/boost/boost/mpl/multiset/aux_/item.hpp,v $
|
---|
14 | // $Date: 2004/09/02 15:41:02 $
|
---|
15 | // $Revision: 1.2 $
|
---|
16 |
|
---|
17 | #include <boost/mpl/multiset/aux_/tag.hpp>
|
---|
18 | #include <boost/mpl/int.hpp>
|
---|
19 | #include <boost/mpl/aux_/type_wrapper.hpp>
|
---|
20 | #include <boost/mpl/aux_/yes_no.hpp>
|
---|
21 | #include <boost/mpl/aux_/value_wknd.hpp>
|
---|
22 | #include <boost/mpl/aux_/static_cast.hpp>
|
---|
23 | #include <boost/mpl/aux_/config/arrays.hpp>
|
---|
24 | #include <boost/mpl/aux_/config/msvc.hpp>
|
---|
25 | #include <boost/mpl/aux_/config/workaround.hpp>
|
---|
26 |
|
---|
27 | #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
---|
28 | # include <boost/mpl/eval_if.hpp>
|
---|
29 | # include <boost/mpl/next.hpp>
|
---|
30 | # include <boost/type_traits/is_same.hpp>
|
---|
31 | #endif
|
---|
32 |
|
---|
33 |
|
---|
34 | namespace boost { namespace mpl {
|
---|
35 |
|
---|
36 | #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
---|
37 |
|
---|
38 | template< typename T, typename Base >
|
---|
39 | struct ms_item
|
---|
40 | {
|
---|
41 | typedef aux::multiset_tag tag;
|
---|
42 |
|
---|
43 | template< typename U > struct prior_count
|
---|
44 | {
|
---|
45 | enum { msvc70_wknd_ = sizeof(Base::key_count(BOOST_MPL_AUX_STATIC_CAST(U*,0))) };
|
---|
46 | typedef int_< msvc70_wknd_ > count_;
|
---|
47 | typedef typename eval_if< is_same<T,U>, next<count_>, count_ >::type c_;
|
---|
48 | #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
|
---|
49 | typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(c_)::value>::type type;
|
---|
50 | #else
|
---|
51 | typedef char (&type)[BOOST_MPL_AUX_MSVC_VALUE_WKND(c_)::value];
|
---|
52 | #endif
|
---|
53 | };
|
---|
54 |
|
---|
55 | template< typename U > struct prior_ref_count
|
---|
56 | {
|
---|
57 | typedef U (* u_)();
|
---|
58 | enum { msvc70_wknd_ = sizeof(Base::ref_key_count(BOOST_MPL_AUX_STATIC_CAST(u_,0))) };
|
---|
59 | typedef int_< msvc70_wknd_ > count_;
|
---|
60 | typedef typename eval_if< is_same<T,U>, next<count_>, count_ >::type c_;
|
---|
61 | #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
|
---|
62 | typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(c_)::value>::type type;
|
---|
63 | #else
|
---|
64 | typedef char (&type)[BOOST_MPL_AUX_MSVC_VALUE_WKND(c_)::value];
|
---|
65 | #endif
|
---|
66 | };
|
---|
67 |
|
---|
68 | template< typename U >
|
---|
69 | static typename prior_count<U>::type key_count(U*);
|
---|
70 |
|
---|
71 | template< typename U >
|
---|
72 | static typename prior_ref_count<U>::type ref_key_count(U (*)());
|
---|
73 | };
|
---|
74 |
|
---|
75 | #else // BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
---|
76 |
|
---|
77 | namespace aux {
|
---|
78 | template< typename U, typename Base >
|
---|
79 | struct prior_key_count
|
---|
80 | {
|
---|
81 | enum { msvc71_wknd_ = sizeof(Base::key_count(BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<U>*,0))) };
|
---|
82 | typedef int_< msvc71_wknd_ > count_;
|
---|
83 | #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
|
---|
84 | typedef typename aux::weighted_tag< BOOST_MPL_AUX_VALUE_WKND(count_)::value >::type type;
|
---|
85 | #else
|
---|
86 | typedef char (&type)[count_::value];
|
---|
87 | #endif
|
---|
88 | };
|
---|
89 | }
|
---|
90 |
|
---|
91 | template< typename T, typename Base >
|
---|
92 | struct ms_item
|
---|
93 | {
|
---|
94 | typedef aux::multiset_tag tag;
|
---|
95 |
|
---|
96 | enum { msvc71_wknd_ = sizeof(Base::key_count(BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<T>*,0))) + 1 };
|
---|
97 | typedef int_< msvc71_wknd_ > count_;
|
---|
98 | #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
|
---|
99 | static
|
---|
100 | typename aux::weighted_tag< BOOST_MPL_AUX_VALUE_WKND(count_)::value >::type
|
---|
101 | key_count(aux::type_wrapper<T>*);
|
---|
102 | #else
|
---|
103 | static char (& key_count(aux::type_wrapper<T>*) )[count_::value];
|
---|
104 | #endif
|
---|
105 |
|
---|
106 | template< typename U >
|
---|
107 | static typename aux::prior_key_count<U,Base>::type key_count(aux::type_wrapper<U>*);
|
---|
108 | };
|
---|
109 |
|
---|
110 | #endif // BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
---|
111 |
|
---|
112 | }}
|
---|
113 |
|
---|
114 | #endif // BOOST_MPL_MULTISET_AUX_ITEM_HPP_INCLUDED
|
---|