forked from boostorg/array
Compare commits
1 Commits
boost-1.72
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
e24d329c11 |
217
.travis.yml
217
.travis.yml
@ -1,217 +0,0 @@
|
|||||||
# Copyright 2016, 2017 Peter Dimov
|
|
||||||
# Copyright 2018, Mike-Dev
|
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
language: cpp
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
python: "2.7"
|
|
||||||
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- /feature\/.*/
|
|
||||||
|
|
||||||
env:
|
|
||||||
matrix:
|
|
||||||
- BOGUS_JOB=true
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
|
|
||||||
exclude:
|
|
||||||
- env: BOGUS_JOB=true
|
|
||||||
|
|
||||||
include:
|
|
||||||
|
|
||||||
# cmake self-test
|
|
||||||
- os: linux
|
|
||||||
env: TEST_CMAKE=TRUE #Only for easier identification in travis web gui
|
|
||||||
install:
|
|
||||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
|
||||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/assert.git ../assert
|
|
||||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/config.git ../config
|
|
||||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/core.git ../core
|
|
||||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/static_assert.git ../static_assert
|
|
||||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/throw_exception.git ../throw_exception
|
|
||||||
|
|
||||||
script:
|
|
||||||
- mkdir __build__ && cd __build__
|
|
||||||
- cmake ../test/test_cmake
|
|
||||||
- cmake --build .
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++
|
|
||||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-4.7
|
|
||||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-4.7
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-4.8
|
|
||||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-4.9
|
|
||||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-4.9
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-5
|
|
||||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-5
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-6
|
|
||||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-6
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
compiler: g++-7
|
|
||||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-7
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++
|
|
||||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.5
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.5
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.5
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.6
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.6
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.6
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.7
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.7
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.7
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.8
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.8
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.8
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-3.9
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-3.9
|
|
||||||
- libstdc++-4.9-dev
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.9
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-4.0
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-4.0
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-trusty-4.0
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++-5.0
|
|
||||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- clang-5.0
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-trusty-5.0
|
|
||||||
|
|
||||||
- os: osx
|
|
||||||
compiler: clang++
|
|
||||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
|
||||||
|
|
||||||
install:
|
|
||||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
|
||||||
- cd ..
|
|
||||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
|
||||||
- cd boost-root
|
|
||||||
- git submodule update --init tools/build
|
|
||||||
- git submodule update --init libs/config
|
|
||||||
- git submodule update --init tools/boostdep
|
|
||||||
- cp -r $TRAVIS_BUILD_DIR/* libs/array
|
|
||||||
- python tools/boostdep/depinst/depinst.py array
|
|
||||||
- ./bootstrap.sh
|
|
||||||
- ./b2 headers
|
|
||||||
|
|
||||||
script:
|
|
||||||
- |-
|
|
||||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
|
||||||
- ./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
on_success: always
|
|
@ -1,24 +0,0 @@
|
|||||||
# Copyright 2018 Mike Dev
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# NOTE: CMake support for Boost.Array is currently experimental at best
|
|
||||||
# and the interface is likely to change in the future
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
|
||||||
project(boost-array LANGUAGES CXX)
|
|
||||||
|
|
||||||
add_library(boost_array INTERFACE)
|
|
||||||
add_library(Boost::array ALIAS boost_array)
|
|
||||||
|
|
||||||
target_include_directories(boost_array INTERFACE include)
|
|
||||||
|
|
||||||
target_link_libraries(boost_array
|
|
||||||
INTERFACE
|
|
||||||
Boost::assert
|
|
||||||
Boost::config
|
|
||||||
Boost::core
|
|
||||||
Boost::static_assert
|
|
||||||
Boost::throw_exception
|
|
||||||
)
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
#~ Copyright Marshall Clow 2013
|
|
||||||
#~ 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)
|
|
||||||
|
|
||||||
using boostbook ;
|
|
||||||
|
|
||||||
boostbook standalone
|
|
||||||
: array.xml
|
|
||||||
: <xsl:param>boost.root=../../../.. ;
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
alias boostdoc
|
|
||||||
: array.xml
|
|
||||||
:
|
|
||||||
:
|
|
||||||
: ;
|
|
||||||
explicit boostdoc ;
|
|
||||||
alias boostrelease ;
|
|
||||||
explicit boostrelease ;
|
|
@ -7,10 +7,6 @@
|
|||||||
<firstname>Nicolai</firstname>
|
<firstname>Nicolai</firstname>
|
||||||
<surname>Josuttis</surname>
|
<surname>Josuttis</surname>
|
||||||
</author>
|
</author>
|
||||||
<maintainer>
|
|
||||||
<firstname>Marshall</firstname>
|
|
||||||
<surname>Clow</surname>
|
|
||||||
</maintainer>
|
|
||||||
|
|
||||||
<copyright>
|
<copyright>
|
||||||
<year>2001</year>
|
<year>2001</year>
|
||||||
@ -20,11 +16,6 @@
|
|||||||
<holder>Nicolai M. Josuttis</holder>
|
<holder>Nicolai M. Josuttis</holder>
|
||||||
</copyright>
|
</copyright>
|
||||||
|
|
||||||
<copyright>
|
|
||||||
<year>2012</year>
|
|
||||||
<holder>Marshall Clow</holder>
|
|
||||||
</copyright>
|
|
||||||
|
|
||||||
<legalnotice>
|
<legalnotice>
|
||||||
<para>Distributed under the Boost Software License, Version 1.0.
|
<para>Distributed under the Boost Software License, Version 1.0.
|
||||||
(See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
(See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
||||||
@ -77,12 +68,7 @@
|
|||||||
|
|
||||||
<para>Note that this class is suggested to be part of the next
|
<para>Note that this class is suggested to be part of the next
|
||||||
Technical Report, which will extend the C++ Standard (see
|
Technical Report, which will extend the C++ Standard (see
|
||||||
<ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
|
<ulink url="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
|
||||||
|
|
||||||
<para>Update: <code>std::array</code> is (as of C++11) part of the C++ standard.
|
|
||||||
The differences between <code>boost::array</code> and <code>std::array</code> are minimal.
|
|
||||||
If you are using C++11, you should consider using <code>std::array</code> instead of <code>boost::array</code>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>Class <code><classname>array</classname></code> fulfills most
|
<para>Class <code><classname>array</classname></code> fulfills most
|
||||||
but not all of the requirements of "reversible containers" (see
|
but not all of the requirements of "reversible containers" (see
|
||||||
@ -185,24 +171,6 @@
|
|||||||
<returns><simpara>iterator for position after the last element</simpara></returns>
|
<returns><simpara>iterator for position after the last element</simpara></returns>
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
<throws><simpara>will not throw</simpara></throws>
|
||||||
</overloaded-method>
|
</overloaded-method>
|
||||||
|
|
||||||
<overloaded-method name="cbegin" cv="const">
|
|
||||||
<signature>
|
|
||||||
<type>const_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>constant iterator for the first element</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<overloaded-method name="cend" cv="const">
|
|
||||||
<signature>
|
|
||||||
<type>const_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>constant iterator for position after the last element</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
</method-group>
|
</method-group>
|
||||||
|
|
||||||
<method-group name="reverse iterator support">
|
<method-group name="reverse iterator support">
|
||||||
@ -227,24 +195,6 @@
|
|||||||
|
|
||||||
<returns><simpara>reverse iterator for position after the last element in reverse iteration</simpara></returns>
|
<returns><simpara>reverse iterator for position after the last element in reverse iteration</simpara></returns>
|
||||||
</overloaded-method>
|
</overloaded-method>
|
||||||
|
|
||||||
<overloaded-method name="crbegin" cv="const">
|
|
||||||
<signature>
|
|
||||||
<type>const_reverse_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>constant reverse iterator for the first element of reverse iteration</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<overloaded-method name="crend" cv="const">
|
|
||||||
<signature>
|
|
||||||
<type>const_reverse_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>constant reverse iterator for position after the last element in reverse iteration</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
</method-group>
|
</method-group>
|
||||||
|
|
||||||
<method-group name="capacity">
|
<method-group name="capacity">
|
||||||
@ -510,49 +460,6 @@
|
|||||||
<returns><simpara><code>!(x < y)</code></simpara></returns>
|
<returns><simpara><code>!(x < y)</code></simpara></returns>
|
||||||
</function>
|
</function>
|
||||||
</free-function-group>
|
</free-function-group>
|
||||||
|
|
||||||
<free-function-group name="specializations">
|
|
||||||
<function name="boost::get">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
<template-nontype-parameter name="Idx">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>T</type>
|
|
||||||
|
|
||||||
<parameter name="arr">
|
|
||||||
<paramtype><classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<returns><simpara>element of array with index <code>Idx</code></simpara></returns>
|
|
||||||
<effects><simpara>Will <code>static_assert</code> if <code>Idx >= N</code></simpara></effects>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="boost::get">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
<template-nontype-parameter name="Idx">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>T</type>
|
|
||||||
|
|
||||||
<parameter name="arr">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<returns><simpara>const element of array with index <code>Idx</code></simpara></returns>
|
|
||||||
<effects><simpara>Will <code>static_assert</code> if <code>Idx >= N</code></simpara></effects>
|
|
||||||
</function>
|
|
||||||
</free-function-group>
|
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
</namespace>
|
</namespace>
|
||||||
</header>
|
</header>
|
||||||
|
@ -13,13 +13,6 @@
|
|||||||
* 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)
|
||||||
*
|
*
|
||||||
* 9 Jan 2013 - (mtc) Added constexpr
|
|
||||||
* 14 Apr 2012 - (mtc) Added support for boost::hash
|
|
||||||
* 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility.
|
|
||||||
* 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)
|
||||||
@ -31,20 +24,9 @@
|
|||||||
#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>
|
||||||
#include <boost/static_assert.hpp>
|
|
||||||
#include <boost/swap.hpp>
|
|
||||||
|
|
||||||
// Handles broken standard libraries better than <iterator>
|
// Handles broken standard libraries better than <iterator>
|
||||||
#include <boost/detail/iterator.hpp>
|
#include <boost/detail/iterator.hpp>
|
||||||
@ -73,23 +55,21 @@ namespace boost {
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
|
||||||
// iterator support
|
// iterator support
|
||||||
iterator begin() { return elems; }
|
iterator begin() { return elems; }
|
||||||
const_iterator begin() const { return elems; }
|
const_iterator begin() const { return elems; }
|
||||||
const_iterator cbegin() const { return elems; }
|
iterator end() { return elems+N; }
|
||||||
|
const_iterator end() const { return elems+N; }
|
||||||
iterator end() { return elems+N; }
|
|
||||||
const_iterator end() const { return elems+N; }
|
|
||||||
const_iterator cend() const { return elems+N; }
|
|
||||||
|
|
||||||
// reverse iterator support
|
// reverse iterator support
|
||||||
#if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
|
#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
|
||||||
typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
|
// workaround for broken reverse_iterator in VC7
|
||||||
value_type, reference, iterator, difference_type> reverse_iterator;
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
|
||||||
typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
|
reference, iterator, reference> > reverse_iterator;
|
||||||
value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
||||||
|
const_reference, iterator, reference> > 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;
|
||||||
@ -100,32 +80,27 @@ namespace boost {
|
|||||||
const_reverse_iterator rbegin() const {
|
const_reverse_iterator rbegin() const {
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crbegin() const {
|
|
||||||
return const_reverse_iterator(end());
|
|
||||||
}
|
|
||||||
|
|
||||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||||
const_reverse_iterator rend() const {
|
const_reverse_iterator rend() const {
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crend() const {
|
|
||||||
return const_reverse_iterator(begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
// operator[]
|
// operator[]
|
||||||
reference operator[](size_type i)
|
reference operator[](size_type i)
|
||||||
{
|
{
|
||||||
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
BOOST_ASSERT( i < N && "out of range" );
|
||||||
|
return elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const
|
const_reference operator[](size_type i) const
|
||||||
{
|
{
|
||||||
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
BOOST_ASSERT( i < N && "out of range" );
|
||||||
|
return elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// at() with range check
|
// at() with range check
|
||||||
reference at(size_type i) { return rangecheck(i), elems[i]; }
|
reference at(size_type i) { rangecheck(i); return elems[i]; }
|
||||||
/*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; }
|
const_reference at(size_type i) const { rangecheck(i); return elems[i]; }
|
||||||
|
|
||||||
// front() and back()
|
// front() and back()
|
||||||
reference front()
|
reference front()
|
||||||
@ -133,7 +108,7 @@ namespace boost {
|
|||||||
return elems[0];
|
return elems[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CONSTEXPR const_reference front() const
|
const_reference front() const
|
||||||
{
|
{
|
||||||
return elems[0];
|
return elems[0];
|
||||||
}
|
}
|
||||||
@ -143,21 +118,20 @@ namespace boost {
|
|||||||
return elems[N-1];
|
return elems[N-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CONSTEXPR const_reference back() const
|
const_reference back() const
|
||||||
{
|
{
|
||||||
return elems[N-1];
|
return elems[N-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// size is constant
|
// size is constant
|
||||||
static BOOST_CONSTEXPR size_type size() { return N; }
|
static size_type size() { return N; }
|
||||||
static BOOST_CONSTEXPR bool empty() { return false; }
|
static bool empty() { return false; }
|
||||||
static BOOST_CONSTEXPR size_type max_size() { return N; }
|
static size_type max_size() { return N; }
|
||||||
enum { static_size = N };
|
enum { static_size = N };
|
||||||
|
|
||||||
// swap (note: linear complexity)
|
// swap (note: linear complexity)
|
||||||
void swap (array<T,N>& y) {
|
void swap (array<T,N>& y) {
|
||||||
for (size_type i = 0; i < N; ++i)
|
std::swap_ranges(begin(),end(),y.begin());
|
||||||
boost::swap(elems[i],y.elems[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct access to data (read-only)
|
// direct access to data (read-only)
|
||||||
@ -175,19 +149,21 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assign one value to all elements
|
// assign one value to all elements
|
||||||
void assign (const T& value) { fill ( value ); } // A synonym for fill
|
void assign (const T& value)
|
||||||
void fill (const T& value)
|
|
||||||
{
|
{
|
||||||
std::fill_n(begin(),size(),value);
|
std::fill_n(begin(),size(),value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check range (may be private because it is static)
|
// check range (may be private because it is static)
|
||||||
static BOOST_CONSTEXPR bool rangecheck (size_type i) {
|
static void rangecheck (size_type i) {
|
||||||
return i >= size() ? boost::throw_exception(std::out_of_range ("array<>: index out of range")), true : true;
|
if (i >= size()) {
|
||||||
|
throw std::out_of_range("array<>: index out of range");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||||
template< class T >
|
template< class T >
|
||||||
class array< T, 0 > {
|
class array< T, 0 > {
|
||||||
|
|
||||||
@ -202,23 +178,21 @@ namespace boost {
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
|
||||||
// iterator support
|
// iterator support
|
||||||
iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); }
|
iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); }
|
||||||
const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||||
const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
iterator end() { return begin(); }
|
||||||
|
const_iterator end() const { return begin(); }
|
||||||
iterator end() { return begin(); }
|
|
||||||
const_iterator end() const { return begin(); }
|
|
||||||
const_iterator cend() const { return cbegin(); }
|
|
||||||
|
|
||||||
// reverse iterator support
|
// reverse iterator support
|
||||||
#if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
|
#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
|
||||||
typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
|
// workaround for broken reverse_iterator in VC7
|
||||||
value_type, reference, iterator, difference_type> reverse_iterator;
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
|
||||||
typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
|
reference, iterator, reference> > reverse_iterator;
|
||||||
value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
|
typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
||||||
|
const_reference, iterator, reference> > 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;
|
||||||
@ -229,32 +203,25 @@ namespace boost {
|
|||||||
const_reverse_iterator rbegin() const {
|
const_reverse_iterator rbegin() const {
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crbegin() const {
|
|
||||||
return const_reverse_iterator(end());
|
|
||||||
}
|
|
||||||
|
|
||||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||||
const_reverse_iterator rend() const {
|
const_reverse_iterator rend() const {
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crend() const {
|
|
||||||
return const_reverse_iterator(begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
// operator[]
|
// operator[]
|
||||||
reference operator[](size_type /*i*/)
|
reference operator[](size_type i)
|
||||||
{
|
{
|
||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*BOOST_CONSTEXPR*/ const_reference operator[](size_type /*i*/) const
|
const_reference operator[](size_type i) const
|
||||||
{
|
{
|
||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
// at() with range check
|
// at() with range check
|
||||||
reference at(size_type /*i*/) { return failed_rangecheck(); }
|
reference at(size_type i) { return failed_rangecheck(); }
|
||||||
/*BOOST_CONSTEXPR*/ const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
|
const_reference at(size_type i) const { return failed_rangecheck(); }
|
||||||
|
|
||||||
// front() and back()
|
// front() and back()
|
||||||
reference front()
|
reference front()
|
||||||
@ -262,7 +229,7 @@ namespace boost {
|
|||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CONSTEXPR const_reference front() const
|
const_reference front() const
|
||||||
{
|
{
|
||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
@ -272,18 +239,18 @@ namespace boost {
|
|||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CONSTEXPR const_reference back() const
|
const_reference back() const
|
||||||
{
|
{
|
||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
// size is constant
|
// size is constant
|
||||||
static BOOST_CONSTEXPR size_type size() { return 0; }
|
static size_type size() { return 0; }
|
||||||
static BOOST_CONSTEXPR bool empty() { return true; }
|
static bool empty() { return true; }
|
||||||
static BOOST_CONSTEXPR size_type max_size() { return 0; }
|
static size_type max_size() { return 0; }
|
||||||
enum { static_size = 0 };
|
enum { static_size = 0 };
|
||||||
|
|
||||||
void swap (array<T,0>& /*y*/) {
|
void swap (array<T,0>& y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct access to data (read-only)
|
// direct access to data (read-only)
|
||||||
@ -300,14 +267,12 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assign one value to all elements
|
// assign one value to all elements
|
||||||
void assign (const T& value) { fill ( value ); }
|
void assign (const T& ) { }
|
||||||
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) && !defined(__PATHSCALE__))
|
|
||||||
//
|
//
|
||||||
// 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
|
||||||
@ -315,9 +280,9 @@ namespace boost {
|
|||||||
//
|
//
|
||||||
static T placeholder;
|
static T placeholder;
|
||||||
return placeholder;
|
return placeholder;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// comparisons
|
// comparisons
|
||||||
template<class T, std::size_t N>
|
template<class T, std::size_t N>
|
||||||
@ -351,107 +316,6 @@ namespace boost {
|
|||||||
x.swap(y);
|
x.swap(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__SUNPRO_CC)
|
|
||||||
// Trac ticket #4757; the Sun Solaris compiler can't handle
|
|
||||||
// syntax like 'T(&get_c_array(boost::array<T,N>& arg))[N]'
|
|
||||||
//
|
|
||||||
// We can't just use this for all compilers, because the
|
|
||||||
// borland compilers can't handle this form.
|
|
||||||
namespace detail {
|
|
||||||
template <typename T, std::size_t N> struct c_array
|
|
||||||
{
|
|
||||||
typedef T type[N];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Specific for boost::array: simply returns its elems data member.
|
|
||||||
template <typename T, std::size_t N>
|
|
||||||
typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg)
|
|
||||||
{
|
|
||||||
return arg.elems;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Specific for boost::array: simply returns its elems data member.
|
|
||||||
template <typename T, std::size_t N>
|
|
||||||
typename detail::c_array<T,N>::type const& get_c_array(const boost::array<T,N>& arg)
|
|
||||||
{
|
|
||||||
return arg.elems;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
template <class It> std::size_t hash_range(It, It);
|
|
||||||
|
|
||||||
template<class T, std::size_t N>
|
|
||||||
std::size_t hash_value(const array<T,N>& arr)
|
|
||||||
{
|
|
||||||
return boost::hash_range(arr.begin(), arr.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t Idx, typename T, size_t N>
|
|
||||||
T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
|
||||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
|
|
||||||
return arr[Idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t Idx, typename T, size_t N>
|
|
||||||
const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
|
||||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" );
|
|
||||||
return arr[Idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* namespace boost */
|
} /* namespace boost */
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
// If we don't have std::array, I'm assuming that we don't have std::get
|
|
||||||
namespace std {
|
|
||||||
template <size_t Idx, typename T, size_t N>
|
|
||||||
T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
|
||||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" );
|
|
||||||
return arr[Idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t Idx, typename T, size_t N>
|
|
||||||
const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
|
||||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(const boost::array &) index out of range" );
|
|
||||||
return arr[Idx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
|
||||||
# pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*BOOST_ARRAY_HPP*/
|
#endif /*BOOST_ARRAY_HPP*/
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"key": "array",
|
|
||||||
"name": "Array",
|
|
||||||
"authors": [
|
|
||||||
"Nicolai Josuttis"
|
|
||||||
],
|
|
||||||
"description": "STL compliant container wrapper for arrays of constant size.",
|
|
||||||
"std": [
|
|
||||||
"tr1"
|
|
||||||
],
|
|
||||||
"category": [
|
|
||||||
"Containers"
|
|
||||||
],
|
|
||||||
"maintainers": [
|
|
||||||
"Marshall Clow <marshall -at- idio.com>"
|
|
||||||
]
|
|
||||||
}
|
|
@ -2,6 +2,8 @@
|
|||||||
#~ Distributed under the Boost Software License, Version 1.0.
|
#~ 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)
|
#~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
import testing ;
|
||||||
|
|
||||||
test-suite array :
|
test-suite array :
|
||||||
[ run array0.cpp ]
|
[ run array0.cpp ]
|
||||||
[ run array1.cpp ]
|
[ run array1.cpp ]
|
||||||
@ -9,10 +11,4 @@ test-suite array :
|
|||||||
[ run array3.cpp ]
|
[ run array3.cpp ]
|
||||||
[ run array4.cpp ]
|
[ run array4.cpp ]
|
||||||
[ run array5.cpp ]
|
[ run array5.cpp ]
|
||||||
[ run array6.cpp ]
|
|
||||||
[ run array7.cpp ]
|
|
||||||
# [ run array_constexpr.cpp ]
|
|
||||||
[ compile-fail array_getfail1.cpp ]
|
|
||||||
[ compile-fail array_getfail2.cpp ]
|
|
||||||
[ run array_hash.cpp ]
|
|
||||||
;
|
;
|
||||||
|
@ -9,14 +9,18 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
unsigned int failed_tests = 0;
|
||||||
|
|
||||||
|
void fail_test( const char * reason ) {
|
||||||
|
++failed_tests;
|
||||||
|
std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
void BadValue( const T & )
|
void BadValue( const T & )
|
||||||
{
|
{
|
||||||
BOOST_TEST ( false );
|
fail_test( "Unexpected value" );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
@ -28,45 +32,59 @@ 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.fill ( T() );
|
test_case.assign( 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
|
||||||
BOOST_TEST ( test_case.empty());
|
if( !test_case.empty() ) {
|
||||||
BOOST_TEST ( const_test_case.empty());
|
BadValue( test_case.front() );
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_TEST ( test_case.size() == 0 );
|
if( !const_test_case.empty() ) {
|
||||||
BOOST_TEST ( const_test_case.size() == 0 );
|
BadValue( const_test_case.back() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( test_case.size() > 0 ) {
|
||||||
|
BadValue( test_case[ 0 ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( const_test_case.max_size() > 0 ) {
|
||||||
|
BadValue( const_test_case[ 0 ] );
|
||||||
|
}
|
||||||
|
|
||||||
// Assert requirements of TR1 6.2.2.4
|
// Assert requirements of TR1 6.2.2.4
|
||||||
BOOST_TEST ( test_case.begin() == test_case.end());
|
if( test_case.begin() != test_case.end() ) {
|
||||||
BOOST_TEST ( test_case.cbegin() == test_case.cend());
|
fail_test( "Not an empty range" );
|
||||||
BOOST_TEST ( const_test_case.begin() == const_test_case.end());
|
}
|
||||||
BOOST_TEST ( const_test_case.cbegin() == const_test_case.cend());
|
if( const_test_case.begin() != const_test_case.end() ) {
|
||||||
|
fail_test( "Not an empty range" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( test_case.begin() == const_test_case.begin() ) {
|
||||||
|
fail_test( "iterators for different containers are not distinct" );
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_TEST ( test_case.begin() != const_test_case.begin() );
|
|
||||||
if( test_case.data() == const_test_case.data() ) {
|
if( test_case.data() == const_test_case.data() ) {
|
||||||
// Value of data is unspecified in TR1, so no requirement this test pass or fail
|
// Value of data is unspecified in TR1, so no requirement this test pass or fail
|
||||||
// However, it must compile!
|
// However, it must compile!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check can safely use all iterator types with std algorithms
|
// Check can safely use all iterator types with std algorithms
|
||||||
std::for_each( test_case.begin(), test_case.end(), BadValue< T > );
|
std::for_each( test_case.begin(), test_case.end(), BadValue< T > );
|
||||||
std::for_each( test_case.rbegin(), test_case.rend(), BadValue< T > );
|
std::for_each( test_case.rbegin(), test_case.rend(), BadValue< T > );
|
||||||
std::for_each( test_case.cbegin(), test_case.cend(), BadValue< T > );
|
|
||||||
std::for_each( const_test_case.begin(), const_test_case.end(), BadValue< T > );
|
std::for_each( const_test_case.begin(), const_test_case.end(), BadValue< T > );
|
||||||
std::for_each( const_test_case.rbegin(), const_test_case.rend(), BadValue< T > );
|
std::for_each( const_test_case.rbegin(), const_test_case.rend(), BadValue< T > );
|
||||||
std::for_each( const_test_case.cbegin(), const_test_case.cend(), BadValue< T > );
|
|
||||||
|
|
||||||
// Check swap is well formed
|
// Check swap is well formed
|
||||||
std::swap( test_case, test_case );
|
std::swap( test_case, test_case );
|
||||||
|
|
||||||
// Check assignment operator and overloads are well formed
|
// Check assigment operator and overloads are well formed
|
||||||
test_case = const_test_case;
|
test_case = const_test_case;
|
||||||
|
|
||||||
// Confirm at() throws the std lib defined exception
|
// Confirm at() throws the std lib defined exception
|
||||||
try {
|
try {
|
||||||
BadValue( test_case.at( 0 ));
|
BadValue( test_case.at( 0 ) );
|
||||||
} catch ( const std::out_of_range & ) {
|
} catch ( const std::out_of_range & ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +102,6 @@ int main()
|
|||||||
RunTests< void * >();
|
RunTests< void * >();
|
||||||
RunTests< long double >();
|
RunTests< long double >();
|
||||||
RunTests< std::string >();
|
RunTests< std::string >();
|
||||||
|
return failed_tests;
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,21 +5,17 @@
|
|||||||
* 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>
|
||||||
#include "print.hpp"
|
#include "print.hpp"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace boost;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// create and initialize array
|
// create and initialize array
|
||||||
boost::array<int,10> a = { { 1, 2, 3, 4, 5 } };
|
array<int,10> a = { { 1, 2, 3, 4, 5 } };
|
||||||
|
|
||||||
print_elements(a);
|
print_elements(a);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ int main()
|
|||||||
|
|
||||||
// copy and change order
|
// copy and change order
|
||||||
boost::array<std::string,4> seasons_orig = seasons;
|
boost::array<std::string,4> seasons_orig = seasons;
|
||||||
for (std::size_t i=seasons.size()-1; i>0; --i) {
|
for (unsigned i=seasons.size()-1; i>0; --i) {
|
||||||
std::swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
|
std::swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,13 +39,6 @@ int main()
|
|||||||
=seasons.rbegin(); pos<seasons.rend(); ++pos) {
|
=seasons.rbegin(); pos<seasons.rend(); ++pos) {
|
||||||
std::cout << " " << *pos;
|
std::cout << " " << *pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try constant reverse iterators
|
|
||||||
std::cout << "reverse: ";
|
|
||||||
for (boost::array<std::string,4>::const_reverse_iterator pos
|
|
||||||
=seasons.crbegin(); pos<seasons.crend(); ++pos) {
|
|
||||||
std::cout << " " << *pos;
|
|
||||||
}
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
return 0; // makes Visual-C++ compiler happy
|
return 0; // makes Visual-C++ compiler happy
|
||||||
|
@ -27,7 +27,7 @@ int main()
|
|||||||
typedef boost::array<float,6> Array;
|
typedef boost::array<float,6> Array;
|
||||||
|
|
||||||
// create and initialize an array
|
// create and initialize an array
|
||||||
const Array a = { { 42.42f } };
|
const Array a = { { 42.42 } };
|
||||||
|
|
||||||
// use some common STL container operations
|
// use some common STL container operations
|
||||||
std::cout << "static_size: " << a.size() << std::endl;
|
std::cout << "static_size: " << a.size() << std::endl;
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
/* tests for using class array<> specialization for size 0
|
|
||||||
* (C) Copyright Alisdair Meredith 2006.
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
template< class T >
|
|
||||||
void RunTests()
|
|
||||||
{
|
|
||||||
typedef boost::array< T, 5 > test_type;
|
|
||||||
typedef T arr[5];
|
|
||||||
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
|
||||||
|
|
||||||
arr &aRef = get_c_array ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.begin () == &aRef[0] );
|
|
||||||
|
|
||||||
const arr &caRef = get_c_array ( test_case );
|
|
||||||
typename test_type::const_iterator iter = test_case.begin ();
|
|
||||||
BOOST_TEST ( &*iter == &caRef[0] );
|
|
||||||
|
|
||||||
// Confirm at() throws the std lib defined exception
|
|
||||||
try {
|
|
||||||
test_case.at( test_case.size());
|
|
||||||
BOOST_TEST(false);
|
|
||||||
}
|
|
||||||
catch ( const std::out_of_range & ) {}
|
|
||||||
|
|
||||||
try {
|
|
||||||
test_case.at( test_case.size() + 1);
|
|
||||||
BOOST_TEST(false);
|
|
||||||
}
|
|
||||||
catch ( const std::out_of_range & ) {}
|
|
||||||
|
|
||||||
try {
|
|
||||||
test_case.at( test_case.size() + 100);
|
|
||||||
BOOST_TEST(false);
|
|
||||||
}
|
|
||||||
catch ( const std::out_of_range & ) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main ()
|
|
||||||
{
|
|
||||||
RunTests< bool >();
|
|
||||||
RunTests< void * >();
|
|
||||||
RunTests< long double >();
|
|
||||||
RunTests< std::string >();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
|||||||
/* tests using std::get on boost:array
|
|
||||||
* (C) Copyright Marshall Clow 2012
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
#include <array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
template< class T >
|
|
||||||
void RunStdTests()
|
|
||||||
{
|
|
||||||
typedef boost::array< T, 5 > test_type;
|
|
||||||
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
|
||||||
|
|
||||||
T &aRef = std::get<0> ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.begin () == &aRef );
|
|
||||||
|
|
||||||
const T &caRef = std::get<0> ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.cbegin () == &caRef );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template< class T >
|
|
||||||
void RunBoostTests()
|
|
||||||
{
|
|
||||||
typedef boost::array< T, 5 > test_type;
|
|
||||||
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
|
||||||
|
|
||||||
T &aRef = boost::get<0> ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.begin () == &aRef );
|
|
||||||
|
|
||||||
const T &caRef = boost::get<0> ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.cbegin () == &caRef );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
RunBoostTests< bool >();
|
|
||||||
RunBoostTests< void * >();
|
|
||||||
RunBoostTests< long double >();
|
|
||||||
RunBoostTests< std::string >();
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
RunStdTests< bool >();
|
|
||||||
RunStdTests< void * >();
|
|
||||||
RunStdTests< long double >();
|
|
||||||
RunStdTests< std::string >();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
|||||||
/* tests using constexpr on boost:array
|
|
||||||
* (C) Copyright Marshall Clow 2012
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
#include <array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_CONSTEXPR
|
|
||||||
constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
|
|
||||||
constexpr std::array<int, 10> arr_std {{ 0,1,2,3,4,5,6,7,8,9 }};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void sink ( T t ) {}
|
|
||||||
|
|
||||||
template <typename T, size_t N>
|
|
||||||
void sink ( boost::array<T,N> &arr ) {}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// constexpr int two = arr_std.at (2);
|
|
||||||
constexpr int three = arr.at (3);
|
|
||||||
int whatever [ arr.at(4) ];
|
|
||||||
(void)three;
|
|
||||||
(void) whatever;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // no constexpr means no constexpr tests!
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,50 +0,0 @@
|
|||||||
/* tests using std::get on boost:array
|
|
||||||
* (C) Copyright Marshall Clow 2012
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <boost/static_assert.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <algorithm>
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
#include <array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
template< class T >
|
|
||||||
void RunStdTests()
|
|
||||||
{
|
|
||||||
typedef boost::array< T, 5 > test_type;
|
|
||||||
typedef T arr[5];
|
|
||||||
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
|
||||||
|
|
||||||
T &aRef = std::get<5> ( test_case ); // should fail to compile
|
|
||||||
BOOST_TEST ( &*test_case.begin () == &aRef );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
RunStdTests< bool >();
|
|
||||||
RunStdTests< void * >();
|
|
||||||
RunStdTests< long double >();
|
|
||||||
RunStdTests< std::string >();
|
|
||||||
#else
|
|
||||||
BOOST_STATIC_ASSERT ( false ); // fail on C++03 systems.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
/* tests using std::get on boost:array
|
|
||||||
* (C) Copyright Marshall Clow 2012
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
#include <array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
template< class T >
|
|
||||||
void RunStdTests()
|
|
||||||
{
|
|
||||||
typedef boost::array< T, 5 > test_type;
|
|
||||||
typedef T arr[5];
|
|
||||||
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
|
||||||
|
|
||||||
T &aRef = std::get<0> ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.begin () == &aRef );
|
|
||||||
|
|
||||||
const T &caRef = std::get<0> ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.cbegin () == &caRef );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template< class T >
|
|
||||||
void RunBoostTests()
|
|
||||||
{
|
|
||||||
typedef boost::array< T, 5 > test_type;
|
|
||||||
typedef T arr[5];
|
|
||||||
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
|
||||||
|
|
||||||
T &aRef = boost::get<5> ( test_case );
|
|
||||||
BOOST_TEST ( &*test_case.begin () == &aRef );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
RunBoostTests< bool >();
|
|
||||||
RunBoostTests< void * >();
|
|
||||||
RunBoostTests< long double >();
|
|
||||||
RunBoostTests< std::string >();
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
RunStdTests< bool >();
|
|
||||||
RunStdTests< void * >();
|
|
||||||
RunStdTests< long double >();
|
|
||||||
RunStdTests< std::string >();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
/* tests for using boost::hash with boost::array
|
|
||||||
* (C) Copyright Marshall Clow 2012
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <boost/functional/hash.hpp>
|
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
template< class T >
|
|
||||||
void RunTests()
|
|
||||||
{
|
|
||||||
// std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ());
|
|
||||||
// std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ());
|
|
||||||
|
|
||||||
typedef boost::array< T, 5 > barr;
|
|
||||||
typedef T arr[5];
|
|
||||||
barr test_barr = {{ 1, 1, 2, 3, 5 }};
|
|
||||||
arr test_arr = { 1, 1, 2, 3, 5 };
|
|
||||||
|
|
||||||
std::size_t bhash = boost::hash<barr> () ( test_barr );
|
|
||||||
std::size_t ahash = boost::hash<arr> () ( test_arr );
|
|
||||||
BOOST_TEST ( ahash == bhash );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
RunTests< int >();
|
|
||||||
RunTests< long >();
|
|
||||||
RunTests< long double >();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
|||||||
# Copyright 2018 Mike Dev
|
|
||||||
# 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
|
|
||||||
#
|
|
||||||
# NOTE: This does NOT run the unit tests for Boost.Array.
|
|
||||||
# It only tests, if the CMakeLists.txt file in it's root works as expected
|
|
||||||
|
|
||||||
cmake_minimum_required( VERSION 3.5 )
|
|
||||||
|
|
||||||
project( BoostBindCMakeSelfTest )
|
|
||||||
|
|
||||||
add_subdirectory( ../../../assert ${CMAKE_CURRENT_BINARY_DIR}/libs/assert )
|
|
||||||
add_subdirectory( ../../../config ${CMAKE_CURRENT_BINARY_DIR}/libs/config )
|
|
||||||
add_subdirectory( ../../../core ${CMAKE_CURRENT_BINARY_DIR}/libs/core )
|
|
||||||
add_subdirectory( ../../../static_assert ${CMAKE_CURRENT_BINARY_DIR}/libs/static_assert )
|
|
||||||
add_subdirectory( ../../../throw_exception ${CMAKE_CURRENT_BINARY_DIR}/libs/thorw_exception )
|
|
||||||
|
|
||||||
add_subdirectory( ../.. ${CMAKE_CURRENT_BINARY_DIR}/libs/boost_array )
|
|
||||||
|
|
||||||
add_executable( boost_array_cmake_self_test main.cpp )
|
|
||||||
target_link_libraries( boost_array_cmake_self_test Boost::array )
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
#include <boost/array.hpp>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
boost::array<int,5> a{};
|
|
||||||
}
|
|
Reference in New Issue
Block a user