Chris@16
|
1
|
Chris@16
|
2 #ifndef BOOST_MPL_VECTOR_AUX_AT_HPP_INCLUDED
|
Chris@16
|
3 #define BOOST_MPL_VECTOR_AUX_AT_HPP_INCLUDED
|
Chris@16
|
4
|
Chris@16
|
5 // Copyright Aleksey Gurtovoy 2000-2004
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
8 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
9 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
10 //
|
Chris@16
|
11 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
12
|
Chris@101
|
13 // $Id$
|
Chris@101
|
14 // $Date$
|
Chris@101
|
15 // $Revision$
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/mpl/at_fwd.hpp>
|
Chris@16
|
18 #include <boost/mpl/vector/aux_/tag.hpp>
|
Chris@16
|
19 #include <boost/mpl/long.hpp>
|
Chris@16
|
20 #include <boost/mpl/void.hpp>
|
Chris@16
|
21 #include <boost/mpl/aux_/nttp_decl.hpp>
|
Chris@16
|
22 #include <boost/mpl/aux_/type_wrapper.hpp>
|
Chris@16
|
23 #include <boost/mpl/aux_/value_wknd.hpp>
|
Chris@16
|
24 #include <boost/mpl/aux_/config/typeof.hpp>
|
Chris@16
|
25 #include <boost/mpl/aux_/config/ctps.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 namespace boost { namespace mpl {
|
Chris@16
|
28
|
Chris@16
|
29 #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
|
Chris@16
|
30
|
Chris@16
|
31 template< typename Vector, long n_ >
|
Chris@16
|
32 struct v_at_impl
|
Chris@16
|
33 {
|
Chris@16
|
34 typedef long_< (Vector::lower_bound_::value + n_) > index_;
|
Chris@16
|
35 typedef __typeof__( Vector::item_(index_()) ) type;
|
Chris@16
|
36 };
|
Chris@16
|
37
|
Chris@16
|
38
|
Chris@16
|
39 template< typename Vector, long n_ >
|
Chris@16
|
40 struct v_at
|
Chris@16
|
41 : aux::wrapped_type< typename v_at_impl<Vector,n_>::type >
|
Chris@16
|
42 {
|
Chris@16
|
43 };
|
Chris@16
|
44
|
Chris@16
|
45 template<>
|
Chris@16
|
46 struct at_impl< aux::vector_tag >
|
Chris@16
|
47 {
|
Chris@16
|
48 template< typename Vector, typename N > struct apply
|
Chris@16
|
49 : v_at<
|
Chris@16
|
50 Vector
|
Chris@16
|
51 , BOOST_MPL_AUX_VALUE_WKND(N)::value
|
Chris@16
|
52 >
|
Chris@16
|
53 {
|
Chris@16
|
54 };
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57 #else
|
Chris@16
|
58
|
Chris@16
|
59 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
Chris@16
|
60 && !defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
|
Chris@16
|
61
|
Chris@16
|
62 template< typename Vector, BOOST_MPL_AUX_NTTP_DECL(long, n_) > struct v_at;
|
Chris@16
|
63
|
Chris@16
|
64 template< BOOST_MPL_AUX_NTTP_DECL(long, n_) >
|
Chris@16
|
65 struct at_impl< aux::vector_tag<n_> >
|
Chris@16
|
66 {
|
Chris@16
|
67 template< typename Vector, typename N > struct apply
|
Chris@16
|
68 #if !defined(__BORLANDC__)
|
Chris@16
|
69 : v_at<
|
Chris@16
|
70 Vector
|
Chris@16
|
71 , BOOST_MPL_AUX_VALUE_WKND(N)::value
|
Chris@16
|
72 >
|
Chris@16
|
73 {
|
Chris@16
|
74 #else
|
Chris@16
|
75 {
|
Chris@16
|
76 typedef typename v_at<
|
Chris@16
|
77 Vector
|
Chris@16
|
78 , BOOST_MPL_AUX_VALUE_WKND(N)::value
|
Chris@16
|
79 >::type type;
|
Chris@16
|
80 #endif
|
Chris@16
|
81 };
|
Chris@16
|
82 };
|
Chris@16
|
83
|
Chris@16
|
84 # else
|
Chris@16
|
85
|
Chris@16
|
86 namespace aux {
|
Chris@16
|
87
|
Chris@16
|
88 template< BOOST_MPL_AUX_NTTP_DECL(long, n_) > struct v_at_impl
|
Chris@16
|
89 {
|
Chris@16
|
90 template< typename V > struct result_;
|
Chris@16
|
91 };
|
Chris@16
|
92
|
Chris@16
|
93 // to work around ETI, etc.
|
Chris@16
|
94 template<> struct v_at_impl<-1>
|
Chris@16
|
95 {
|
Chris@16
|
96 template< typename V > struct result_
|
Chris@16
|
97 {
|
Chris@16
|
98 typedef void_ type;
|
Chris@16
|
99 };
|
Chris@16
|
100 };
|
Chris@16
|
101
|
Chris@16
|
102 } // namespace aux
|
Chris@16
|
103
|
Chris@16
|
104 template< typename T, BOOST_MPL_AUX_NTTP_DECL(long, n_) >
|
Chris@16
|
105 struct v_at
|
Chris@16
|
106 : aux::v_at_impl<n_>::template result_<T>
|
Chris@16
|
107 {
|
Chris@16
|
108 };
|
Chris@16
|
109
|
Chris@16
|
110 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
111
|
Chris@16
|
112 #endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
|
Chris@16
|
113
|
Chris@16
|
114 }}
|
Chris@16
|
115
|
Chris@16
|
116 #endif // BOOST_MPL_VECTOR_AUX_AT_HPP_INCLUDED
|