| 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 | #  include BOOST_TR1_HEADER(array) | 
|---|
| 13 |  | 
|---|
| 14 | #else | 
|---|
| 15 |  | 
|---|
| 16 | #include <boost/array.hpp> | 
|---|
| 17 | #include <boost/static_assert.hpp> | 
|---|
| 18 | #include <boost/type_traits/integral_constant.hpp> | 
|---|
| 19 | #include <boost/detail/workaround.hpp> | 
|---|
| 20 |  | 
|---|
| 21 | namespace std{ namespace tr1{ | 
|---|
| 22 |  | 
|---|
| 23 | using ::boost::array; | 
|---|
| 24 |  | 
|---|
| 25 | #if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582) | 
|---|
| 26 | // [6.1.3.2] Tuple creation functions | 
|---|
| 27 | using ::boost::swap; | 
|---|
| 28 | #endif | 
|---|
| 29 |  | 
|---|
| 30 | #if !defined(BOOST_TR1_USE_OLD_TUPLE) | 
|---|
| 31 | }} namespace boost{ namespace fusion{ | 
|---|
| 32 | #endif | 
|---|
| 33 |  | 
|---|
| 34 | // [6.2.2.5] Tuple interface to class template array | 
|---|
| 35 | template <class T> struct tuple_size; // forward declaration | 
|---|
| 36 | template <int I, class T> struct tuple_element; // forward declaration | 
|---|
| 37 | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | 
|---|
| 38 | template <class T, size_t N> | 
|---|
| 39 | struct tuple_size< ::boost::array<T, N> > | 
|---|
| 40 |    : public ::boost::integral_constant< ::std::size_t, N>{}; | 
|---|
| 41 |  | 
|---|
| 42 |  | 
|---|
| 43 | template <int I, class T, size_t N> | 
|---|
| 44 | struct tuple_element<I, ::boost::array<T, N> > | 
|---|
| 45 | { | 
|---|
| 46 | #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) | 
|---|
| 47 |    BOOST_STATIC_ASSERT(I < (int)N); | 
|---|
| 48 |    BOOST_STATIC_ASSERT(I >= 0); | 
|---|
| 49 | #endif | 
|---|
| 50 |    typedef T type; | 
|---|
| 51 | }; | 
|---|
| 52 | #endif | 
|---|
| 53 | template <int I, class T, size_t N> | 
|---|
| 54 | T& get( ::boost::array<T, N>& a) | 
|---|
| 55 | { | 
|---|
| 56 |    BOOST_STATIC_ASSERT(I < N); | 
|---|
| 57 |    BOOST_STATIC_ASSERT(I >= 0); | 
|---|
| 58 |    return a[I]; | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | template <int I, class T, size_t N> | 
|---|
| 62 | const T& get(const array<T, N>& a) | 
|---|
| 63 | { | 
|---|
| 64 |    BOOST_STATIC_ASSERT(I < N); | 
|---|
| 65 |    BOOST_STATIC_ASSERT(I >= 0); | 
|---|
| 66 |    return a[I]; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | #if !defined(BOOST_TR1_USE_OLD_TUPLE) | 
|---|
| 70 | }} namespace std{ namespace tr1{ | 
|---|
| 71 |  | 
|---|
| 72 |    using ::boost::fusion::tuple_size; | 
|---|
| 73 |    using ::boost::fusion::tuple_element; | 
|---|
| 74 |    using ::boost::fusion::get; | 
|---|
| 75 |  | 
|---|
| 76 | #endif | 
|---|
| 77 |  | 
|---|
| 78 |  | 
|---|
| 79 | } } // namespaces | 
|---|
| 80 |  | 
|---|
| 81 | #endif | 
|---|
| 82 |  | 
|---|
| 83 | #endif | 
|---|