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