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