1.1 --- a/epoc32/include/stdapis/boost/array.hpp Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/boost/array.hpp Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,27 +1,321 @@
1.4 -# /* **************************************************************************
1.5 -# * *
1.6 -# * (C) Copyright Paul Mensonides 2002.
1.7 -# * Distributed under the Boost Software License, Version 1.0. (See
1.8 -# * accompanying file LICENSE_1_0.txt or copy at
1.9 -# * http://www.boost.org/LICENSE_1_0.txt)
1.10 -# * *
1.11 -# ************************************************************************** */
1.12 -#
1.13 -# /* See http://www.boost.org for most recent version. */
1.14 -#
1.15 -# ifndef BOOST_PREPROCESSOR_ARRAY_HPP
1.16 -# define BOOST_PREPROCESSOR_ARRAY_HPP
1.17 -#
1.18 -# include <boost/preprocessor/array/data.hpp>
1.19 -# include <boost/preprocessor/array/elem.hpp>
1.20 -# include <boost/preprocessor/array/insert.hpp>
1.21 -# include <boost/preprocessor/array/pop_back.hpp>
1.22 -# include <boost/preprocessor/array/pop_front.hpp>
1.23 -# include <boost/preprocessor/array/push_back.hpp>
1.24 -# include <boost/preprocessor/array/push_front.hpp>
1.25 -# include <boost/preprocessor/array/remove.hpp>
1.26 -# include <boost/preprocessor/array/replace.hpp>
1.27 -# include <boost/preprocessor/array/reverse.hpp>
1.28 -# include <boost/preprocessor/array/size.hpp>
1.29 -#
1.30 -# endif
1.31 +/* The following code declares class array,
1.32 + * an STL container (as wrapper) for arrays of constant size.
1.33 + *
1.34 + * See
1.35 + * http://www.boost.org/libs/array/
1.36 + * for documentation.
1.37 + *
1.38 + * The original author site is at: http://www.josuttis.com/
1.39 + *
1.40 + * (C) Copyright Nicolai M. Josuttis 2001.
1.41 + *
1.42 + * Distributed under the Boost Software License, Version 1.0. (See
1.43 + * accompanying file LICENSE_1_0.txt or copy at
1.44 + * http://www.boost.org/LICENSE_1_0.txt)
1.45 + *
1.46 + * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis)
1.47 + * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries.
1.48 + * 05 Aug 2001 - minor update (Nico Josuttis)
1.49 + * 20 Jan 2001 - STLport fix (Beman Dawes)
1.50 + * 29 Sep 2000 - Initial Revision (Nico Josuttis)
1.51 + *
1.52 + * Jan 29, 2004
1.53 + */
1.54 +#ifndef BOOST_ARRAY_HPP
1.55 +#define BOOST_ARRAY_HPP
1.56 +
1.57 +#include <cstddef>
1.58 +#include <stdexcept>
1.59 +#include <boost/assert.hpp>
1.60 +
1.61 +// Handles broken standard libraries better than <iterator>
1.62 +#include <boost/detail/iterator.hpp>
1.63 +#include <boost/throw_exception.hpp>
1.64 +#include <algorithm>
1.65 +
1.66 +// FIXES for broken compilers
1.67 +#include <boost/config.hpp>
1.68 +
1.69 +
1.70 +namespace boost {
1.71 +
1.72 + template<class T, std::size_t N>
1.73 + class array {
1.74 + public:
1.75 + T elems[N]; // fixed-size array of elements of type T
1.76 +
1.77 + public:
1.78 + // type definitions
1.79 + typedef T value_type;
1.80 + typedef T* iterator;
1.81 + typedef const T* const_iterator;
1.82 + typedef T& reference;
1.83 + typedef const T& const_reference;
1.84 + typedef std::size_t size_type;
1.85 + typedef std::ptrdiff_t difference_type;
1.86 +
1.87 + // iterator support
1.88 + iterator begin() { return elems; }
1.89 + const_iterator begin() const { return elems; }
1.90 + iterator end() { return elems+N; }
1.91 + const_iterator end() const { return elems+N; }
1.92 +
1.93 + // reverse iterator support
1.94 +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
1.95 + typedef std::reverse_iterator<iterator> reverse_iterator;
1.96 + typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
1.97 +#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
1.98 + // workaround for broken reverse_iterator in VC7
1.99 + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
1.100 + reference, iterator, reference> > reverse_iterator;
1.101 + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
1.102 + const_reference, iterator, reference> > const_reverse_iterator;
1.103 +#else
1.104 + // workaround for broken reverse_iterator implementations
1.105 + typedef std::reverse_iterator<iterator,T> reverse_iterator;
1.106 + typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
1.107 +#endif
1.108 +
1.109 + reverse_iterator rbegin() { return reverse_iterator(end()); }
1.110 + const_reverse_iterator rbegin() const {
1.111 + return const_reverse_iterator(end());
1.112 + }
1.113 + reverse_iterator rend() { return reverse_iterator(begin()); }
1.114 + const_reverse_iterator rend() const {
1.115 + return const_reverse_iterator(begin());
1.116 + }
1.117 +
1.118 + // operator[]
1.119 + reference operator[](size_type i)
1.120 + {
1.121 + BOOST_ASSERT( i < N && "out of range" );
1.122 + return elems[i];
1.123 + }
1.124 +
1.125 + const_reference operator[](size_type i) const
1.126 + {
1.127 + BOOST_ASSERT( i < N && "out of range" );
1.128 + return elems[i];
1.129 + }
1.130 +
1.131 + // at() with range check
1.132 + reference at(size_type i) { rangecheck(i); return elems[i]; }
1.133 + const_reference at(size_type i) const { rangecheck(i); return elems[i]; }
1.134 +
1.135 + // front() and back()
1.136 + reference front()
1.137 + {
1.138 + return elems[0];
1.139 + }
1.140 +
1.141 + const_reference front() const
1.142 + {
1.143 + return elems[0];
1.144 + }
1.145 +
1.146 + reference back()
1.147 + {
1.148 + return elems[N-1];
1.149 + }
1.150 +
1.151 + const_reference back() const
1.152 + {
1.153 + return elems[N-1];
1.154 + }
1.155 +
1.156 + // size is constant
1.157 + static size_type size() { return N; }
1.158 + static bool empty() { return false; }
1.159 + static size_type max_size() { return N; }
1.160 + enum { static_size = N };
1.161 +
1.162 + // swap (note: linear complexity)
1.163 + void swap (array<T,N>& y) {
1.164 + std::swap_ranges(begin(),end(),y.begin());
1.165 + }
1.166 +
1.167 + // direct access to data (read-only)
1.168 + const T* data() const { return elems; }
1.169 + T* data() { return elems; }
1.170 +
1.171 + // use array as C array (direct read/write access to data)
1.172 + T* c_array() { return elems; }
1.173 +
1.174 + // assignment with type conversion
1.175 + template <typename T2>
1.176 + array<T,N>& operator= (const array<T2,N>& rhs) {
1.177 + std::copy(rhs.begin(),rhs.end(), begin());
1.178 + return *this;
1.179 + }
1.180 +
1.181 + // assign one value to all elements
1.182 + void assign (const T& value)
1.183 + {
1.184 + std::fill_n(begin(),size(),value);
1.185 + }
1.186 +
1.187 + // check range (may be private because it is static)
1.188 + static void rangecheck (size_type i) {
1.189 + if (i >= size()) {
1.190 + throw std::range_error("array<>: index out of range");
1.191 + }
1.192 + }
1.193 +
1.194 + };
1.195 +
1.196 +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
1.197 + template< class T >
1.198 + class array< T, 0 > {
1.199 +
1.200 + public:
1.201 + // type definitions
1.202 + typedef T value_type;
1.203 + typedef T* iterator;
1.204 + typedef const T* const_iterator;
1.205 + typedef T& reference;
1.206 + typedef const T& const_reference;
1.207 + typedef std::size_t size_type;
1.208 + typedef std::ptrdiff_t difference_type;
1.209 +
1.210 + // iterator support
1.211 + iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); }
1.212 + const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
1.213 + iterator end() { return begin(); }
1.214 + const_iterator end() const { return begin(); }
1.215 +
1.216 + // reverse iterator support
1.217 +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
1.218 + typedef std::reverse_iterator<iterator> reverse_iterator;
1.219 + typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
1.220 +#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
1.221 + // workaround for broken reverse_iterator in VC7
1.222 + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
1.223 + reference, iterator, reference> > reverse_iterator;
1.224 + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
1.225 + const_reference, iterator, reference> > const_reverse_iterator;
1.226 +#else
1.227 + // workaround for broken reverse_iterator implementations
1.228 + typedef std::reverse_iterator<iterator,T> reverse_iterator;
1.229 + typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
1.230 +#endif
1.231 +
1.232 + reverse_iterator rbegin() { return reverse_iterator(end()); }
1.233 + const_reverse_iterator rbegin() const {
1.234 + return const_reverse_iterator(end());
1.235 + }
1.236 + reverse_iterator rend() { return reverse_iterator(begin()); }
1.237 + const_reverse_iterator rend() const {
1.238 + return const_reverse_iterator(begin());
1.239 + }
1.240 +
1.241 + // operator[]
1.242 + reference operator[](size_type i)
1.243 + {
1.244 + return failed_rangecheck();
1.245 + }
1.246 +
1.247 + const_reference operator[](size_type i) const
1.248 + {
1.249 + return failed_rangecheck();
1.250 + }
1.251 +
1.252 + // at() with range check
1.253 + reference at(size_type i) { return failed_rangecheck(); }
1.254 + const_reference at(size_type i) const { return failed_rangecheck(); }
1.255 +
1.256 + // front() and back()
1.257 + reference front()
1.258 + {
1.259 + return failed_rangecheck();
1.260 + }
1.261 +
1.262 + const_reference front() const
1.263 + {
1.264 + return failed_rangecheck();
1.265 + }
1.266 +
1.267 + reference back()
1.268 + {
1.269 + return failed_rangecheck();
1.270 + }
1.271 +
1.272 + const_reference back() const
1.273 + {
1.274 + return failed_rangecheck();
1.275 + }
1.276 +
1.277 + // size is constant
1.278 + static size_type size() { return 0; }
1.279 + static bool empty() { return true; }
1.280 + static size_type max_size() { return 0; }
1.281 + enum { static_size = 0 };
1.282 +
1.283 + void swap (array<T,0>& y) {
1.284 + }
1.285 +
1.286 + // direct access to data (read-only)
1.287 + const T* data() const { return 0; }
1.288 + T* data() { return 0; }
1.289 +
1.290 + // use array as C array (direct read/write access to data)
1.291 + T* c_array() { return 0; }
1.292 +
1.293 + // assignment with type conversion
1.294 + template <typename T2>
1.295 + array<T,0>& operator= (const array<T2,0>& ) {
1.296 + return *this;
1.297 + }
1.298 +
1.299 + // assign one value to all elements
1.300 + void assign (const T& ) { }
1.301 +
1.302 + // check range (may be private because it is static)
1.303 + static reference failed_rangecheck () {
1.304 + std::range_error e("attempt to access element of an empty array");
1.305 + boost::throw_exception(e);
1.306 + //
1.307 + // We need to return something here to keep
1.308 + // some compilers happy: however we will never
1.309 + // actually get here....
1.310 + //
1.311 + static T placeholder;
1.312 + return placeholder;
1.313 + }
1.314 + };
1.315 +#endif
1.316 +
1.317 + // comparisons
1.318 + template<class T, std::size_t N>
1.319 + bool operator== (const array<T,N>& x, const array<T,N>& y) {
1.320 + return std::equal(x.begin(), x.end(), y.begin());
1.321 + }
1.322 + template<class T, std::size_t N>
1.323 + bool operator< (const array<T,N>& x, const array<T,N>& y) {
1.324 + return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
1.325 + }
1.326 + template<class T, std::size_t N>
1.327 + bool operator!= (const array<T,N>& x, const array<T,N>& y) {
1.328 + return !(x==y);
1.329 + }
1.330 + template<class T, std::size_t N>
1.331 + bool operator> (const array<T,N>& x, const array<T,N>& y) {
1.332 + return y<x;
1.333 + }
1.334 + template<class T, std::size_t N>
1.335 + bool operator<= (const array<T,N>& x, const array<T,N>& y) {
1.336 + return !(y<x);
1.337 + }
1.338 + template<class T, std::size_t N>
1.339 + bool operator>= (const array<T,N>& x, const array<T,N>& y) {
1.340 + return !(x<y);
1.341 + }
1.342 +
1.343 + // global swap()
1.344 + template<class T, std::size_t N>
1.345 + inline void swap (array<T,N>& x, array<T,N>& y) {
1.346 + x.swap(y);
1.347 + }
1.348 +
1.349 +} /* namespace boost */
1.350 +
1.351 +#endif /*BOOST_ARRAY_HPP*/