Chris@16
|
1 // (C) Copyright John Maddock 2005.
|
Chris@16
|
2 // Use, modification and distribution are subject to the
|
Chris@16
|
3 // Boost Software License, Version 1.0. (See accompanying file
|
Chris@16
|
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_TR1_ARRAY_HPP_INCLUDED
|
Chris@16
|
7 # define BOOST_TR1_ARRAY_HPP_INCLUDED
|
Chris@16
|
8 # include <boost/tr1/detail/config.hpp>
|
Chris@16
|
9
|
Chris@16
|
10 #ifdef BOOST_HAS_TR1_ARRAY
|
Chris@16
|
11
|
Chris@16
|
12 # if defined(BOOST_HAS_INCLUDE_NEXT) && !defined(BOOST_TR1_DISABLE_INCLUDE_NEXT)
|
Chris@16
|
13 # include_next BOOST_TR1_HEADER(array)
|
Chris@16
|
14 # else
|
Chris@16
|
15 # include <boost/tr1/detail/config_all.hpp>
|
Chris@16
|
16 # include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(array))
|
Chris@16
|
17 # endif
|
Chris@16
|
18
|
Chris@16
|
19 #else
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/array.hpp>
|
Chris@16
|
22 #include <boost/static_assert.hpp>
|
Chris@16
|
23 #include <boost/type_traits/integral_constant.hpp>
|
Chris@16
|
24 #include <boost/detail/workaround.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 namespace std{ namespace tr1{
|
Chris@16
|
27
|
Chris@16
|
28 using ::boost::array;
|
Chris@16
|
29
|
Chris@16
|
30 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
|
Chris@16
|
31 // [6.1.3.2] Tuple creation functions
|
Chris@16
|
32 using ::boost::swap;
|
Chris@16
|
33 #endif
|
Chris@16
|
34
|
Chris@16
|
35 #if !defined(BOOST_TR1_USE_OLD_TUPLE)
|
Chris@16
|
36 }} namespace boost{ namespace fusion{
|
Chris@16
|
37 #endif
|
Chris@16
|
38
|
Chris@16
|
39 // [6.2.2.5] Tuple interface to class template array
|
Chris@16
|
40 template <class T> struct tuple_size; // forward declaration
|
Chris@16
|
41 template <int I, class T> struct tuple_element; // forward declaration
|
Chris@16
|
42 template <class T, size_t N>
|
Chris@16
|
43 struct tuple_size< ::boost::array<T, N> >
|
Chris@16
|
44 : public ::boost::integral_constant< ::std::size_t, N>{};
|
Chris@16
|
45
|
Chris@16
|
46
|
Chris@16
|
47 template <int I, class T, size_t N>
|
Chris@16
|
48 struct tuple_element<I, ::boost::array<T, N> >
|
Chris@16
|
49 {
|
Chris@16
|
50 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570))
|
Chris@16
|
51 BOOST_STATIC_ASSERT(I < (int)N);
|
Chris@16
|
52 BOOST_STATIC_ASSERT(I >= 0);
|
Chris@16
|
53 #endif
|
Chris@16
|
54 typedef T type;
|
Chris@16
|
55 };
|
Chris@16
|
56 template <int I, class T, size_t N>
|
Chris@16
|
57 T& get( ::boost::array<T, N>& a)
|
Chris@16
|
58 {
|
Chris@16
|
59 BOOST_STATIC_ASSERT(I < N);
|
Chris@16
|
60 BOOST_STATIC_ASSERT(I >= 0);
|
Chris@16
|
61 return a[I];
|
Chris@16
|
62 }
|
Chris@16
|
63
|
Chris@16
|
64 template <int I, class T, size_t N>
|
Chris@16
|
65 const T& get(const array<T, N>& a)
|
Chris@16
|
66 {
|
Chris@16
|
67 BOOST_STATIC_ASSERT(I < N);
|
Chris@16
|
68 BOOST_STATIC_ASSERT(I >= 0);
|
Chris@16
|
69 return a[I];
|
Chris@16
|
70 }
|
Chris@16
|
71
|
Chris@16
|
72 #if !defined(BOOST_TR1_USE_OLD_TUPLE)
|
Chris@16
|
73 }} namespace std{ namespace tr1{
|
Chris@16
|
74
|
Chris@16
|
75 using ::boost::fusion::tuple_size;
|
Chris@16
|
76 using ::boost::fusion::tuple_element;
|
Chris@16
|
77 using ::boost::fusion::get;
|
Chris@16
|
78
|
Chris@16
|
79 #endif
|
Chris@16
|
80
|
Chris@16
|
81
|
Chris@16
|
82 } } // namespaces
|
Chris@16
|
83
|
Chris@16
|
84 #endif
|
Chris@16
|
85
|
Chris@16
|
86 #endif
|