|
|
|
@ -13,6 +13,10 @@
|
|
|
|
|
* accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
|
* http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
*
|
|
|
|
|
* 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group.
|
|
|
|
|
* See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
|
|
|
|
|
* Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow)
|
|
|
|
|
* 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow)
|
|
|
|
|
* 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)
|
|
|
|
@ -24,9 +28,19 @@
|
|
|
|
|
#ifndef BOOST_ARRAY_HPP
|
|
|
|
|
#define BOOST_ARRAY_HPP
|
|
|
|
|
|
|
|
|
|
#include <boost/detail/workaround.hpp>
|
|
|
|
|
|
|
|
|
|
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
|
|
|
|
# pragma warning(push)
|
|
|
|
|
# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe
|
|
|
|
|
# pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated
|
|
|
|
|
# pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
#include <boost/swap.hpp>
|
|
|
|
|
|
|
|
|
|
// Handles broken standard libraries better than <iterator>
|
|
|
|
|
#include <boost/detail/iterator.hpp>
|
|
|
|
@ -70,6 +84,11 @@ namespace boost {
|
|
|
|
|
reference, iterator, reference> > reverse_iterator;
|
|
|
|
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
|
|
|
|
const_reference, iterator, reference> > const_reverse_iterator;
|
|
|
|
|
#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
|
|
|
|
|
typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
|
|
|
|
|
value_type, reference, iterator, difference_type> reverse_iterator;
|
|
|
|
|
typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
|
|
|
|
|
value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
|
|
|
|
|
#else
|
|
|
|
|
// workaround for broken reverse_iterator implementations
|
|
|
|
|
typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
|
|
|
@ -131,7 +150,8 @@ namespace boost {
|
|
|
|
|
|
|
|
|
|
// swap (note: linear complexity)
|
|
|
|
|
void swap (array<T,N>& y) {
|
|
|
|
|
std::swap_ranges(begin(),end(),y.begin());
|
|
|
|
|
for (size_type i = 0; i < N; ++i)
|
|
|
|
|
boost::swap(elems[i],y.elems[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// direct access to data (read-only)
|
|
|
|
@ -149,7 +169,8 @@ namespace boost {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// assign one value to all elements
|
|
|
|
|
void assign (const T& value)
|
|
|
|
|
void assign (const T& value) { fill ( value ); } // A synonym for fill
|
|
|
|
|
void fill (const T& value)
|
|
|
|
|
{
|
|
|
|
|
std::fill_n(begin(),size(),value);
|
|
|
|
|
}
|
|
|
|
@ -157,7 +178,8 @@ namespace boost {
|
|
|
|
|
// check range (may be private because it is static)
|
|
|
|
|
static void rangecheck (size_type i) {
|
|
|
|
|
if (i >= size()) {
|
|
|
|
|
throw std::out_of_range("array<>: index out of range");
|
|
|
|
|
std::out_of_range e("array<>: index out of range");
|
|
|
|
|
boost::throw_exception(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -193,6 +215,11 @@ namespace boost {
|
|
|
|
|
reference, iterator, reference> > reverse_iterator;
|
|
|
|
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
|
|
|
|
const_reference, iterator, reference> > const_reverse_iterator;
|
|
|
|
|
#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
|
|
|
|
|
typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
|
|
|
|
|
value_type, reference, iterator, difference_type> reverse_iterator;
|
|
|
|
|
typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
|
|
|
|
|
value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
|
|
|
|
|
#else
|
|
|
|
|
// workaround for broken reverse_iterator implementations
|
|
|
|
|
typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
|
|
|
@ -209,19 +236,19 @@ namespace boost {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// operator[]
|
|
|
|
|
reference operator[](size_type i)
|
|
|
|
|
reference operator[](size_type /*i*/)
|
|
|
|
|
{
|
|
|
|
|
return failed_rangecheck();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const_reference operator[](size_type i) const
|
|
|
|
|
const_reference operator[](size_type /*i*/) const
|
|
|
|
|
{
|
|
|
|
|
return failed_rangecheck();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// at() with range check
|
|
|
|
|
reference at(size_type i) { return failed_rangecheck(); }
|
|
|
|
|
const_reference at(size_type i) const { return failed_rangecheck(); }
|
|
|
|
|
reference at(size_type /*i*/) { return failed_rangecheck(); }
|
|
|
|
|
const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
|
|
|
|
|
|
|
|
|
|
// front() and back()
|
|
|
|
|
reference front()
|
|
|
|
@ -250,7 +277,7 @@ namespace boost {
|
|
|
|
|
static size_type max_size() { return 0; }
|
|
|
|
|
enum { static_size = 0 };
|
|
|
|
|
|
|
|
|
|
void swap (array<T,0>& y) {
|
|
|
|
|
void swap (array<T,0>& /*y*/) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// direct access to data (read-only)
|
|
|
|
@ -267,12 +294,14 @@ namespace boost {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// assign one value to all elements
|
|
|
|
|
void assign (const T& ) { }
|
|
|
|
|
|
|
|
|
|
void assign (const T& value) { fill ( value ); }
|
|
|
|
|
void fill (const T& ) {}
|
|
|
|
|
|
|
|
|
|
// check range (may be private because it is static)
|
|
|
|
|
static reference failed_rangecheck () {
|
|
|
|
|
std::out_of_range e("attempt to access element of an empty array");
|
|
|
|
|
boost::throw_exception(e);
|
|
|
|
|
#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC)
|
|
|
|
|
//
|
|
|
|
|
// We need to return something here to keep
|
|
|
|
|
// some compilers happy: however we will never
|
|
|
|
@ -280,6 +309,7 @@ namespace boost {
|
|
|
|
|
//
|
|
|
|
|
static T placeholder;
|
|
|
|
|
return placeholder;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
@ -318,4 +348,9 @@ namespace boost {
|
|
|
|
|
|
|
|
|
|
} /* namespace boost */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
|
|
|
|
# pragma warning(pop)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /*BOOST_ARRAY_HPP*/
|
|
|
|
|