X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=boost%2Fboost%2Farray.hpp;h=ce9eda7b53362c1bfd6b4f16de5c65250f3752bb;hb=4a7ab830bce5a4d403f7229818a15b293cc533a1;hp=12621f744446bc559c16fdfbbfcbab1f37d2054a;hpb=2cd26f417aa3d57dc59ca08a150e7f7580aecb62;p=lyx.git diff --git a/boost/boost/array.hpp b/boost/boost/array.hpp index 12621f7444..ce9eda7b53 100644 --- a/boost/boost/array.hpp +++ b/boost/boost/array.hpp @@ -4,27 +4,38 @@ * See * http://www.josuttis.com/cppcode * for details and the latest version. + * See + * http://www.boost.org/libs/array for Documentation. + * for documentation. * - * (C) Copyright Nicolai M. Josuttis 1999. - * Permission to copy, use, modify, sell and distribute this software - * is granted provided this copyright notice appears in all copies. - * This software is provided "as is" without express or implied - * warranty, and with no claim as to its suitability for any purpose. + * (C) Copyright Nicolai M. Josuttis 2001. + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) * + * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis) + * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries. + * 05 Aug 2001 - minor update (Nico Josuttis) * 20 Jan 2001 - STLport fix (Beman Dawes) * 29 Sep 2000 - Initial Revision (Nico Josuttis) + * + * Jan 29, 2004 */ #ifndef BOOST_ARRAY_HPP #define BOOST_ARRAY_HPP #include #include -#include +#include + +// Handles broken standard libraries better than +#include #include // FIXES for broken compilers #include + namespace boost { template @@ -49,9 +60,15 @@ namespace boost { const_iterator end() const { return elems+N; } // reverse iterator support -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; +#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) + // workaround for broken reverse_iterator in VC7 + typedef std::reverse_iterator > reverse_iterator; + typedef std::reverse_iterator > const_reverse_iterator; #else // workaround for broken reverse_iterator implementations typedef std::reverse_iterator reverse_iterator; @@ -68,18 +85,42 @@ namespace boost { } // operator[] - reference operator[](size_type i) { return elems[i]; } - const_reference operator[](size_type i) const { return elems[i]; } + reference operator[](size_type i) + { + BOOST_ASSERT( i < N && "out of range" ); + return elems[i]; + } + + const_reference operator[](size_type i) const + { + BOOST_ASSERT( i < N && "out of range" ); + return elems[i]; + } // at() with range check reference at(size_type i) { rangecheck(i); return elems[i]; } const_reference at(size_type i) const { rangecheck(i); return elems[i]; } // front() and back() - reference front() { return elems[0]; } - const_reference front() const { return elems[0]; } - reference back() { return elems[N-1]; } - const_reference back() const { return elems[N-1]; } + reference front() + { + return elems[0]; + } + + const_reference front() const + { + return elems[0]; + } + + reference back() + { + return elems[N-1]; + } + + const_reference back() const + { + return elems[N-1]; + } // size is constant static size_type size() { return N; } @@ -92,9 +133,12 @@ namespace boost { std::swap_ranges(begin(),end(),y.begin()); } - // direct access to data + // direct access to data (read-only) const T* data() const { return elems; } + // use array as C array (direct read/write access to data) + T* c_array() { return elems; } + // assignment with type conversion template array& operator= (const array& rhs) { @@ -108,12 +152,11 @@ namespace boost { std::fill_n(begin(),size(),value); } -#ifndef BOOST_NO_PRIVATE_IN_AGGREGATE - private: -#endif // check range (may be private because it is static) static void rangecheck (size_type i) { - if (i >= size()) { throw std::range_error("array"); } + if (i >= size()) { + throw std::range_error("array<>: index out of range"); + } } };