600
|
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 |
# ifdef BOOST_HAS_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 |
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
43 |
template <class T, size_t N>
|
|
44 |
struct tuple_size< ::boost::array<T, N> >
|
|
45 |
: public ::boost::integral_constant< ::std::size_t, N>{};
|
|
46 |
|
|
47 |
|
|
48 |
template <int I, class T, size_t N>
|
|
49 |
struct tuple_element<I, ::boost::array<T, N> >
|
|
50 |
{
|
|
51 |
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570))
|
|
52 |
BOOST_STATIC_ASSERT(I < (int)N);
|
|
53 |
BOOST_STATIC_ASSERT(I >= 0);
|
|
54 |
#endif
|
|
55 |
typedef T type;
|
|
56 |
};
|
|
57 |
#endif
|
|
58 |
template <int I, class T, size_t N>
|
|
59 |
T& get( ::boost::array<T, N>& a)
|
|
60 |
{
|
|
61 |
BOOST_STATIC_ASSERT(I < N);
|
|
62 |
BOOST_STATIC_ASSERT(I >= 0);
|
|
63 |
return a[I];
|
|
64 |
}
|
|
65 |
|
|
66 |
template <int I, class T, size_t N>
|
|
67 |
const T& get(const array<T, N>& a)
|
|
68 |
{
|
|
69 |
BOOST_STATIC_ASSERT(I < N);
|
|
70 |
BOOST_STATIC_ASSERT(I >= 0);
|
|
71 |
return a[I];
|
|
72 |
}
|
|
73 |
|
|
74 |
#if !defined(BOOST_TR1_USE_OLD_TUPLE)
|
|
75 |
}} namespace std{ namespace tr1{
|
|
76 |
|
|
77 |
using ::boost::fusion::tuple_size;
|
|
78 |
using ::boost::fusion::tuple_element;
|
|
79 |
using ::boost::fusion::get;
|
|
80 |
|
|
81 |
#endif
|
|
82 |
|
|
83 |
|
|
84 |
} } // namespaces
|
|
85 |
|
|
86 |
#endif
|
|
87 |
|
|
88 |
#endif
|