mirror of
https://github.com/boostorg/array.git
synced 2025-06-26 04:21:49 +02:00
Compare commits
10 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
30465bdb87 | |||
64e5394540 | |||
c37498364e | |||
5e81100035 | |||
79cadb97d7 | |||
9609395af0 | |||
fb72e72640 | |||
e875287d55 | |||
100b5d687b | |||
7fb9412ea8 |
@ -1,21 +0,0 @@
|
|||||||
#----------------------------------------------------------------------------
|
|
||||||
# This file was automatically generated from the original CMakeLists.txt file
|
|
||||||
# Add a variable to hold the headers for the library
|
|
||||||
set (lib_headers
|
|
||||||
array.hpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add a library target to the build system
|
|
||||||
boost_library_project(
|
|
||||||
array
|
|
||||||
# SRCDIRS
|
|
||||||
TESTDIRS test
|
|
||||||
HEADERS ${lib_headers}
|
|
||||||
# DOCDIRS
|
|
||||||
DESCRIPTION "STL compliant container wrapper for arrays of constant size."
|
|
||||||
MODULARIZED
|
|
||||||
AUTHORS "Nicolai Josuttis"
|
|
||||||
# MAINTAINERS
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
@ -13,6 +13,10 @@
|
|||||||
* accompanying file LICENSE_1_0.txt or copy at
|
* accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* 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)
|
* 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.
|
* 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries.
|
||||||
* 05 Aug 2001 - minor update (Nico Josuttis)
|
* 05 Aug 2001 - minor update (Nico Josuttis)
|
||||||
@ -24,6 +28,15 @@
|
|||||||
#ifndef BOOST_ARRAY_HPP
|
#ifndef BOOST_ARRAY_HPP
|
||||||
#define 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 <cstddef>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@ -71,6 +84,11 @@ namespace boost {
|
|||||||
reference, iterator, reference> > reverse_iterator;
|
reference, iterator, reference> > reverse_iterator;
|
||||||
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
||||||
const_reference, iterator, reference> > const_reverse_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
|
#else
|
||||||
// workaround for broken reverse_iterator implementations
|
// workaround for broken reverse_iterator implementations
|
||||||
typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
||||||
@ -151,7 +169,8 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assign one value to all elements
|
// 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);
|
std::fill_n(begin(),size(),value);
|
||||||
}
|
}
|
||||||
@ -159,7 +178,8 @@ namespace boost {
|
|||||||
// check range (may be private because it is static)
|
// check range (may be private because it is static)
|
||||||
static void rangecheck (size_type i) {
|
static void rangecheck (size_type i) {
|
||||||
if (i >= size()) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,6 +215,11 @@ namespace boost {
|
|||||||
reference, iterator, reference> > reverse_iterator;
|
reference, iterator, reference> > reverse_iterator;
|
||||||
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
||||||
const_reference, iterator, reference> > const_reverse_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
|
#else
|
||||||
// workaround for broken reverse_iterator implementations
|
// workaround for broken reverse_iterator implementations
|
||||||
typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
||||||
@ -269,12 +294,14 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assign one value to all elements
|
// 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)
|
// check range (may be private because it is static)
|
||||||
static reference failed_rangecheck () {
|
static reference failed_rangecheck () {
|
||||||
std::out_of_range e("attempt to access element of an empty array");
|
std::out_of_range e("attempt to access element of an empty array");
|
||||||
boost::throw_exception(e);
|
boost::throw_exception(e);
|
||||||
|
#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC)
|
||||||
//
|
//
|
||||||
// We need to return something here to keep
|
// We need to return something here to keep
|
||||||
// some compilers happy: however we will never
|
// some compilers happy: however we will never
|
||||||
@ -282,6 +309,7 @@ namespace boost {
|
|||||||
//
|
//
|
||||||
static T placeholder;
|
static T placeholder;
|
||||||
return placeholder;
|
return placeholder;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@ -318,6 +346,43 @@ namespace boost {
|
|||||||
x.swap(y);
|
x.swap(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specific for boost::array: simply returns its elems data member.
|
||||||
|
template <typename T, std::size_t N>
|
||||||
|
T(&get_c_array(boost::array<T,N>& arg))[N]
|
||||||
|
{
|
||||||
|
return arg.elems;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Const version.
|
||||||
|
template <typename T, std::size_t N>
|
||||||
|
const T(&get_c_array(const boost::array<T,N>& arg))[N]
|
||||||
|
{
|
||||||
|
return arg.elems;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Overload for std::array, assuming that std::array will have
|
||||||
|
// explicit conversion functions as discussed at the WG21 meeting
|
||||||
|
// in Summit, March 2009.
|
||||||
|
template <typename T, std::size_t N>
|
||||||
|
T(&get_c_array(std::array<T,N>& arg))[N]
|
||||||
|
{
|
||||||
|
return static_cast<T(&)[N]>(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Const version.
|
||||||
|
template <typename T, std::size_t N>
|
||||||
|
const T(&get_c_array(const std::array<T,N>& arg))[N]
|
||||||
|
{
|
||||||
|
return static_cast<T(&)[N]>(arg);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} /* namespace boost */
|
} /* namespace boost */
|
||||||
|
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /*BOOST_ARRAY_HPP*/
|
#endif /*BOOST_ARRAY_HPP*/
|
||||||
|
@ -1 +0,0 @@
|
|||||||
boost_module(array DEPENDS utility)
|
|
@ -1,8 +0,0 @@
|
|||||||
boost_additional_test_dependencies(array BOOST_DEPENDS test)
|
|
||||||
|
|
||||||
boost_test_run(array0 array0.cpp)
|
|
||||||
boost_test_run(array1 array1.cpp)
|
|
||||||
boost_test_run(array2 array2.cpp)
|
|
||||||
boost_test_run(array3 array3.cpp)
|
|
||||||
boost_test_run(array4 array4.cpp)
|
|
||||||
boost_test_run(array5 array5.cpp)
|
|
@ -32,7 +32,7 @@ void RunTests()
|
|||||||
test_type test_case = {};
|
test_type test_case = {};
|
||||||
const boost::array< T, 0 > const_test_case = test_type();
|
const boost::array< T, 0 > const_test_case = test_type();
|
||||||
|
|
||||||
test_case.assign( T() );
|
test_case.fill ( T() );
|
||||||
|
|
||||||
// front/back and operator[] must compile, but calling them is undefined
|
// front/back and operator[] must compile, but calling them is undefined
|
||||||
// Likewise, all tests below should evaluate to false, avoiding undefined behaviour
|
// Likewise, all tests below should evaluate to false, avoiding undefined behaviour
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _SCL_SECURE_NO_WARNINGS
|
||||||
|
// Suppress warnings from the std lib:
|
||||||
|
# define _SCL_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
Reference in New Issue
Block a user