mirror of
https://github.com/boostorg/array.git
synced 2025-06-25 20:11:45 +02:00
Compare commits
80 Commits
boost-1.77
...
feature/re
Author | SHA1 | Date | |
---|---|---|---|
cd0532b8fa | |||
6a9e8c78da | |||
55bc631d40 | |||
435b293467 | |||
6447b408b2 | |||
17b49d86ad | |||
fe60e163c7 | |||
16280f660b | |||
16b6ba8d84 | |||
f5a3f1b34a | |||
9e2868f8e2 | |||
4f2ed73766 | |||
b32a6cfcfd | |||
50cf6ebba7 | |||
ec05d6ca34 | |||
18ec6239b2 | |||
b44be8da89 | |||
ea9dbd5674 | |||
5c05254afb | |||
a211468866 | |||
c06cadc04f | |||
f155831795 | |||
7ca2f112a2 | |||
19f02c7615 | |||
66386e8eda | |||
54d839c8bc | |||
e7663434ee | |||
52406dfcc0 | |||
9b8a342f44 | |||
01983ff604 | |||
536412674f | |||
8c5f36ae52 | |||
9d6b871972 | |||
79ca787bfe | |||
0da094a21d | |||
2099995189 | |||
31b9fdd397 | |||
dca9ae1a60 | |||
ff5eb67906 | |||
7223d3dfcb | |||
c549abb184 | |||
cbd8e1a8dc | |||
4e3d4ef99f | |||
63f8f022e2 | |||
8d1871b4c2 | |||
c0488c00a3 | |||
48b07e63fb | |||
8999204cae | |||
c5741a92e7 | |||
1ae515a17d | |||
72997add96 | |||
51fbc208d9 | |||
7fac30e1ab | |||
049e98dd57 | |||
e0bd7e8560 | |||
f9bb980a0b | |||
fd24e0592c | |||
ea54ab1610 | |||
cd6244f787 | |||
99c3a4b966 | |||
22b8eebc3c | |||
fed8935fdf | |||
9ea71dd967 | |||
9a11abcb9f | |||
f9c01c811a | |||
23f6b27c0d | |||
ecc47cb42c | |||
d9ccba0907 | |||
bdc9ff1e24 | |||
8ad6749d4a | |||
ec72fd87a1 | |||
3dfc2a089c | |||
b19ce675ad | |||
c774c93b3b | |||
868af27d82 | |||
4647fc7095 | |||
9cc63ae0dd | |||
a3f15458b8 | |||
a9a3dbbc41 | |||
e384e3780b |
346
.drone.jsonnet
Normal file
346
.drone.jsonnet
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
# Copyright 2022 Peter Dimov
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
local library = "array";
|
||||||
|
|
||||||
|
local triggers =
|
||||||
|
{
|
||||||
|
branch: [ "master", "develop", "feature/*" ]
|
||||||
|
};
|
||||||
|
|
||||||
|
local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' };
|
||||||
|
local asan = { ASAN: '1' };
|
||||||
|
|
||||||
|
local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") =
|
||||||
|
{
|
||||||
|
name: name,
|
||||||
|
kind: "pipeline",
|
||||||
|
type: "docker",
|
||||||
|
trigger: triggers,
|
||||||
|
platform:
|
||||||
|
{
|
||||||
|
os: "linux",
|
||||||
|
arch: arch
|
||||||
|
},
|
||||||
|
steps:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: "everything",
|
||||||
|
image: image,
|
||||||
|
environment: environment,
|
||||||
|
commands:
|
||||||
|
[
|
||||||
|
'set -e',
|
||||||
|
'uname -a',
|
||||||
|
'echo $DRONE_STAGE_MACHINE',
|
||||||
|
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
|
||||||
|
] +
|
||||||
|
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
|
||||||
|
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
|
||||||
|
[
|
||||||
|
'export LIBRARY=' + library,
|
||||||
|
'./.drone/drone.sh',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") =
|
||||||
|
{
|
||||||
|
name: name,
|
||||||
|
kind: "pipeline",
|
||||||
|
type: "exec",
|
||||||
|
trigger: triggers,
|
||||||
|
platform: {
|
||||||
|
"os": "darwin",
|
||||||
|
"arch": arch
|
||||||
|
},
|
||||||
|
node: {
|
||||||
|
"os": osx_version
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: "everything",
|
||||||
|
environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" },
|
||||||
|
commands:
|
||||||
|
[
|
||||||
|
'export LIBRARY=' + library,
|
||||||
|
'./.drone/drone.sh',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||||
|
{
|
||||||
|
name: name,
|
||||||
|
kind: "pipeline",
|
||||||
|
type: "docker",
|
||||||
|
trigger: triggers,
|
||||||
|
platform:
|
||||||
|
{
|
||||||
|
os: "windows",
|
||||||
|
arch: arch
|
||||||
|
},
|
||||||
|
"steps":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: "everything",
|
||||||
|
image: image,
|
||||||
|
environment: environment,
|
||||||
|
commands:
|
||||||
|
[
|
||||||
|
'cmd /C .drone\\\\drone.bat ' + library,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
[
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 GCC 4.6",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98' },
|
||||||
|
"g++-4.6",
|
||||||
|
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 GCC 4.7",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98' },
|
||||||
|
"g++-4.7",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 GCC 4.8",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '03,11' },
|
||||||
|
"g++-4.8",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 GCC 4.9",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' },
|
||||||
|
"g++-4.9",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 GCC 5*",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14' },
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 18.04 GCC 6",
|
||||||
|
"cppalliance/droneubuntu1804:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14' },
|
||||||
|
"g++-6",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 18.04 GCC 7* 32/64",
|
||||||
|
"cppalliance/droneubuntu1804:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' },
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 18.04 GCC 8",
|
||||||
|
"cppalliance/droneubuntu1804:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17' },
|
||||||
|
"g++-8",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 20.04 GCC 9* 32/64",
|
||||||
|
"cppalliance/droneubuntu2004:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 20.04 GCC 9* ARM64",
|
||||||
|
"cppalliance/droneubuntu2004:multiarch",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
|
||||||
|
arch="arm64",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 20.04 GCC 9* S390x",
|
||||||
|
"cppalliance/droneubuntu2004:multiarch",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
|
||||||
|
arch="s390x",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 20.04 GCC 10 32/64",
|
||||||
|
"cppalliance/droneubuntu2004:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32,64' },
|
||||||
|
"g++-10-multilib",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 22.04 GCC 11* 32/64",
|
||||||
|
"cppalliance/droneubuntu2204:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 22.04 GCC 12 32/64",
|
||||||
|
"cppalliance/droneubuntu2204:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' },
|
||||||
|
"g++-12-multilib",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.04 GCC 13 32/64 UBSAN",
|
||||||
|
"cppalliance/droneubuntu2404:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' } + ubsan,
|
||||||
|
"g++-13-multilib",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.04 GCC 14 32/64 ASAN",
|
||||||
|
"cppalliance/droneubuntu2404:1",
|
||||||
|
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' } + asan,
|
||||||
|
"g++-14-multilib",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 Clang 3.5",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' },
|
||||||
|
"clang-3.5",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 Clang 3.6",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' },
|
||||||
|
"clang-3.6",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 Clang 3.7",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' },
|
||||||
|
"clang-3.7",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 16.04 Clang 3.8",
|
||||||
|
"cppalliance/droneubuntu1604:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' },
|
||||||
|
"clang-3.8",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 22.04 Clang 13",
|
||||||
|
"cppalliance/droneubuntu2204:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
|
||||||
|
"clang-13",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 22.04 Clang 14",
|
||||||
|
"cppalliance/droneubuntu2204:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' },
|
||||||
|
"clang-14",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 22.04 Clang 15",
|
||||||
|
"cppalliance/droneubuntu2204:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' },
|
||||||
|
"clang-15",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.04 Clang 16",
|
||||||
|
"cppalliance/droneubuntu2404:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '03,11,14,17,20,2b' },
|
||||||
|
"clang-16",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.04 Clang 17 UBSAN",
|
||||||
|
"cppalliance/droneubuntu2404:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||||
|
"clang-17",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.04 Clang 17 ASAN",
|
||||||
|
"cppalliance/droneubuntu2404:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||||
|
"clang-17",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.04 Clang 18 UBSAN",
|
||||||
|
"cppalliance/droneubuntu2404:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||||
|
"clang-18",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.04 Clang 18 ASAN",
|
||||||
|
"cppalliance/droneubuntu2404:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||||
|
"clang-18",
|
||||||
|
),
|
||||||
|
|
||||||
|
linux_pipeline(
|
||||||
|
"Linux 24.10 Clang 19",
|
||||||
|
"cppalliance/droneubuntu2410:1",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' },
|
||||||
|
"clang-19",
|
||||||
|
),
|
||||||
|
|
||||||
|
macos_pipeline(
|
||||||
|
"MacOS 10.15 Xcode 12.2 UBSAN",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
|
||||||
|
),
|
||||||
|
|
||||||
|
macos_pipeline(
|
||||||
|
"MacOS 10.15 Xcode 12.2 ASAN",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
|
||||||
|
),
|
||||||
|
|
||||||
|
macos_pipeline(
|
||||||
|
"MacOS 12.4 Xcode 13.4.1 UBSAN",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
|
||||||
|
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||||
|
),
|
||||||
|
|
||||||
|
macos_pipeline(
|
||||||
|
"MacOS 12.4 Xcode 13.4.1 ASAN",
|
||||||
|
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan,
|
||||||
|
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||||
|
),
|
||||||
|
|
||||||
|
windows_pipeline(
|
||||||
|
"Windows VS2015 msvc-14.0",
|
||||||
|
"cppalliance/dronevs2015",
|
||||||
|
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' },
|
||||||
|
),
|
||||||
|
|
||||||
|
windows_pipeline(
|
||||||
|
"Windows VS2017 msvc-14.1",
|
||||||
|
"cppalliance/dronevs2017",
|
||||||
|
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' },
|
||||||
|
),
|
||||||
|
|
||||||
|
windows_pipeline(
|
||||||
|
"Windows VS2019 msvc-14.2",
|
||||||
|
"cppalliance/dronevs2019",
|
||||||
|
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' },
|
||||||
|
),
|
||||||
|
|
||||||
|
windows_pipeline(
|
||||||
|
"Windows VS2022 msvc-14.3",
|
||||||
|
"cppalliance/dronevs2022:1",
|
||||||
|
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
|
||||||
|
),
|
||||||
|
]
|
37
.drone.star
37
.drone.star
@ -1,37 +0,0 @@
|
|||||||
# Use, modification, and distribution are
|
|
||||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
# file LICENSE.txt)
|
|
||||||
#
|
|
||||||
# Copyright Rene Rivera 2020.
|
|
||||||
|
|
||||||
# For Drone CI we use the Starlark scripting language to reduce duplication.
|
|
||||||
# As the yaml syntax for Drone CI is rather limited.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
globalenv={}
|
|
||||||
linuxglobalimage="cppalliance/droneubuntu1604:1"
|
|
||||||
windowsglobalimage="cppalliance/dronevs2019"
|
|
||||||
|
|
||||||
def main(ctx):
|
|
||||||
return [
|
|
||||||
linux_cxx("TEST_CMAKE=TRUE Job 0", "g++", packages="", buildtype="96ad197d74-2319b6d45f", image=linuxglobalimage, environment={'TEST_CMAKE': 'TRUE', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 1", "g++", packages="", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 2", "g++-4.7", packages="g++-4.7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 3", "g++-4.8", packages="g++-4.8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 4", "g++-4.9", packages="g++-4.9", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.9', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 5", "g++-5", packages="g++-5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 6", "g++-6", packages="g++-6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 7", "g++-7", packages="g++-7", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '03,11,14,17', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 8", "clang++", packages="", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 9", "clang++", packages="clang-3.5 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 10", "clang++", packages="clang-3.6", llvm_os="precise", llvm_ver="3.6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 11", "clang++", packages="clang-3.7", llvm_os="precise", llvm_ver="3.7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.7', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 12", "clang++-3.8", packages="clang-3.8 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.8', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 13", "clang++-3.9", packages="clang-3.9 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.9", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.9', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 14", "clang++-4.0", packages="clang-4.0", llvm_os="xenial", llvm_ver="4.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-4.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv),
|
|
||||||
linux_cxx("TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 15", "clang++-5.0", packages="clang-5.0", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-5.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv),
|
|
||||||
osx_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 16", "clang++", packages="", buildtype="boost", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '1574bddb75'}, globalenv=globalenv),
|
|
||||||
]
|
|
||||||
|
|
||||||
# from https://github.com/boostorg/boost-ci
|
|
||||||
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")
|
|
@ -1,37 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
export TRAVIS_BUILD_DIR=$(pwd)
|
|
||||||
export DRONE_BUILD_DIR=$(pwd)
|
|
||||||
export TRAVIS_BRANCH=$DRONE_BRANCH
|
|
||||||
export VCS_COMMIT_ID=$DRONE_COMMIT
|
|
||||||
export GIT_COMMIT=$DRONE_COMMIT
|
|
||||||
export REPO_NAME=$DRONE_REPO
|
|
||||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
|
||||||
|
|
||||||
echo '==================================> BEFORE_INSTALL'
|
|
||||||
|
|
||||||
. .drone/before-install.sh
|
|
||||||
|
|
||||||
echo '==================================> 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
|
|
||||||
|
|
||||||
echo '==================================> BEFORE_SCRIPT'
|
|
||||||
|
|
||||||
. $DRONE_BUILD_DIR/.drone/before-script.sh
|
|
||||||
|
|
||||||
echo '==================================> SCRIPT'
|
|
||||||
|
|
||||||
mkdir __build__ && cd __build__
|
|
||||||
cmake ../test/test_cmake
|
|
||||||
cmake --build .
|
|
||||||
|
|
||||||
echo '==================================> AFTER_SUCCESS'
|
|
||||||
|
|
||||||
. $DRONE_BUILD_DIR/.drone/after-success.sh
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
export TRAVIS_BUILD_DIR=$(pwd)
|
|
||||||
export DRONE_BUILD_DIR=$(pwd)
|
|
||||||
export TRAVIS_BRANCH=$DRONE_BRANCH
|
|
||||||
export VCS_COMMIT_ID=$DRONE_COMMIT
|
|
||||||
export GIT_COMMIT=$DRONE_COMMIT
|
|
||||||
export REPO_NAME=$DRONE_REPO
|
|
||||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
|
||||||
|
|
||||||
echo '==================================> BEFORE_INSTALL'
|
|
||||||
|
|
||||||
. .drone/before-install.sh
|
|
||||||
|
|
||||||
echo '==================================> 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
|
|
||||||
|
|
||||||
echo '==================================> BEFORE_SCRIPT'
|
|
||||||
|
|
||||||
. $DRONE_BUILD_DIR/.drone/before-script.sh
|
|
||||||
|
|
||||||
echo '==================================> SCRIPT'
|
|
||||||
|
|
||||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
|
||||||
./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD
|
|
||||||
|
|
||||||
echo '==================================> AFTER_SUCCESS'
|
|
||||||
|
|
||||||
. $DRONE_BUILD_DIR/.drone/after-success.sh
|
|
23
.drone/drone.bat
Normal file
23
.drone/drone.bat
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
@REM Copyright 2022 Peter Dimov
|
||||||
|
@REM Distributed under the Boost Software License, Version 1.0.
|
||||||
|
@REM https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
@ECHO ON
|
||||||
|
|
||||||
|
set LIBRARY=%1
|
||||||
|
set DRONE_BUILD_DIR=%CD%
|
||||||
|
|
||||||
|
set BOOST_BRANCH=develop
|
||||||
|
if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||||
|
cd ..
|
||||||
|
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\
|
||||||
|
python tools/boostdep/depinst/depinst.py %LIBRARY%
|
||||||
|
cmd /c bootstrap
|
||||||
|
b2 -d0 headers
|
||||||
|
|
||||||
|
if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||||
|
if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||||
|
b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
25
.drone/drone.sh
Executable file
25
.drone/drone.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2022 Peter Dimov
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||||
|
|
||||||
|
DRONE_BUILD_DIR=$(pwd)
|
||||||
|
|
||||||
|
BOOST_BRANCH=develop
|
||||||
|
if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY
|
||||||
|
python tools/boostdep/depinst/depinst.py $LIBRARY
|
||||||
|
./bootstrap.sh
|
||||||
|
./b2 -d0 headers
|
||||||
|
|
||||||
|
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||||
|
./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
923
.github/workflows/ci.yml
vendored
923
.github/workflows/ci.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: GitHub Actions CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@ -6,10 +6,10 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
- githubactions*
|
|
||||||
- feature/**
|
- feature/**
|
||||||
- fix/**
|
|
||||||
- pr/**
|
env:
|
||||||
|
UBSAN_OPTIONS: print_stacktrace=1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
posix:
|
posix:
|
||||||
@ -17,380 +17,627 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- name: "TEST_CMAKE=TRUE Job 0"
|
- toolset: gcc-4.8
|
||||||
buildtype: "96ad197d74-2319b6d45f"
|
|
||||||
packages: ""
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "g++"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
test_cmake: "TRUE"
|
|
||||||
- name: "TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 1"
|
|
||||||
buildtype: "boost"
|
|
||||||
packages: ""
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "g++"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
toolset: "gcc"
|
|
||||||
compiler: "g++"
|
|
||||||
cxxstd: "03,11"
|
cxxstd: "03,11"
|
||||||
- name: "TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 2"
|
os: ubuntu-latest
|
||||||
buildtype: "boost"
|
container: ubuntu:18.04
|
||||||
packages: "g++-4.7"
|
install: g++-4.8-multilib
|
||||||
packages_to_remove: ""
|
address-model: 32,64
|
||||||
os: "ubuntu-16.04"
|
- toolset: gcc-4.9
|
||||||
cxx: "g++-4.7"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
toolset: "gcc"
|
|
||||||
compiler: "g++-4.7"
|
|
||||||
cxxstd: "03,11"
|
cxxstd: "03,11"
|
||||||
- name: "TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 3"
|
os: ubuntu-latest
|
||||||
buildtype: "boost"
|
container: ubuntu:16.04
|
||||||
packages: "g++-4.8"
|
install: g++-4.9-multilib
|
||||||
packages_to_remove: ""
|
address-model: 32,64
|
||||||
os: "ubuntu-16.04"
|
- toolset: gcc-5
|
||||||
cxx: "g++-4.8"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
toolset: "gcc"
|
|
||||||
compiler: "g++-4.8"
|
|
||||||
cxxstd: "03,11"
|
|
||||||
- name: "TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 4"
|
|
||||||
buildtype: "boost"
|
|
||||||
packages: "g++-4.9"
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "g++-4.9"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
toolset: "gcc"
|
|
||||||
compiler: "g++-4.9"
|
|
||||||
cxxstd: "03,11"
|
|
||||||
- name: "TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 5"
|
|
||||||
buildtype: "boost"
|
|
||||||
packages: "g++-5"
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "g++-5"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
toolset: "gcc"
|
|
||||||
compiler: "g++-5"
|
|
||||||
cxxstd: "03,11,14,1z"
|
cxxstd: "03,11,14,1z"
|
||||||
- name: "TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 6"
|
os: ubuntu-latest
|
||||||
buildtype: "boost"
|
container: ubuntu:18.04
|
||||||
packages: "g++-6"
|
install: g++-5-multilib
|
||||||
packages_to_remove: ""
|
address-model: 32,64
|
||||||
os: "ubuntu-16.04"
|
- toolset: gcc-6
|
||||||
cxx: "g++-6"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
toolset: "gcc"
|
|
||||||
compiler: "g++-6"
|
|
||||||
cxxstd: "03,11,14,1z"
|
cxxstd: "03,11,14,1z"
|
||||||
- name: "TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 7"
|
os: ubuntu-latest
|
||||||
buildtype: "boost"
|
container: ubuntu:18.04
|
||||||
packages: "g++-7"
|
install: g++-6-multilib
|
||||||
packages_to_remove: ""
|
address-model: 32,64
|
||||||
os: "ubuntu-16.04"
|
- toolset: gcc-7
|
||||||
cxx: "g++-7"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: ""
|
|
||||||
llvm_ver: ""
|
|
||||||
toolset: "gcc"
|
|
||||||
compiler: "g++-7"
|
|
||||||
cxxstd: "03,11,14,17"
|
cxxstd: "03,11,14,17"
|
||||||
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 8"
|
os: ubuntu-20.04
|
||||||
buildtype: "boost"
|
install: g++-7-multilib
|
||||||
packages: ""
|
address-model: 32,64
|
||||||
packages_to_remove: ""
|
- toolset: gcc-8
|
||||||
os: "ubuntu-16.04"
|
cxxstd: "03,11,14,17,2a"
|
||||||
cxx: "clang++"
|
os: ubuntu-20.04
|
||||||
sources: ""
|
install: g++-8-multilib
|
||||||
llvm_os: ""
|
address-model: 32,64
|
||||||
llvm_ver: ""
|
- toolset: gcc-9
|
||||||
toolset: "clang"
|
cxxstd: "03,11,14,17,2a"
|
||||||
compiler: "clang++"
|
os: ubuntu-20.04
|
||||||
cxxstd: "03,11"
|
install: g++-9-multilib
|
||||||
- name: "TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 9"
|
address-model: 32,64
|
||||||
buildtype: "boost"
|
- toolset: gcc-10
|
||||||
packages: "clang-3.5 libstdc++-4.9-dev"
|
cxxstd: "03,11,14,17,2a"
|
||||||
packages_to_remove: ""
|
os: ubuntu-22.04
|
||||||
os: "ubuntu-16.04"
|
install: g++-10-multilib
|
||||||
cxx: "clang++-3.5"
|
address-model: 32,64
|
||||||
sources: ""
|
- toolset: gcc-11
|
||||||
llvm_os: "precise"
|
cxxstd: "03,11,14,17,20"
|
||||||
llvm_ver: "3.5"
|
os: ubuntu-22.04
|
||||||
toolset: "clang"
|
install: g++-11-multilib
|
||||||
compiler: "clang++-3.5"
|
address-model: 32,64
|
||||||
|
- toolset: gcc-12
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install: g++-12-multilib
|
||||||
|
address-model: 32,64
|
||||||
|
- toolset: gcc-13
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-24.04
|
||||||
|
install: g++-13-multilib
|
||||||
|
address-model: 32,64
|
||||||
|
- toolset: gcc-14
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-24.04
|
||||||
|
install: g++-14-multilib
|
||||||
|
address-model: 32,64
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-3.9
|
||||||
cxxstd: "03,11,14"
|
cxxstd: "03,11,14"
|
||||||
- name: "TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 10"
|
os: ubuntu-latest
|
||||||
buildtype: "boost"
|
container: ubuntu:18.04
|
||||||
packages: "clang-3.6"
|
install: clang-3.9
|
||||||
packages_to_remove: ""
|
- toolset: clang
|
||||||
os: "ubuntu-16.04"
|
compiler: clang++-4.0
|
||||||
cxx: "clang++-3.6"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: "precise"
|
|
||||||
llvm_ver: "3.6"
|
|
||||||
toolset: "clang"
|
|
||||||
compiler: "clang++-3.6"
|
|
||||||
cxxstd: "03,11,14"
|
cxxstd: "03,11,14"
|
||||||
- name: "TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 11"
|
os: ubuntu-latest
|
||||||
buildtype: "boost"
|
container: ubuntu:18.04
|
||||||
packages: "clang-3.7"
|
install: clang-4.0
|
||||||
packages_to_remove: ""
|
- toolset: clang
|
||||||
os: "ubuntu-16.04"
|
compiler: clang++-5.0
|
||||||
cxx: "clang++-3.7"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: "precise"
|
|
||||||
llvm_ver: "3.7"
|
|
||||||
toolset: "clang"
|
|
||||||
compiler: "clang++-3.7"
|
|
||||||
cxxstd: "03,11,14"
|
|
||||||
- name: "TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 12"
|
|
||||||
buildtype: "boost"
|
|
||||||
packages: "clang-3.8 libstdc++-4.9-dev"
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "clang++-3.8"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: "precise"
|
|
||||||
llvm_ver: "3.8"
|
|
||||||
toolset: "clang"
|
|
||||||
compiler: "clang++-3.8"
|
|
||||||
cxxstd: "03,11,14"
|
|
||||||
- name: "TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 13"
|
|
||||||
buildtype: "boost"
|
|
||||||
packages: "clang-3.9 libstdc++-4.9-dev"
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "clang++-3.9"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: "precise"
|
|
||||||
llvm_ver: "3.9"
|
|
||||||
toolset: "clang"
|
|
||||||
compiler: "clang++-3.9"
|
|
||||||
cxxstd: "03,11,14"
|
|
||||||
- name: "TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 14"
|
|
||||||
buildtype: "boost"
|
|
||||||
packages: "clang-4.0"
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "clang++-4.0"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: "xenial"
|
|
||||||
llvm_ver: "4.0"
|
|
||||||
toolset: "clang"
|
|
||||||
compiler: "clang++-4.0"
|
|
||||||
cxxstd: "03,11,14"
|
|
||||||
- name: "TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 15"
|
|
||||||
buildtype: "boost"
|
|
||||||
packages: "clang-5.0"
|
|
||||||
packages_to_remove: ""
|
|
||||||
os: "ubuntu-16.04"
|
|
||||||
cxx: "clang++-5.0"
|
|
||||||
sources: ""
|
|
||||||
llvm_os: "xenial"
|
|
||||||
llvm_ver: "5.0"
|
|
||||||
toolset: "clang"
|
|
||||||
compiler: "clang++-5.0"
|
|
||||||
cxxstd: "03,11,14,1z"
|
cxxstd: "03,11,14,1z"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install: clang-5.0
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-6.0
|
||||||
|
cxxstd: "03,11,14,17"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install: clang-6.0
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-7
|
||||||
|
cxxstd: "03,11,14,17"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install: clang-7
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-8
|
||||||
|
cxxstd: "03,11,14,17"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install: clang-8
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-9
|
||||||
|
cxxstd: "03,11,14,17,2a"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install: clang-9
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-10
|
||||||
|
cxxstd: "03,11,14,17,2a"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-11
|
||||||
|
cxxstd: "03,11,14,17,2a"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-12
|
||||||
|
cxxstd: "03,11,14,17,20"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-13
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install: clang-13
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-14
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install: clang-14
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-15
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install: clang-15
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-16
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-24.04
|
||||||
|
install: clang-16
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-17
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-24.04
|
||||||
|
install: clang-17
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-18
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: ubuntu-24.04
|
||||||
|
install: clang-18
|
||||||
|
- toolset: clang
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: macos-13
|
||||||
|
- toolset: clang
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: macos-14
|
||||||
|
- toolset: clang
|
||||||
|
cxxstd: "03,11,14,17,20,2b"
|
||||||
|
os: macos-15
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{matrix.os}}
|
||||||
container: ${{ matrix.container }}
|
|
||||||
|
container:
|
||||||
|
image: ${{matrix.container}}
|
||||||
|
volumes:
|
||||||
|
- /node20217:/node20217:rw,rshared
|
||||||
|
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check if running in container
|
- name: Setup container environment
|
||||||
if: matrix.container != ''
|
if: matrix.container
|
||||||
run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: linux
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
CXX: ${{ matrix.cxx }}
|
|
||||||
SOURCES: ${{ matrix.sources }}
|
|
||||||
LLVM_OS: ${{ matrix.llvm_os }}
|
|
||||||
LLVM_VER: ${{ matrix.llvm_ver }}
|
|
||||||
PACKAGES: ${{ matrix.packages }}
|
|
||||||
PACKAGES_TO_REMOVE: ${{ matrix.packages_to_remove }}
|
|
||||||
JOB_BUILDTYPE: ${{ matrix.buildtype }}
|
|
||||||
TEST_CMAKE: ${{ matrix.test_cmake }}
|
|
||||||
TOOLSET: ${{ matrix.toolset }}
|
|
||||||
COMPILER: ${{ matrix.compiler }}
|
|
||||||
CXXSTD: ${{ matrix.cxxstd }}
|
|
||||||
TRAVIS_BRANCH: ${{ github.base_ref }}
|
|
||||||
TRAVIS_OS_NAME: "linux"
|
|
||||||
run: |
|
run: |
|
||||||
echo '==================================> SETUP'
|
apt-get update
|
||||||
echo '==================================> PACKAGES'
|
apt-get -y install sudo python3 git g++ curl xz-utils
|
||||||
set -e
|
|
||||||
if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi
|
|
||||||
echo ">>>>> APT: REPO.."
|
|
||||||
for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done
|
|
||||||
|
|
||||||
if test -n "${LLVM_OS}" ; then
|
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
|
||||||
if test -n "${LLVM_VER}" ; then
|
|
||||||
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS}-${LLVM_VER} main"
|
|
||||||
else
|
|
||||||
# Snapshot (i.e. trunk) build of clang
|
|
||||||
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS} main"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo ">>>>> APT: UPDATE.."
|
|
||||||
sudo -E apt-get -o Acquire::Retries=3 update
|
|
||||||
if test -n "${SOURCES}" ; then
|
|
||||||
echo ">>>>> APT: INSTALL SOURCES.."
|
|
||||||
for SOURCE in $SOURCES; do
|
|
||||||
sudo -E apt-add-repository ppa:$SOURCE
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
echo ">>>>> APT: INSTALL ${PACKAGES}.."
|
|
||||||
sudo -E DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y --no-install-suggests --no-install-recommends install ${PACKAGES}
|
|
||||||
|
|
||||||
echo '==================================> INSTALL AND COMPILE'
|
- name: Install nodejs20glibc2.17
|
||||||
set -e
|
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
|
||||||
export TRAVIS_BUILD_DIR=$(pwd)
|
run: |
|
||||||
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
|
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
|
||||||
export VCS_COMMIT_ID=$GITHUB_SHA
|
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
|
||||||
export GIT_COMMIT=$GITHUB_SHA
|
ldd /__e/node20/bin/node
|
||||||
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
|
|
||||||
export USER=$(whoami)
|
|
||||||
export CC=${CC:-gcc}
|
|
||||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
|
||||||
|
|
||||||
if [ "$JOB_BUILDTYPE" == "96ad197d74-2319b6d45f" ]; then
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
echo '==================================> INSTALL'
|
- name: Install packages
|
||||||
|
if: matrix.install
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install ${{matrix.install}}
|
||||||
|
|
||||||
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
- name: Setup Boost
|
||||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/assert.git ../assert
|
run: |
|
||||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/config.git ../config
|
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/core.git ../core
|
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/static_assert.git ../static_assert
|
echo LIBRARY: $LIBRARY
|
||||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/throw_exception.git ../throw_exception
|
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||||
|
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||||
echo '==================================> SCRIPT'
|
echo GITHUB_REF: $GITHUB_REF
|
||||||
|
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||||
mkdir __build__ && cd __build__
|
REF=${REF#refs/heads/}
|
||||||
cmake ../test/test_cmake
|
echo REF: $REF
|
||||||
cmake --build .
|
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||||
|
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||||
elif [ "$JOB_BUILDTYPE" == "boost" ]; then
|
|
||||||
|
|
||||||
echo '==================================> INSTALL'
|
|
||||||
|
|
||||||
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
|
||||||
cd ..
|
cd ..
|
||||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
cd boost-root
|
cd boost-root
|
||||||
git submodule update --init tools/build
|
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||||
git submodule update --init libs/config
|
|
||||||
git submodule update --init tools/boostdep
|
git submodule update --init tools/boostdep
|
||||||
cp -r $TRAVIS_BUILD_DIR/* libs/array
|
python3 tools/boostdep/depinst/depinst.py -I examples $LIBRARY
|
||||||
python tools/boostdep/depinst/depinst.py array
|
|
||||||
./bootstrap.sh
|
./bootstrap.sh
|
||||||
./b2 headers
|
./b2 -d0 headers
|
||||||
|
|
||||||
echo '==================================> SCRIPT'
|
- name: Create user-config.jam
|
||||||
|
if: matrix.compiler
|
||||||
|
run: |
|
||||||
|
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||||
|
|
||||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
- name: Run tests
|
||||||
./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
export ADDRMD=${{matrix.address-model}}
|
||||||
|
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
|
||||||
|
|
||||||
fi
|
windows:
|
||||||
osx:
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 16"
|
- toolset: msvc-14.0
|
||||||
buildtype: "boost"
|
cxxstd: 14,latest
|
||||||
packages: ""
|
addrmd: 32,64
|
||||||
os: "macos-10.15"
|
os: windows-2019
|
||||||
cxx: "clang++"
|
- toolset: msvc-14.2
|
||||||
sources: ""
|
cxxstd: "14,17,20,latest"
|
||||||
llvm_os: ""
|
addrmd: 32,64
|
||||||
llvm_ver: ""
|
os: windows-2019
|
||||||
xcode_version: 11.7
|
- toolset: msvc-14.3
|
||||||
toolset: "clang"
|
cxxstd: "14,17,20,latest"
|
||||||
compiler: "clang++"
|
addrmd: 32,64
|
||||||
cxxstd: "03,11,14,1z"
|
os: windows-2022
|
||||||
|
- toolset: clang-win
|
||||||
|
cxxstd: "14,17,latest"
|
||||||
|
addrmd: 32,64
|
||||||
|
os: windows-2022
|
||||||
|
- toolset: gcc
|
||||||
|
cxxstd: "03,11,14,17,2a"
|
||||||
|
addrmd: 64
|
||||||
|
os: windows-2019
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set DEVELOPER_DIR
|
- name: Setup Boost
|
||||||
if: matrix.xcode_version != ''
|
shell: cmd
|
||||||
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
|
|
||||||
- name: Test DEVELOPER_DIR
|
|
||||||
run: echo $DEVELOPER_DIR
|
|
||||||
|
|
||||||
- name: "osx"
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
CXX: ${{ matrix.cxx }}
|
|
||||||
SOURCES: ${{ matrix.sources }}
|
|
||||||
LLVM_OS: ${{ matrix.llvm_os }}
|
|
||||||
LLVM_VER: ${{ matrix.llvm_ver }}
|
|
||||||
PACKAGES: ${{ matrix.packages }}
|
|
||||||
JOB_BUILDTYPE: ${{ matrix.buildtype }}
|
|
||||||
TEST_CMAKE: ${{ matrix.test_cmake }}
|
|
||||||
TOOLSET: ${{ matrix.toolset }}
|
|
||||||
COMPILER: ${{ matrix.compiler }}
|
|
||||||
CXXSTD: ${{ matrix.cxxstd }}
|
|
||||||
TRAVIS_BRANCH: ${{ github.base_ref }}
|
|
||||||
TRAVIS_OS_NAME: "osx"
|
|
||||||
run: |
|
run: |
|
||||||
echo '==================================> SETUP'
|
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||||
set -e
|
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||||
sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bck
|
echo LIBRARY: %LIBRARY%
|
||||||
echo '==================================> PACKAGES'
|
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||||
echo '==================================> INSTALL AND COMPILE'
|
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||||
set -e
|
echo GITHUB_REF: %GITHUB_REF%
|
||||||
export TRAVIS_BUILD_DIR=$(pwd)
|
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||||
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
|
set BOOST_BRANCH=develop
|
||||||
export VCS_COMMIT_ID=$GITHUB_SHA
|
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||||
export GIT_COMMIT=$GITHUB_SHA
|
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||||
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
|
cd ..
|
||||||
export USER=$(whoami)
|
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
export CC=${CC:-gcc}
|
cd boost-root
|
||||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
python tools/boostdep/depinst/depinst.py -I examples --git_args "--jobs 3" %LIBRARY%
|
||||||
|
cmd /c bootstrap
|
||||||
|
b2 -d0 headers
|
||||||
|
|
||||||
if [ "$JOB_BUILDTYPE" == "boost" ]; then
|
- name: Run tests
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||||
|
|
||||||
echo '==================================> INSTALL'
|
posix-cmake-subdir:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-20.04
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
- os: ubuntu-24.04
|
||||||
|
- os: macos-13
|
||||||
|
- os: macos-14
|
||||||
|
- os: macos-15
|
||||||
|
|
||||||
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
if: matrix.install
|
||||||
|
run: sudo apt-get -y install ${{matrix.install}}
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
run: |
|
||||||
|
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||||
|
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||||
|
echo LIBRARY: $LIBRARY
|
||||||
|
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||||
|
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||||
|
echo GITHUB_REF: $GITHUB_REF
|
||||||
|
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||||
|
REF=${REF#refs/heads/}
|
||||||
|
echo REF: $REF
|
||||||
|
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||||
|
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||||
cd ..
|
cd ..
|
||||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
cd boost-root
|
cd boost-root
|
||||||
git submodule update --init tools/build
|
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||||
git submodule update --init libs/config
|
|
||||||
git submodule update --init tools/boostdep
|
git submodule update --init tools/boostdep
|
||||||
cp -r $TRAVIS_BUILD_DIR/* libs/array
|
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||||
python tools/boostdep/depinst/depinst.py array
|
|
||||||
./bootstrap.sh
|
|
||||||
./b2 headers
|
|
||||||
|
|
||||||
echo '==================================> SCRIPT'
|
- name: Use library with add_subdirectory
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||||
|
mkdir __build__ && cd __build__
|
||||||
|
cmake ..
|
||||||
|
cmake --build .
|
||||||
|
ctest --output-on-failure --no-tests=error
|
||||||
|
|
||||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
posix-cmake-install:
|
||||||
./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-20.04
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
- os: ubuntu-24.04
|
||||||
|
- os: macos-13
|
||||||
|
- os: macos-14
|
||||||
|
- os: macos-15
|
||||||
|
|
||||||
fi
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
if: matrix.install
|
||||||
|
run: sudo apt-get -y install ${{matrix.install}}
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
run: |
|
||||||
|
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||||
|
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||||
|
echo LIBRARY: $LIBRARY
|
||||||
|
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||||
|
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||||
|
echo GITHUB_REF: $GITHUB_REF
|
||||||
|
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||||
|
REF=${REF#refs/heads/}
|
||||||
|
echo REF: $REF
|
||||||
|
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||||
|
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||||
|
cd ..
|
||||||
|
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
mkdir __build__ && cd __build__
|
||||||
|
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
cmake --build . --target install
|
||||||
|
|
||||||
|
- name: Use the installed library
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||||
|
cmake --build .
|
||||||
|
ctest --output-on-failure --no-tests=error
|
||||||
|
|
||||||
|
posix-cmake-test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-20.04
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
- os: ubuntu-24.04
|
||||||
|
- os: macos-13
|
||||||
|
- os: macos-14
|
||||||
|
- os: macos-15
|
||||||
|
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
if: matrix.install
|
||||||
|
run: sudo apt-get -y install ${{matrix.install}}
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
run: |
|
||||||
|
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||||
|
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||||
|
echo LIBRARY: $LIBRARY
|
||||||
|
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||||
|
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||||
|
echo GITHUB_REF: $GITHUB_REF
|
||||||
|
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||||
|
REF=${REF#refs/heads/}
|
||||||
|
echo REF: $REF
|
||||||
|
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||||
|
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||||
|
cd ..
|
||||||
|
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
mkdir __build__ && cd __build__
|
||||||
|
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||||
|
|
||||||
|
- name: Build tests
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
cmake --build . --target tests
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
ctest --output-on-failure --no-tests=error
|
||||||
|
|
||||||
|
windows-cmake-subdir:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-2019
|
||||||
|
- os: windows-2022
|
||||||
|
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||||
|
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||||
|
echo LIBRARY: %LIBRARY%
|
||||||
|
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||||
|
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||||
|
echo GITHUB_REF: %GITHUB_REF%
|
||||||
|
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||||
|
set BOOST_BRANCH=develop
|
||||||
|
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||||
|
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||||
|
cd ..
|
||||||
|
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||||
|
|
||||||
|
- name: Use library with add_subdirectory (Debug)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
|
||||||
|
mkdir __build__ && cd __build__
|
||||||
|
cmake ..
|
||||||
|
cmake --build . --config Debug
|
||||||
|
ctest --output-on-failure --no-tests=error -C Debug
|
||||||
|
|
||||||
|
- name: Use library with add_subdirectory (Release)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
|
||||||
|
cmake --build . --config Release
|
||||||
|
ctest --output-on-failure --no-tests=error -C Release
|
||||||
|
|
||||||
|
windows-cmake-install:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-2019
|
||||||
|
- os: windows-2022
|
||||||
|
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||||
|
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||||
|
echo LIBRARY: %LIBRARY%
|
||||||
|
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||||
|
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||||
|
echo GITHUB_REF: %GITHUB_REF%
|
||||||
|
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||||
|
set BOOST_BRANCH=develop
|
||||||
|
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||||
|
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||||
|
cd ..
|
||||||
|
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
mkdir __build__ && cd __build__
|
||||||
|
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||||
|
|
||||||
|
- name: Install (Debug)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
cmake --build . --target install --config Debug
|
||||||
|
|
||||||
|
- name: Install (Release)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
cmake --build . --target install --config Release
|
||||||
|
|
||||||
|
- name: Use the installed library (Debug)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||||
|
cmake --build . --config Debug
|
||||||
|
ctest --output-on-failure --no-tests=error -C Debug
|
||||||
|
|
||||||
|
- name: Use the installed library (Release)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
|
||||||
|
cmake --build . --config Release
|
||||||
|
ctest --output-on-failure --no-tests=error -C Release
|
||||||
|
|
||||||
|
windows-cmake-test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-2019
|
||||||
|
- os: windows-2022
|
||||||
|
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||||
|
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||||
|
echo LIBRARY: %LIBRARY%
|
||||||
|
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||||
|
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||||
|
echo GITHUB_REF: %GITHUB_REF%
|
||||||
|
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||||
|
set BOOST_BRANCH=develop
|
||||||
|
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||||
|
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||||
|
cd ..
|
||||||
|
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||||
|
git submodule update --init tools/boostdep
|
||||||
|
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
mkdir __build__ && cd __build__
|
||||||
|
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
|
||||||
|
|
||||||
|
- name: Build tests (Debug)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
cmake --build . --target tests --config Debug
|
||||||
|
|
||||||
|
- name: Run tests (Debug)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
ctest --output-on-failure --no-tests=error -C Debug
|
||||||
|
|
||||||
|
- name: Build tests (Release)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
cmake --build . --target tests --config Release
|
||||||
|
|
||||||
|
- name: Run tests (Release)
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/__build__
|
||||||
|
ctest --output-on-failure --no-tests=error -C Release
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
# Copyright 2018 Mike Dev
|
# Generated by `boostdep --cmake array`
|
||||||
|
# Copyright 2020, 2021 Peter Dimov
|
||||||
# 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
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5...3.20)
|
cmake_minimum_required(VERSION 3.5...3.20)
|
||||||
|
|
||||||
project(boost_array VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
project(boost_array VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||||
|
|
||||||
add_library(boost_array INTERFACE)
|
add_library(boost_array INTERFACE)
|
||||||
@ -11,10 +13,16 @@ add_library(Boost::array ALIAS boost_array)
|
|||||||
target_include_directories(boost_array INTERFACE include)
|
target_include_directories(boost_array INTERFACE include)
|
||||||
|
|
||||||
target_link_libraries(boost_array
|
target_link_libraries(boost_array
|
||||||
INTERFACE
|
INTERFACE
|
||||||
Boost::assert
|
Boost::assert
|
||||||
Boost::config
|
Boost::config
|
||||||
Boost::core
|
Boost::core
|
||||||
Boost::static_assert
|
Boost::static_assert
|
||||||
Boost::throw_exception
|
Boost::throw_exception
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||||
|
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
1
doc/.gitignore
vendored
Normal file
1
doc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/html
|
@ -1,19 +1,22 @@
|
|||||||
#~ Copyright Marshall Clow 2013
|
#~ Copyright Marshall Clow 2013
|
||||||
|
#~ Copyright Christian Mazakas 2024
|
||||||
#~ 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)
|
||||||
|
|
||||||
using boostbook ;
|
import asciidoctor ;
|
||||||
|
|
||||||
boostbook standalone
|
html array.html : array.adoc ;
|
||||||
: array.xml
|
|
||||||
: <xsl:param>boost.root=../../../.. ;
|
install html_ : array.html : <location>html ;
|
||||||
|
|
||||||
|
pdf array.pdf : array.adoc ;
|
||||||
|
explicit array.pdf ;
|
||||||
|
|
||||||
|
install pdf_ : array.pdf : <location>pdf ;
|
||||||
|
explicit pdf_ ;
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
alias boostdoc
|
alias boostdoc ;
|
||||||
: array.xml
|
|
||||||
:
|
|
||||||
:
|
|
||||||
: ;
|
|
||||||
explicit boostdoc ;
|
explicit boostdoc ;
|
||||||
alias boostrelease ;
|
alias boostrelease : html_ ;
|
||||||
explicit boostrelease ;
|
explicit boostrelease ;
|
||||||
|
28
doc/array.adoc
Normal file
28
doc/array.adoc
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
////
|
||||||
|
Copyright 2001-2004 Nicolai M. Josuttis
|
||||||
|
Copyright 2012 Marshall Clow
|
||||||
|
Copyright 2024 Christian Mazakas
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
////
|
||||||
|
|
||||||
|
# Boost.Array
|
||||||
|
Nicolai M. Josuttis
|
||||||
|
:toc: left
|
||||||
|
:toclevels: 4
|
||||||
|
:idprefix:
|
||||||
|
:docinfo: private-footer
|
||||||
|
:source-highlighter: rouge
|
||||||
|
:source-language: c++
|
||||||
|
:sectanchors:
|
||||||
|
|
||||||
|
:leveloffset: +1
|
||||||
|
|
||||||
|
include::array/introduction.adoc[]
|
||||||
|
include::array/changes.adoc[]
|
||||||
|
include::array/reference.adoc[]
|
||||||
|
include::array/design_rationale.adoc[]
|
||||||
|
include::array/information.adoc[]
|
||||||
|
include::array/copyright.adoc[]
|
||||||
|
|
||||||
|
:leveloffset: -1
|
639
doc/array.xml
639
doc/array.xml
@ -1,639 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
|
||||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
|
||||||
<library name="Array" dirname="array" id="array" last-revision="$Date$">
|
|
||||||
<libraryinfo>
|
|
||||||
<author>
|
|
||||||
<firstname>Nicolai</firstname>
|
|
||||||
<surname>Josuttis</surname>
|
|
||||||
</author>
|
|
||||||
<maintainer>
|
|
||||||
<firstname>Marshall</firstname>
|
|
||||||
<surname>Clow</surname>
|
|
||||||
</maintainer>
|
|
||||||
|
|
||||||
<copyright>
|
|
||||||
<year>2001</year>
|
|
||||||
<year>2002</year>
|
|
||||||
<year>2003</year>
|
|
||||||
<year>2004</year>
|
|
||||||
<holder>Nicolai M. Josuttis</holder>
|
|
||||||
</copyright>
|
|
||||||
|
|
||||||
<copyright>
|
|
||||||
<year>2012</year>
|
|
||||||
<holder>Marshall Clow</holder>
|
|
||||||
</copyright>
|
|
||||||
|
|
||||||
<legalnotice>
|
|
||||||
<para>Distributed under the Boost Software License, Version 1.0.
|
|
||||||
(See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
|
|
||||||
<ulink
|
|
||||||
url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>)
|
|
||||||
</para>
|
|
||||||
</legalnotice>
|
|
||||||
|
|
||||||
<librarypurpose>STL compliant container wrapper for arrays of constant size</librarypurpose>
|
|
||||||
<librarycategory name="category:containers"/>
|
|
||||||
</libraryinfo>
|
|
||||||
|
|
||||||
<title>Boost.Array</title>
|
|
||||||
|
|
||||||
<section id="array.intro">
|
|
||||||
<title>Introduction</title>
|
|
||||||
|
|
||||||
<using-namespace name="boost"/>
|
|
||||||
<using-class name="array"/>
|
|
||||||
|
|
||||||
<para>The C++ Standard Template Library STL as part of the C++
|
|
||||||
Standard Library provides a framework for processing algorithms on
|
|
||||||
different kind of containers. However, ordinary arrays don't
|
|
||||||
provide the interface of STL containers (although, they provide
|
|
||||||
the iterator interface of STL containers).</para>
|
|
||||||
|
|
||||||
<para>As replacement for ordinary arrays, the STL provides class
|
|
||||||
<code><classname>std::vector</classname></code>. However,
|
|
||||||
<code><classname>std::vector<></classname></code> provides
|
|
||||||
the semantics of dynamic arrays. Thus, it manages data to be able
|
|
||||||
to change the number of elements. This results in some overhead in
|
|
||||||
case only arrays with static size are needed.</para>
|
|
||||||
|
|
||||||
<para>In his book, <emphasis>Generic Programming and the
|
|
||||||
STL</emphasis>, Matthew H. Austern introduces a useful wrapper
|
|
||||||
class for ordinary arrays with static size, called
|
|
||||||
<code>block</code>. It is safer and has no worse performance than
|
|
||||||
ordinary arrays. In <emphasis>The C++ Programming
|
|
||||||
Language</emphasis>, 3rd edition, Bjarne Stroustrup introduces a
|
|
||||||
similar class, called <code>c_array</code>, which I (<ulink
|
|
||||||
url="http://www.josuttis.com">Nicolai Josuttis</ulink>) present
|
|
||||||
slightly modified in my book <emphasis>The C++ Standard Library -
|
|
||||||
A Tutorial and Reference</emphasis>, called
|
|
||||||
<code>carray</code>. This is the essence of these approaches
|
|
||||||
spiced with many feedback from <ulink
|
|
||||||
url="http://www.boost.org">boost</ulink>.</para>
|
|
||||||
|
|
||||||
<para>After considering different names, we decided to name this
|
|
||||||
class simply <code><classname>array</classname></code>.</para>
|
|
||||||
|
|
||||||
<para>Note that this class is suggested to be part of the next
|
|
||||||
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>
|
|
||||||
|
|
||||||
<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
|
|
||||||
but not all of the requirements of "reversible containers" (see
|
|
||||||
Section 23.1, [lib.container.requirements] of the C++
|
|
||||||
Standard). The reasons array is not an reversible STL container is
|
|
||||||
because:
|
|
||||||
<itemizedlist spacing="compact">
|
|
||||||
<listitem><simpara>No constructors are provided.</simpara></listitem>
|
|
||||||
<listitem><simpara>Elements may have an undetermined initial value (see <xref linkend="array.rationale"/>).</simpara></listitem>
|
|
||||||
<listitem><simpara><functionname>swap</functionname>() has no constant complexity.</simpara></listitem>
|
|
||||||
<listitem><simpara><methodname>size</methodname>() is always constant, based on the second template argument of the type.</simpara></listitem>
|
|
||||||
<listitem><simpara>The container provides no allocator support.</simpara></listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that:
|
|
||||||
<itemizedlist spacing="compact">
|
|
||||||
<listitem><simpara><methodname>front</methodname>() and <methodname>back</methodname>() are provided.</simpara></listitem>
|
|
||||||
<listitem><simpara><methodname>operator[]</methodname> and <methodname>at</methodname>() are provided.</simpara></listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<library-reference>
|
|
||||||
<header name="boost/array.hpp">
|
|
||||||
<namespace name="boost">
|
|
||||||
<class name="array">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<purpose><para>STL compliant container wrapper for arrays of constant size</para></purpose>
|
|
||||||
<typedef name="value_type">
|
|
||||||
<type>T</type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="iterator">
|
|
||||||
<type>T*</type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="const_iterator">
|
|
||||||
<type>const T*</type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="reverse_iterator">
|
|
||||||
<type><classname>std::reverse_iterator</classname><iterator></type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="const_reverse_iterator">
|
|
||||||
<type><classname>std::reverse_iterator</classname><const_iterator></type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="reference">
|
|
||||||
<type>T&</type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="const_reference">
|
|
||||||
<type>const T&</type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="size_type">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</typedef>
|
|
||||||
<typedef name="difference_type">
|
|
||||||
<type>std::ptrdiff_t</type>
|
|
||||||
</typedef>
|
|
||||||
|
|
||||||
<static-constant name="static_size">
|
|
||||||
<type>size_type</type>
|
|
||||||
<default>N</default>
|
|
||||||
</static-constant>
|
|
||||||
|
|
||||||
<copy-assignment>
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="U"/>
|
|
||||||
</template>
|
|
||||||
<parameter name="other">
|
|
||||||
<paramtype>const <classname>array</classname><U, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<effects><simpara><code>std::copy(rhs.<methodname>begin</methodname>(),rhs.<methodname>end</methodname>(), <methodname>begin</methodname>())</code></simpara></effects>
|
|
||||||
</copy-assignment>
|
|
||||||
|
|
||||||
<method-group name="iterator support">
|
|
||||||
<overloaded-method name="begin">
|
|
||||||
<signature>
|
|
||||||
<type>iterator</type>
|
|
||||||
</signature>
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>iterator for the first element</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<overloaded-method name="end">
|
|
||||||
<signature>
|
|
||||||
<type>iterator</type>
|
|
||||||
</signature>
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>iterator for position after the last element</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</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 name="reverse iterator support">
|
|
||||||
<overloaded-method name="rbegin">
|
|
||||||
<signature>
|
|
||||||
<type>reverse_iterator</type>
|
|
||||||
</signature>
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_reverse_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>reverse iterator for the first element of reverse iteration</simpara></returns>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<overloaded-method name="rend">
|
|
||||||
<signature>
|
|
||||||
<type>reverse_iterator</type>
|
|
||||||
</signature>
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_reverse_iterator</type>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>reverse iterator for position after the last element in reverse iteration</simpara></returns>
|
|
||||||
</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 name="capacity">
|
|
||||||
<method name="size">
|
|
||||||
<type>size_type</type>
|
|
||||||
<returns><simpara><code>N</code></simpara></returns>
|
|
||||||
</method>
|
|
||||||
<method name="empty">
|
|
||||||
<type>bool</type>
|
|
||||||
<returns><simpara><code>N==0</code></simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</method>
|
|
||||||
<method name="max_size">
|
|
||||||
<type>size_type</type>
|
|
||||||
<returns><simpara><code>N</code></simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</method>
|
|
||||||
</method-group>
|
|
||||||
|
|
||||||
<method-group name="element access">
|
|
||||||
<overloaded-method name="operator[]">
|
|
||||||
<signature>
|
|
||||||
<type>reference</type>
|
|
||||||
<parameter name="i">
|
|
||||||
<paramtype>size_type</paramtype>
|
|
||||||
</parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_reference</type>
|
|
||||||
<parameter name="i">
|
|
||||||
<paramtype>size_type</paramtype>
|
|
||||||
</parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<requires><simpara><code>i < N</code></simpara></requires>
|
|
||||||
<returns><simpara>element with index <code>i</code></simpara></returns>
|
|
||||||
<throws><simpara>will not throw.</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<overloaded-method name="at">
|
|
||||||
<signature>
|
|
||||||
<type>reference</type>
|
|
||||||
<parameter name="i">
|
|
||||||
<paramtype>size_type</paramtype>
|
|
||||||
</parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_reference</type>
|
|
||||||
<parameter name="i">
|
|
||||||
<paramtype>size_type</paramtype>
|
|
||||||
</parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<returns><simpara>element with index <code>i</code></simpara></returns>
|
|
||||||
<throws><simpara><code><classname>std::range_error</classname></code> if <code>i >= N</code></simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<overloaded-method name="front">
|
|
||||||
<signature>
|
|
||||||
<type>reference</type>
|
|
||||||
</signature>
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_reference</type>
|
|
||||||
</signature>
|
|
||||||
<requires><simpara><code>N > 0</code></simpara></requires>
|
|
||||||
<returns><simpara>the first element</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<overloaded-method name="back">
|
|
||||||
<signature>
|
|
||||||
<type>reference</type>
|
|
||||||
</signature>
|
|
||||||
<signature cv="const">
|
|
||||||
<type>const_reference</type>
|
|
||||||
</signature>
|
|
||||||
<requires><simpara><code>N > 0</code></simpara></requires>
|
|
||||||
<returns><simpara>the last element</simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</overloaded-method>
|
|
||||||
|
|
||||||
<method name="data" cv="const">
|
|
||||||
<type>const T*</type>
|
|
||||||
<returns><simpara><code>elems</code></simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="c_array">
|
|
||||||
<type>T*</type>
|
|
||||||
<returns><simpara><code>elems</code></simpara></returns>
|
|
||||||
<throws><simpara>will not throw</simpara></throws>
|
|
||||||
</method>
|
|
||||||
</method-group>
|
|
||||||
|
|
||||||
<method-group name="modifiers">
|
|
||||||
<method name="swap">
|
|
||||||
<type>void</type>
|
|
||||||
<parameter name="other">
|
|
||||||
<paramtype><classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<effects><simpara><code>std::swap_ranges(<methodname>begin</methodname>(), <methodname>end</methodname>(), other.<methodname>begin</methodname>())</code></simpara></effects>
|
|
||||||
<complexity><simpara>linear in <code>N</code></simpara></complexity>
|
|
||||||
</method>
|
|
||||||
<method name="assign">
|
|
||||||
<type>void</type>
|
|
||||||
<parameter name="value">
|
|
||||||
<paramtype>const T&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<effects><simpara><code>std::fill_n(<methodname>begin</methodname>(), N, value)</code></simpara></effects>
|
|
||||||
</method>
|
|
||||||
</method-group>
|
|
||||||
|
|
||||||
<data-member name="elems[N]"> <!-- HACK -->
|
|
||||||
<type>T</type>
|
|
||||||
</data-member>
|
|
||||||
|
|
||||||
<free-function-group name="specialized algorithms">
|
|
||||||
<function name="swap">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>void</type>
|
|
||||||
|
|
||||||
<parameter name="x">
|
|
||||||
<paramtype><classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="y">
|
|
||||||
<paramtype><classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
|
|
||||||
<effects><simpara><code>x.<methodname>swap</methodname>(y)</code></simpara></effects>
|
|
||||||
<throws><simpara>will not throw.</simpara></throws>
|
|
||||||
</function>
|
|
||||||
</free-function-group>
|
|
||||||
|
|
||||||
<free-function-group name="comparisons">
|
|
||||||
<function name="operator==">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>bool</type>
|
|
||||||
|
|
||||||
<parameter name="x">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="y">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
|
|
||||||
<returns><simpara><code>std::equal(x.<methodname>begin</methodname>(), x.<methodname>end</methodname>(), y.<methodname>begin</methodname>())</code></simpara>
|
|
||||||
</returns>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="operator!=">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>bool</type>
|
|
||||||
|
|
||||||
<parameter name="x">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="y">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
|
|
||||||
<returns><simpara><code>!(x == y)</code></simpara>
|
|
||||||
</returns>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="operator<">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>bool</type>
|
|
||||||
|
|
||||||
<parameter name="x">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="y">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
|
|
||||||
<returns><simpara><code>std::lexicographical_compare(x.<methodname>begin</methodname>(), x.<methodname>end</methodname>(), y.<methodname>begin</methodname>(), y.<methodname>end</methodname>())</code></simpara>
|
|
||||||
</returns>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="operator>">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>bool</type>
|
|
||||||
|
|
||||||
<parameter name="x">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="y">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
|
|
||||||
<returns><simpara><code>y < x</code></simpara></returns>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="operator<=">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>bool</type>
|
|
||||||
|
|
||||||
<parameter name="x">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="y">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
|
|
||||||
<returns><simpara><code>!(y < x)</code></simpara></returns>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="operator>=">
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
<template-nontype-parameter name="N">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
</template-nontype-parameter>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<type>bool</type>
|
|
||||||
|
|
||||||
<parameter name="x">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="y">
|
|
||||||
<paramtype>const <classname>array</classname><T, N>&</paramtype>
|
|
||||||
</parameter>
|
|
||||||
|
|
||||||
<returns><simpara><code>!(x < y)</code></simpara></returns>
|
|
||||||
</function>
|
|
||||||
</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>
|
|
||||||
</namespace>
|
|
||||||
</header>
|
|
||||||
</library-reference>
|
|
||||||
|
|
||||||
<section id="array.rationale">
|
|
||||||
<title>Design Rationale</title>
|
|
||||||
|
|
||||||
<para>There was an important design tradeoff regarding the
|
|
||||||
constructors: We could implement array as an "aggregate" (see
|
|
||||||
Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would
|
|
||||||
mean:
|
|
||||||
<itemizedlist>
|
|
||||||
<listitem><simpara>An array can be initialized with a
|
|
||||||
brace-enclosing, comma-separated list of initializers for the
|
|
||||||
elements of the container, written in increasing subscript
|
|
||||||
order:</simpara>
|
|
||||||
|
|
||||||
<programlisting><classname>boost::array</classname><int,4> a = { { 1, 2, 3 } };</programlisting>
|
|
||||||
|
|
||||||
<simpara>Note that if there are fewer elements in the
|
|
||||||
initializer list, then each remaining element gets
|
|
||||||
default-initialized (thus, it has a defined value).</simpara>
|
|
||||||
</listitem></itemizedlist></para>
|
|
||||||
|
|
||||||
<para>However, this approach has its drawbacks: <emphasis
|
|
||||||
role="bold"> passing no initializer list means that the elements
|
|
||||||
have an indetermined initial value</emphasis>, because the rule says
|
|
||||||
that aggregates may have:
|
|
||||||
<itemizedlist>
|
|
||||||
<listitem><simpara>No user-declared constructors.</simpara></listitem>
|
|
||||||
<listitem><simpara>No private or protected non-static data members.</simpara></listitem>
|
|
||||||
<listitem><simpara>No base classes.</simpara></listitem>
|
|
||||||
<listitem><simpara>No virtual functions.</simpara></listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>Nevertheless, The current implementation uses this approach.</para>
|
|
||||||
|
|
||||||
<para>Note that for standard conforming compilers it is possible to
|
|
||||||
use fewer braces (according to 8.5.1 (11) of the Standard). That is,
|
|
||||||
you can initialize an array as follows:</para>
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
<classname>boost::array</classname><int,4> a = { 1, 2, 3 };
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
<para>I'd appreciate any constructive feedback. <emphasis
|
|
||||||
role="bold">Please note: I don't have time to read all boost
|
|
||||||
mails. Thus, to make sure that feedback arrives to me, please send
|
|
||||||
me a copy of each mail regarding this class.</emphasis></para>
|
|
||||||
|
|
||||||
<para>The code is provided "as is" without expressed or implied
|
|
||||||
warranty.</para>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="array.more.info">
|
|
||||||
<title>For more information...</title>
|
|
||||||
<para>To find more details about using ordinary arrays in C++ and
|
|
||||||
the framework of the STL, see e.g.
|
|
||||||
|
|
||||||
<literallayout>The C++ Standard Library - A Tutorial and Reference
|
|
||||||
by Nicolai M. Josuttis
|
|
||||||
Addison Wesley Longman, 1999
|
|
||||||
ISBN 0-201-37926-0</literallayout>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para><ulink url="http://www.josuttis.com/">Home Page of Nicolai
|
|
||||||
Josuttis</ulink></para>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="array.ack">
|
|
||||||
<title>Acknowledgements</title>
|
|
||||||
|
|
||||||
<para>Doug Gregor ported the documentation to the BoostBook format.</para>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Notes:
|
|
||||||
empty() should return N != 0
|
|
||||||
size(), empty(), max_size() should be const
|
|
||||||
-->
|
|
||||||
|
|
||||||
</library>
|
|
16
doc/array/changes.adoc
Normal file
16
doc/array/changes.adoc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
////
|
||||||
|
Copyright 2025 Peter Dimov
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
////
|
||||||
|
|
||||||
|
[#changes]
|
||||||
|
# Revision History
|
||||||
|
:toc:
|
||||||
|
:toc-title:
|
||||||
|
:idprefix:
|
||||||
|
|
||||||
|
## Changes in 1.88.0
|
||||||
|
|
||||||
|
* Converted documentation to AsciiDoc (Christian Mazakas).
|
||||||
|
* Added `noexcept` and `constexpr` as appropriate.
|
15
doc/array/copyright.adoc
Normal file
15
doc/array/copyright.adoc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
////
|
||||||
|
Copyright 2024 Christian Mazakas
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
////
|
||||||
|
|
||||||
|
[#copyright]
|
||||||
|
# Copyright and License
|
||||||
|
:idprefix: copyright
|
||||||
|
|
||||||
|
Copyright (C) 2001-2004 Nicolai M. Josuttis
|
||||||
|
|
||||||
|
Copyright (C) 2012 Marshall Clow
|
||||||
|
|
||||||
|
Distributed under the https://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].
|
39
doc/array/design_rationale.adoc
Normal file
39
doc/array/design_rationale.adoc
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
////
|
||||||
|
Copyright 2001-2004 Nicolai M. Josuttis
|
||||||
|
Copyright 2012 Marshall Clow
|
||||||
|
Copyright 2024 Christian Mazakas
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
////
|
||||||
|
|
||||||
|
[#design]
|
||||||
|
# Design Rationale
|
||||||
|
:idprefix: design_
|
||||||
|
:cpp: C++
|
||||||
|
|
||||||
|
There was an important design tradeoff regarding the constructors: We could implement array as an "aggregate" (see Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would mean:
|
||||||
|
|
||||||
|
* An array can be initialized with a brace-enclosing, comma-separated list of initializers for the elements of the container, written in increasing subscript order:
|
||||||
|
+
|
||||||
|
--
|
||||||
|
```cpp
|
||||||
|
boost::array<int,4> a = { { 1, 2, 3 } };
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that if there are fewer elements in the initializer list, then each remaining element gets default-initialized (thus, it has a defined value).
|
||||||
|
--
|
||||||
|
|
||||||
|
However, this approach has its drawbacks: **passing no initializer list means that the elements have an indetermined initial value**, because the rule says that aggregates may have:
|
||||||
|
|
||||||
|
* No user-declared constructors.
|
||||||
|
* No private or protected non-static data members.
|
||||||
|
* No base classes.
|
||||||
|
* No virtual functions.
|
||||||
|
|
||||||
|
Nevertheless, the current implementation uses this approach.
|
||||||
|
|
||||||
|
Note that for standard conforming compilers it is possible to use fewer braces (according to 8.5.1 (11) of the Standard). That is, you can initialize an array as follows:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
boost::array<int,4> a = { 1, 2, 3 };
|
||||||
|
```
|
22
doc/array/information.adoc
Normal file
22
doc/array/information.adoc
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
////
|
||||||
|
Copyright 2001-2004 Nicolai M. Josuttis
|
||||||
|
Copyright 2012 Marshall Clow
|
||||||
|
Copyright 2024 Christian Mazakas
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
////
|
||||||
|
|
||||||
|
[#information]
|
||||||
|
# For more information...
|
||||||
|
:idprefix: information_
|
||||||
|
:cpp: C++
|
||||||
|
|
||||||
|
To find more details about using ordinary arrays in C++ and the framework of the STL, see e.g.
|
||||||
|
|
||||||
|
The C++ Standard Library - A Tutorial and Reference +
|
||||||
|
by Nicolai M. Josuttis +
|
||||||
|
Addison Wesley Longman, 1999 +
|
||||||
|
ISBN 0-201-37926-0
|
||||||
|
|
||||||
|
|
||||||
|
http://www.josuttis.com/[Home Page of Nicolai Josuttis]
|
44
doc/array/introduction.adoc
Normal file
44
doc/array/introduction.adoc
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
////
|
||||||
|
Copyright 2001-2004 Nicolai M. Josuttis
|
||||||
|
Copyright 2012 Marshall Clow
|
||||||
|
Copyright 2024 Christian Mazakas
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
////
|
||||||
|
|
||||||
|
[#introduction]
|
||||||
|
# Introduction
|
||||||
|
:idprefix: introduction_
|
||||||
|
:cpp: C++
|
||||||
|
|
||||||
|
The {cpp} Standard Template Library STL as part of the {cpp} Standard Library provides a framework for processing algorithms on different kind of containers.
|
||||||
|
However, ordinary arrays don't provide the interface of STL containers (although, they provide the iterator interface of STL containers).
|
||||||
|
|
||||||
|
As replacement for ordinary arrays, the STL provides class `std::vector`.
|
||||||
|
However, `std::vector<>` provides the semantics of dynamic arrays.
|
||||||
|
Thus, it manages data to be able to change the number of elements.
|
||||||
|
This results in some overhead in case only arrays with static size are needed.
|
||||||
|
|
||||||
|
In his book, _Generic Programming and the STL_, Matthew H. Austern introduces a useful wrapper class for ordinary arrays with static size, called `block`.
|
||||||
|
It is safer and has no worse performance than ordinary arrays.
|
||||||
|
In _The {cpp} Programming Language_, 3rd edition, Bjarne Stroustrup introduces a similar class, called c_array, which I (http://www.josuttis.com/[Nicolai Josuttis]) present slightly modified in my book _The {cpp} Standard Library - A Tutorial and Reference_, called `carray`.
|
||||||
|
This is the essence of these approaches spiced with many feedback from https://www.boost.org/[Boost].
|
||||||
|
|
||||||
|
After considering different names, we decided to name this class simply `array`.
|
||||||
|
|
||||||
|
Note that this class is suggested to be part of the next Technical Report, which will extend the {cpp} Standard (see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm).
|
||||||
|
|
||||||
|
Update: `std::array` is (as of {cpp}11) part of the {cpp} standard. The differences between `boost::array` and `std::array` are minimal. If you are using {cpp}11, you should consider using `std::array` instead of `boost::array`.
|
||||||
|
|
||||||
|
Class `array` fulfills most but not all of the requirements of "reversible containers" (see Section 23.1, [lib.container.requirements] of the {cpp} Standard). The reasons array is not an reversible STL container is because:
|
||||||
|
|
||||||
|
* No constructors are provided.
|
||||||
|
* Elements may have an undetermined initial value (see the <<design, section called "Design Rationale">>).
|
||||||
|
* `swap()` has no constant complexity.
|
||||||
|
* `size()` is always constant, based on the second template argument of the type.
|
||||||
|
* The container provides no allocator support.
|
||||||
|
|
||||||
|
It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the {cpp} Standard), except that:
|
||||||
|
|
||||||
|
* `front()` and `back()` are provided.
|
||||||
|
* `operator[]` and `at()` are provided.
|
405
doc/array/reference.adoc
Normal file
405
doc/array/reference.adoc
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
////
|
||||||
|
Copyright 2001-2004 Nicolai M. Josuttis
|
||||||
|
Copyright 2012 Marshall Clow
|
||||||
|
Copyright 2024 Christian Mazakas
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
////
|
||||||
|
|
||||||
|
[#reference]
|
||||||
|
# Reference
|
||||||
|
:idprefix: reference_
|
||||||
|
:cpp: C++
|
||||||
|
|
||||||
|
## Header <boost/array.hpp>
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
namespace boost {
|
||||||
|
|
||||||
|
template<typename T, std::size_t N> class array;
|
||||||
|
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
void swap(array<T, N>&, array<T, N>&);
|
||||||
|
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator==(const array<T, N>&, const array<T, N>&);
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator!=(const array<T, N>&, const array<T, N>&);
|
||||||
|
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator<(const array<T, N>&, const array<T, N>&);
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator>(const array<T, N>&, const array<T, N>&);
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator<=(const array<T, N>&, const array<T, N>&);
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator>=(const array<T, N>&, const array<T, N>&);
|
||||||
|
|
||||||
|
template<std::size_t Idx, typename T, std::size_t N>
|
||||||
|
constexpr T& get(array<T, N>&) noexcept;
|
||||||
|
template<std::size_t Idx, typename T, std::size_t N>
|
||||||
|
constexpr const T& get(const array<T, N>&) noexcept;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Class template array
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// In header: <boost/array.hpp>
|
||||||
|
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
class array {
|
||||||
|
public:
|
||||||
|
|
||||||
|
// types
|
||||||
|
|
||||||
|
typedef T value_type;
|
||||||
|
typedef T* iterator;
|
||||||
|
typedef const T* const_iterator;
|
||||||
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
typedef T& reference;
|
||||||
|
typedef const T& const_reference;
|
||||||
|
typedef std::size_t size_type;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
|
||||||
|
// static constants
|
||||||
|
|
||||||
|
static const size_type static_size = N;
|
||||||
|
|
||||||
|
// construct/copy/destroy
|
||||||
|
|
||||||
|
template<typename U> array& operator=(const array<U, N>&);
|
||||||
|
|
||||||
|
// iterator support
|
||||||
|
|
||||||
|
constexpr iterator begin() noexcept;
|
||||||
|
constexpr const_iterator begin() const noexcept;
|
||||||
|
constexpr const_iterator cbegin() const noexcept;
|
||||||
|
|
||||||
|
constexpr iterator end() noexcept;
|
||||||
|
constexpr const_iterator end() const noexcept;
|
||||||
|
constexpr const_iterator cend() const noexcept;
|
||||||
|
|
||||||
|
// reverse iterator support
|
||||||
|
|
||||||
|
reverse_iterator rbegin() noexcept;
|
||||||
|
const_reverse_iterator rbegin() const noexcept;
|
||||||
|
const_reverse_iterator crbegin() const noexcept;
|
||||||
|
|
||||||
|
reverse_iterator rend() noexcept;
|
||||||
|
const_reverse_iterator rend() const noexcept;
|
||||||
|
const_reverse_iterator crend() const noexcept;
|
||||||
|
|
||||||
|
// capacity
|
||||||
|
|
||||||
|
static constexpr size_type size() noexcept;
|
||||||
|
static constexpr bool empty() noexcept;
|
||||||
|
static constexpr size_type max_size() noexcept;
|
||||||
|
|
||||||
|
// element access
|
||||||
|
|
||||||
|
constexpr reference operator[](size_type);
|
||||||
|
constexpr const_reference operator[](size_type) const;
|
||||||
|
|
||||||
|
constexpr reference at(size_type);
|
||||||
|
constexpr const_reference at(size_type) const;
|
||||||
|
|
||||||
|
constexpr reference front();
|
||||||
|
constexpr const_reference front() const;
|
||||||
|
|
||||||
|
constexpr reference back();
|
||||||
|
constexpr const_reference back() const;
|
||||||
|
|
||||||
|
constexpr T* data() noexcept;
|
||||||
|
constexpr const T* data() const noexcept;
|
||||||
|
|
||||||
|
T* c_array() noexcept; // deprecated
|
||||||
|
|
||||||
|
// modifiers
|
||||||
|
|
||||||
|
swap(array<T, N>&);
|
||||||
|
|
||||||
|
constexpr void fill(const T&);
|
||||||
|
void assign(const T&); // deprecated
|
||||||
|
|
||||||
|
// public data members
|
||||||
|
T elems[N];
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Construct/Copy/Destroy
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename U> array& operator=(const array<U, N>& other);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Effects: :: `std::copy(rhs.begin(), rhs.end(), begin())`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Iterator Support
|
||||||
|
|
||||||
|
```
|
||||||
|
constexpr iterator begin() noexcept;
|
||||||
|
constexpr const_iterator begin() const noexcept;
|
||||||
|
constexpr const_iterator cbegin() const noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `data()`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
constexpr iterator end() noexcept;
|
||||||
|
constexpr const_iterator end() const noexcept;
|
||||||
|
constexpr const_iterator cend() const noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `data() + size()`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Reverse Iterator Support
|
||||||
|
|
||||||
|
```
|
||||||
|
reverse_iterator rbegin() noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `reverse_iterator(end())`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
const_reverse_iterator rbegin() const noexcept;
|
||||||
|
const_reverse_iterator crbegin() const noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `const_reverse_iterator(end())`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
reverse_iterator rend() noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `reverse_iterator(begin())`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
const_reverse_iterator rend() const noexcept;
|
||||||
|
const_reverse_iterator crend() const noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `const_reverse_iterator(begin())`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Capacity
|
||||||
|
|
||||||
|
```
|
||||||
|
static constexpr size_type size() noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `N`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
static constexpr bool empty() noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `N == 0`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
static constexpr size_type max_size() noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `N`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Element Access
|
||||||
|
|
||||||
|
```
|
||||||
|
constexpr reference operator[](size_type i);
|
||||||
|
constexpr const_reference operator[](size_type i) const;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Requires: :: `i < N`.
|
||||||
|
Returns: :: `elems[i]`.
|
||||||
|
Throws: :: nothing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
constexpr reference at(size_type i);
|
||||||
|
constexpr const_reference at(size_type i) const;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `elems[i]`.
|
||||||
|
Throws: :: `std::out_of_range` if `i >= N`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
constexpr reference front();
|
||||||
|
constexpr const_reference front() const;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Requires: :: `N > 0`.
|
||||||
|
Returns: :: `elems[0]`.
|
||||||
|
Throws: :: nothing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
constexpr reference back();
|
||||||
|
constexpr const_reference back() const;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Requires: :: `N > 0`.
|
||||||
|
Returns: :: `elems[N-1]`.
|
||||||
|
Throws: :: nothing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
constexpr T* data() noexcept;
|
||||||
|
constexpr const T* data() const noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `elems`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
T* c_array() noexcept; // deprecated
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `data()`.
|
||||||
|
Remarks: :: This function is deprecated. Use `data()` instead.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Modifiers
|
||||||
|
|
||||||
|
```
|
||||||
|
void swap(array<T, N>& other);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Effects: :: `std::swap(elems, other.elems)`.
|
||||||
|
Complexity: :: linear in `N`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
void fill(const T& value);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Effects: :: for each `i` in `[0..N)`, performs `elems[i] = value;`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
void assign(const T& value); // deprecated
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Effects: :: `fill(value)`.
|
||||||
|
Remarks: :: An obsolete and deprecated spelling of `fill`. Use `fill` instead.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Specialized Algorithms
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
void swap(array<T, N>& x, array<T, N>& y);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Effects: :: `x.swap(y)`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Comparisons
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator==(const array<T, N>& x, const array<T, N>& y);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `std::equal(x.begin(), x.end(), y.begin())`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator!=(const array<T, N>& x, const array<T, N>& y);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `!(x == y)`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator<(const array<T, N>& x, const array<T, N>& y);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end())`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator>(const array<T, N>& x, const array<T, N>& y);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `y < x`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator<=(const array<T, N>& x, const array<T, N>& y);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `!(y < x)`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr bool operator>=(const array<T, N>& x, const array<T, N>& y);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Returns: :: `!(x < y)`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Specializations
|
||||||
|
|
||||||
|
```
|
||||||
|
template<std::size_t Idx, typename T, std::size_t N>
|
||||||
|
constexpr T& get(array<T, N>& arr) noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Mandates: :: `Idx < N`.
|
||||||
|
Returns: :: `arr[Idx]`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
template<std::size_t Idx, typename T, std::size_t N>
|
||||||
|
constexpr const T& get(const array<T, N>& arr) noexcept;
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Mandates: :: `Idx < N`.
|
||||||
|
Returns: :: `arr[Idx]`.
|
||||||
|
|
||||||
|
---
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef BOOST_ARRAY_HPP_INCLUDED
|
||||||
|
#define BOOST_ARRAY_HPP_INCLUDED
|
||||||
|
|
||||||
/* The following code declares class array,
|
/* The following code declares class array,
|
||||||
* an STL container (as wrapper) for arrays of constant size.
|
* an STL container (as wrapper) for arrays of constant size.
|
||||||
*
|
*
|
||||||
@ -28,31 +31,24 @@
|
|||||||
*
|
*
|
||||||
* Jan 29, 2004
|
* Jan 29, 2004
|
||||||
*/
|
*/
|
||||||
#ifndef BOOST_ARRAY_HPP
|
|
||||||
#define BOOST_ARRAY_HPP
|
|
||||||
|
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||||
# pragma warning(push)
|
# 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:4510) // boost::array<T,N>' : default constructor could not be generated
|
# pragma warning(disable:4512) // boost::array<T,N>' : assignment operator could not be generated
|
||||||
# pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required
|
# pragma warning(disable:4610) // class 'boost::array<T,N>' can never be instantiated - user defined constructor required
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <iterator>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/swap.hpp>
|
|
||||||
|
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <algorithm>
|
#include <iterator>
|
||||||
|
#include <stdexcept>
|
||||||
// FIXES for broken compilers
|
#include <utility>
|
||||||
#include <boost/config.hpp>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
@ -72,114 +68,124 @@ namespace boost {
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
|
||||||
// iterator support
|
// iterator support
|
||||||
iterator begin() { return elems; }
|
BOOST_CXX14_CONSTEXPR iterator begin() BOOST_NOEXCEPT { return elems; }
|
||||||
const_iterator begin() const { return elems; }
|
BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT { return elems; }
|
||||||
const_iterator cbegin() const { return elems; }
|
BOOST_CONSTEXPR const_iterator cbegin() const BOOST_NOEXCEPT { return elems; }
|
||||||
|
|
||||||
iterator end() { return elems+N; }
|
BOOST_CXX14_CONSTEXPR iterator end() BOOST_NOEXCEPT { return elems+N; }
|
||||||
const_iterator end() const { return elems+N; }
|
BOOST_CONSTEXPR const_iterator end() const BOOST_NOEXCEPT { return elems+N; }
|
||||||
const_iterator cend() const { return elems+N; }
|
BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return elems+N; }
|
||||||
|
|
||||||
// reverse iterator support
|
// reverse iterator support
|
||||||
#if !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)
|
|
||||||
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;
|
|
||||||
typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); }
|
||||||
const_reverse_iterator rbegin() const {
|
const_reverse_iterator rbegin() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crbegin() const {
|
const_reverse_iterator crbegin() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
reverse_iterator rend() BOOST_NOEXCEPT { return reverse_iterator(begin()); }
|
||||||
const_reverse_iterator rend() const {
|
const_reverse_iterator rend() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crend() const {
|
const_reverse_iterator crend() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
// operator[]
|
// operator[]
|
||||||
reference operator[](size_type i)
|
BOOST_CXX14_CONSTEXPR reference operator[](size_type i)
|
||||||
{
|
{
|
||||||
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const
|
#if !BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
{
|
BOOST_CONSTEXPR
|
||||||
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
#endif
|
||||||
|
const_reference operator[](size_type i) const
|
||||||
|
{
|
||||||
|
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// at() with range check
|
// at() with range check
|
||||||
reference at(size_type i) { return rangecheck(i), elems[i]; }
|
BOOST_CXX14_CONSTEXPR reference at(size_type i) { return rangecheck(i), elems[i]; }
|
||||||
/*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; }
|
BOOST_CONSTEXPR const_reference at(size_type i) const { return rangecheck(i), elems[i]; }
|
||||||
|
|
||||||
// front() and back()
|
// front() and back()
|
||||||
reference front()
|
BOOST_CXX14_CONSTEXPR reference front()
|
||||||
{
|
|
||||||
return elems[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_CONSTEXPR const_reference front() const
|
|
||||||
{
|
{
|
||||||
return elems[0];
|
return elems[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
reference back()
|
BOOST_CONSTEXPR const_reference front() const
|
||||||
{
|
{
|
||||||
return elems[N-1];
|
return elems[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CONSTEXPR const_reference back() const
|
BOOST_CXX14_CONSTEXPR reference back()
|
||||||
{
|
{
|
||||||
return elems[N-1];
|
return elems[N-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_CONSTEXPR const_reference back() const
|
||||||
|
{
|
||||||
|
return elems[N-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// size is constant
|
// size is constant
|
||||||
static BOOST_CONSTEXPR size_type size() { return N; }
|
static BOOST_CONSTEXPR size_type size() BOOST_NOEXCEPT { return N; }
|
||||||
static BOOST_CONSTEXPR bool empty() { return false; }
|
static BOOST_CONSTEXPR bool empty() BOOST_NOEXCEPT { return false; }
|
||||||
static BOOST_CONSTEXPR size_type max_size() { return N; }
|
static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return N; }
|
||||||
enum { static_size = N };
|
enum { static_size = N };
|
||||||
|
|
||||||
// swap (note: linear complexity)
|
// swap (note: linear complexity)
|
||||||
void swap (array<T,N>& y) {
|
BOOST_CXX14_CONSTEXPR void swap (array<T,N>& y)
|
||||||
for (size_type i = 0; i < N; ++i)
|
{
|
||||||
boost::swap(elems[i],y.elems[i]);
|
std::swap( elems, y.elems );
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct access to data (read-only)
|
// direct access to data
|
||||||
const T* data() const { return elems; }
|
BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return elems; }
|
||||||
T* data() { return elems; }
|
BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return elems; }
|
||||||
|
|
||||||
// use array as C array (direct read/write access to data)
|
// obsolete
|
||||||
T* c_array() { return elems; }
|
BOOST_DEPRECATED( "please use `data()` instead" )
|
||||||
|
T* c_array() BOOST_NOEXCEPT { return elems; }
|
||||||
|
|
||||||
// assignment with type conversion
|
// assignment with type conversion
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
array<T,N>& operator= (const array<T2,N>& rhs) {
|
array<T,N>& operator= (const array<T2,N>& rhs)
|
||||||
std::copy(rhs.begin(),rhs.end(), begin());
|
{
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
elems[ i ] = rhs.elems[ i ];
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign one value to all elements
|
// fill with one value
|
||||||
void assign (const T& value) { fill ( value ); } // A synonym for fill
|
BOOST_CXX14_CONSTEXPR void fill (const T& value)
|
||||||
void fill (const T& value)
|
|
||||||
{
|
{
|
||||||
std::fill_n(begin(),size(),value);
|
// using elems[ 0 ] as a temporary copy
|
||||||
|
// avoids the aliasing opportunity betw.
|
||||||
|
// `value` and `elems`
|
||||||
|
|
||||||
|
elems[ 0 ] = value;
|
||||||
|
|
||||||
|
for( std::size_t i = 1; i < N; ++i )
|
||||||
|
{
|
||||||
|
elems[ i ] = elems[ 0 ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// an obsolete synonym for fill
|
||||||
|
BOOST_DEPRECATED( "please use `fill` instead" )
|
||||||
|
void assign (const T& value) { fill ( 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 BOOST_CONSTEXPR bool rangecheck (size_type i) {
|
||||||
return i >= size() ? boost::throw_exception(std::out_of_range ("array<>: index out of range")), true : true;
|
return i >= size() ? boost::throw_exception(std::out_of_range ("array<>: index out of range")), true : true;
|
||||||
@ -201,42 +207,31 @@ 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() BOOST_NOEXCEPT { return iterator( reinterpret_cast< T * >( this ) ); }
|
||||||
const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
const_iterator begin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||||
const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
const_iterator cbegin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||||
|
|
||||||
iterator end() { return begin(); }
|
iterator end() BOOST_NOEXCEPT { return begin(); }
|
||||||
const_iterator end() const { return begin(); }
|
const_iterator end() const BOOST_NOEXCEPT { return begin(); }
|
||||||
const_iterator cend() const { return cbegin(); }
|
const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); }
|
||||||
|
|
||||||
// reverse iterator support
|
// reverse iterator support
|
||||||
#if !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)
|
|
||||||
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;
|
|
||||||
typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); }
|
||||||
const_reverse_iterator rbegin() const {
|
const_reverse_iterator rbegin() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crbegin() const {
|
const_reverse_iterator crbegin() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(end());
|
return const_reverse_iterator(end());
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
reverse_iterator rend() BOOST_NOEXCEPT { return reverse_iterator(begin()); }
|
||||||
const_reverse_iterator rend() const {
|
const_reverse_iterator rend() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
const_reverse_iterator crend() const {
|
const_reverse_iterator crend() const BOOST_NOEXCEPT {
|
||||||
return const_reverse_iterator(begin());
|
return const_reverse_iterator(begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,14 +241,14 @@ namespace boost {
|
|||||||
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()
|
||||||
@ -261,7 +256,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();
|
||||||
}
|
}
|
||||||
@ -271,26 +266,28 @@ 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 BOOST_CONSTEXPR size_type size() BOOST_NOEXCEPT { return 0; }
|
||||||
static BOOST_CONSTEXPR bool empty() { return true; }
|
static BOOST_CONSTEXPR bool empty() BOOST_NOEXCEPT { return true; }
|
||||||
static BOOST_CONSTEXPR size_type max_size() { return 0; }
|
static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return 0; }
|
||||||
enum { static_size = 0 };
|
enum { static_size = 0 };
|
||||||
|
|
||||||
void swap (array<T,0>& /*y*/) {
|
BOOST_CXX14_CONSTEXPR void swap (array<T,0>& /*y*/)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct access to data (read-only)
|
// direct access to data
|
||||||
const T* data() const { return 0; }
|
BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return 0; }
|
||||||
T* data() { return 0; }
|
BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return 0; }
|
||||||
|
|
||||||
// use array as C array (direct read/write access to data)
|
// obsolete
|
||||||
T* c_array() { return 0; }
|
BOOST_DEPRECATED( "please use `data()` instead" )
|
||||||
|
T* c_array() BOOST_NOEXCEPT { return 0; }
|
||||||
|
|
||||||
// assignment with type conversion
|
// assignment with type conversion
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
@ -298,10 +295,13 @@ namespace boost {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign one value to all elements
|
// an obsolete synonym for fill
|
||||||
|
BOOST_DEPRECATED( "please use `fill` instead" )
|
||||||
void assign (const T& value) { fill ( value ); }
|
void assign (const T& value) { fill ( value ); }
|
||||||
void fill (const T& ) {}
|
|
||||||
|
// fill with one value
|
||||||
|
BOOST_CXX14_CONSTEXPR 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");
|
||||||
@ -320,95 +320,89 @@ namespace boost {
|
|||||||
|
|
||||||
// comparisons
|
// comparisons
|
||||||
template<class T, std::size_t N>
|
template<class T, std::size_t N>
|
||||||
bool operator== (const array<T,N>& x, const array<T,N>& y) {
|
BOOST_CXX14_CONSTEXPR bool operator== (const array<T,N>& x, const array<T,N>& y)
|
||||||
return std::equal(x.begin(), x.end(), y.begin());
|
{
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
if( !( x[ i ] == y[ i ] ) ) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
template<class T, std::size_t N>
|
|
||||||
bool operator< (const array<T,N>& x, const array<T,N>& y) {
|
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
|
||||||
return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
|
|
||||||
|
template<class T>
|
||||||
|
BOOST_CXX14_CONSTEXPR bool operator== (const array<T, 0>& x, const array<T, 0>& y)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N>
|
template<class T, std::size_t N>
|
||||||
bool operator!= (const array<T,N>& x, const array<T,N>& y) {
|
BOOST_CXX14_CONSTEXPR bool operator!= (const array<T,N>& x, const array<T,N>& y) {
|
||||||
return !(x==y);
|
return !(x==y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, std::size_t N>
|
template<class T, std::size_t N>
|
||||||
bool operator> (const array<T,N>& x, const array<T,N>& y) {
|
BOOST_CXX14_CONSTEXPR bool operator< (const array<T,N>& x, const array<T,N>& y)
|
||||||
|
{
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
if( x[ i ] < y[ i ] ) return true;
|
||||||
|
if( y[ i ] < x[ i ] ) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
BOOST_CXX14_CONSTEXPR bool operator< (const array<T, 0>& x, const array<T, 0>& y)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
BOOST_CXX14_CONSTEXPR bool operator> (const array<T,N>& x, const array<T,N>& y) {
|
||||||
return y<x;
|
return y<x;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, std::size_t N>
|
template<class T, std::size_t N>
|
||||||
bool operator<= (const array<T,N>& x, const array<T,N>& y) {
|
BOOST_CXX14_CONSTEXPR bool operator<= (const array<T,N>& x, const array<T,N>& y) {
|
||||||
return !(y<x);
|
return !(y<x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, std::size_t N>
|
template<class T, std::size_t N>
|
||||||
bool operator>= (const array<T,N>& x, const array<T,N>& y) {
|
BOOST_CXX14_CONSTEXPR bool operator>= (const array<T,N>& x, const array<T,N>& y) {
|
||||||
return !(x<y);
|
return !(x<y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// global swap()
|
// global swap()
|
||||||
template<class T, std::size_t N>
|
template<class T, std::size_t N>
|
||||||
inline void swap (array<T,N>& x, array<T,N>& y) {
|
BOOST_CXX14_CONSTEXPR inline void swap (array<T,N>& x, array<T,N>& y) {
|
||||||
x.swap(y);
|
x.swap(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__SUNPRO_CC)
|
// undocumented and obsolete
|
||||||
// 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>
|
template <typename T, std::size_t N>
|
||||||
|
BOOST_DEPRECATED( "please use `elems` instead" )
|
||||||
T(&get_c_array(boost::array<T,N>& arg))[N]
|
T(&get_c_array(boost::array<T,N>& arg))[N]
|
||||||
{
|
{
|
||||||
return arg.elems;
|
return arg.elems;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Const version.
|
// Const version.
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
|
BOOST_DEPRECATED( "please use `elems` instead" )
|
||||||
const T(&get_c_array(const boost::array<T,N>& arg))[N]
|
const T(&get_c_array(const boost::array<T,N>& arg))[N]
|
||||||
{
|
{
|
||||||
return arg.elems;
|
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 It> std::size_t hash_range(It, It);
|
||||||
|
|
||||||
@ -419,13 +413,13 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <size_t Idx, typename T, size_t N>
|
template <size_t Idx, typename T, size_t N>
|
||||||
T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
BOOST_CXX14_CONSTEXPR T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
||||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
|
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
|
||||||
return arr[Idx];
|
return arr[Idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t Idx, typename T, size_t N>
|
template <size_t Idx, typename T, size_t N>
|
||||||
const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
BOOST_CONSTEXPR 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" );
|
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" );
|
||||||
return arr[Idx];
|
return arr[Idx];
|
||||||
}
|
}
|
||||||
@ -436,12 +430,14 @@ namespace boost {
|
|||||||
// If we don't have std::array, I'm assuming that we don't have std::get
|
// If we don't have std::array, I'm assuming that we don't have std::get
|
||||||
namespace std {
|
namespace std {
|
||||||
template <size_t Idx, typename T, size_t N>
|
template <size_t Idx, typename T, size_t N>
|
||||||
|
BOOST_DEPRECATED( "please use `boost::get` instead" )
|
||||||
T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
||||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" );
|
BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" );
|
||||||
return arr[Idx];
|
return arr[Idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t Idx, typename T, size_t N>
|
template <size_t Idx, typename T, size_t N>
|
||||||
|
BOOST_DEPRECATED( "please use `boost::get` instead" )
|
||||||
const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
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" );
|
BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(const boost::array &) index out of range" );
|
||||||
return arr[Idx];
|
return arr[Idx];
|
||||||
@ -449,8 +445,8 @@ namespace std {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*BOOST_ARRAY_HPP*/
|
#endif // #ifndef BOOST_ARRAY_HPP_INCLUDED
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="refresh" content="0; URL=../../doc/html/array.html">
|
<meta http-equiv="refresh" content="0; URL=doc/html/array.html">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Automatic redirection failed, please go to
|
Automatic redirection failed, please go to
|
||||||
<a href="../../doc/html/array.html">../../doc/html/array.html</a> <hr>
|
<a href="../../doc/html/array.html">doc/html/array.html</a> <hr>
|
||||||
<p><EFBFBD> Copyright Beman Dawes, 2001</p>
|
<p><EFBFBD> Copyright Beman Dawes, 2001</p>
|
||||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
12
test/CMakeLists.txt
Normal file
12
test/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Copyright 2018, 2019, 2021, 2022 Peter Dimov
|
||||||
|
# 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||||
|
|
||||||
|
if(HAVE_BOOST_TEST)
|
||||||
|
|
||||||
|
boost_test_jamfile(FILE Jamfile.v2
|
||||||
|
LINK_LIBRARIES Boost::array Boost::container_hash Boost::core)
|
||||||
|
|
||||||
|
endif()
|
@ -2,17 +2,66 @@
|
|||||||
#~ 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)
|
||||||
|
|
||||||
test-suite array :
|
require-b2 5.0.1 ;
|
||||||
[ run array0.cpp ]
|
import testing ;
|
||||||
[ run array1.cpp ]
|
import-search /boost/config/checks ;
|
||||||
[ run array2.cpp ]
|
import config : requires ;
|
||||||
[ run array3.cpp ]
|
|
||||||
[ run array4.cpp ]
|
#
|
||||||
[ run array5.cpp ]
|
|
||||||
[ run array6.cpp ]
|
run array0.cpp ;
|
||||||
[ run array7.cpp ]
|
run array1.cpp ;
|
||||||
# [ run array_constexpr.cpp ]
|
run array2.cpp ;
|
||||||
[ compile-fail array_getfail1.cpp ]
|
run array3.cpp ;
|
||||||
[ compile-fail array_getfail2.cpp ]
|
run array4.cpp ;
|
||||||
[ run array_hash.cpp ]
|
run array5.cpp ;
|
||||||
;
|
run array6.cpp ;
|
||||||
|
run array7.cpp ;
|
||||||
|
|
||||||
|
compile array_constexpr.cpp ;
|
||||||
|
|
||||||
|
compile-fail array_getfail1.cpp ;
|
||||||
|
compile-fail array_getfail2.cpp ;
|
||||||
|
|
||||||
|
run array_hash.cpp
|
||||||
|
: : : [ requires cxx11_noexcept ] ;
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
run array_typedef_test.cpp ;
|
||||||
|
run array_elems_test.cpp ;
|
||||||
|
run array_init_test.cpp ;
|
||||||
|
run array_copy_test.cpp ;
|
||||||
|
run array_convert_test.cpp ;
|
||||||
|
run array_data_test.cpp ;
|
||||||
|
run array_iterator_test.cpp ;
|
||||||
|
run array_reverse_test.cpp ;
|
||||||
|
run array_size_test.cpp ;
|
||||||
|
run array_access_test.cpp ;
|
||||||
|
run array_c_array_test.cpp ;
|
||||||
|
run array_fill_test.cpp ;
|
||||||
|
run array_assign_test.cpp ;
|
||||||
|
run array_swap_test.cpp ;
|
||||||
|
run array_swap_test2.cpp ;
|
||||||
|
run array_eq_test.cpp ;
|
||||||
|
run array_lt_test.cpp ;
|
||||||
|
run array_get_test.cpp ;
|
||||||
|
|
||||||
|
# C++11 constexpr
|
||||||
|
|
||||||
|
compile array_init_test_cx.cpp ;
|
||||||
|
compile array_copy_test_cx.cpp ;
|
||||||
|
compile array_data_test_cx.cpp ;
|
||||||
|
compile array_iterator_test_cx.cpp ;
|
||||||
|
compile array_size_test_cx.cpp ;
|
||||||
|
compile array_access_test_cx.cpp ;
|
||||||
|
compile array_get_test_cx.cpp ;
|
||||||
|
|
||||||
|
# C++14 constexpr
|
||||||
|
|
||||||
|
compile array_eq_test_cx.cpp ;
|
||||||
|
compile array_lt_test_cx.cpp ;
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
run quick.cpp ;
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/array.hpp>
|
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
117
test/array_access_test.cpp
Normal file
117
test/array_access_test.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
struct assertion_failure
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
void assertion_failed( char const* /*expr*/, char const* /*function*/, char const* /*file*/, long /*line*/ )
|
||||||
|
{
|
||||||
|
throw assertion_failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertion_failed_msg( char const* /*expr*/, char const* /*msg*/, char const* /*function*/, char const* /*file*/, long /*line*/ )
|
||||||
|
{
|
||||||
|
throw assertion_failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
T* p1 = a.data();
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
T* p2 = &a[ i ];
|
||||||
|
T* p3 = &a.at( i );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 + i );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + i );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T* p2 = &a.front();
|
||||||
|
T* p3 = &a.back();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 + 0 );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + N - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( a.at( N ), std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a[ N ], assertion_failure );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a = {{}};
|
||||||
|
|
||||||
|
T const* p1 = a.data();
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
T const* p2 = &a[ i ];
|
||||||
|
T const* p3 = &a.at( i );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 + i );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + i );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T const* p2 = &a.front();
|
||||||
|
T const* p3 = &a.back();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 + 0 );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + N - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( a.at( N ), std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a[ N ], assertion_failure );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, 0> a = {};
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( a.at( 0 ), std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a[ 0 ], std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a.front(), std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a.back(), std::out_of_range );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, 0> const a = {};
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( a.at( 0 ), std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a[ 0 ], std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a.front(), std::out_of_range );
|
||||||
|
BOOST_TEST_THROWS( a.back(), std::out_of_range );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test<int const, 1>();
|
||||||
|
test<int const, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
50
test/array_access_test_cx.cpp
Normal file
50
test/array_access_test_cx.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T> void test()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a = {{}};
|
||||||
|
|
||||||
|
STATIC_ASSERT( &a[ 0 ] == a.data() + 0 );
|
||||||
|
STATIC_ASSERT( &a[ 1 ] == a.data() + 1 );
|
||||||
|
STATIC_ASSERT( &a[ 2 ] == a.data() + 2 );
|
||||||
|
STATIC_ASSERT( &a[ 3 ] == a.data() + 3 );
|
||||||
|
|
||||||
|
STATIC_ASSERT( &a.at( 0 ) == a.data() + 0 );
|
||||||
|
STATIC_ASSERT( &a.at( 1 ) == a.data() + 1 );
|
||||||
|
STATIC_ASSERT( &a.at( 2 ) == a.data() + 2 );
|
||||||
|
STATIC_ASSERT( &a.at( 3 ) == a.data() + 3 );
|
||||||
|
|
||||||
|
STATIC_ASSERT( &a.front() == a.data() );
|
||||||
|
STATIC_ASSERT( &a.back() == a.data() + 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
60
test/array_assign_test.cpp
Normal file
60
test/array_assign_test.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
// assign is a nonstandard equivalent of fill
|
||||||
|
// it probably needs to be deprecated and removed
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {};
|
||||||
|
|
||||||
|
a.assign( 1 );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
a.assign( 5 );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], 5 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test3()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
// aliasing
|
||||||
|
a.assign( a[ 1 ] );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
|
||||||
|
test3<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
70
test/array_c_array_test.cpp
Normal file
70
test/array_c_array_test.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
// c_array and get_c_array are nonstandard extensions
|
||||||
|
// probably need to be deprecated and removed
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {};
|
||||||
|
|
||||||
|
T* p1 = a.c_array();
|
||||||
|
T* p2 = a.data();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p1, p2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test2()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
T (&e1)[ N ] = boost::get_c_array( a );
|
||||||
|
T (&e2)[ N ] = a.elems;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( static_cast<T*>( e1 ), static_cast<T*>( e2 ) );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a = {{}};
|
||||||
|
|
||||||
|
T const (&e1)[ N ] = boost::get_c_array( a );
|
||||||
|
T const (&e2)[ N ] = a.elems;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( static_cast<T const*>( e1 ), static_cast<T const*>( e2 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test<int const, 0>();
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
// = {} doesn't work for const T
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
test<int const, 1>();
|
||||||
|
test<int const, 7>();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
test2<int, 1>();
|
||||||
|
test2<int, 7>();
|
||||||
|
|
||||||
|
test2<int const, 1>();
|
||||||
|
test2<int const, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
@ -3,29 +3,17 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See
|
* Distributed under the Boost Software License, Version 1.0. (See
|
||||||
* 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)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
#include <algorithm>
|
#include <boost/config.hpp>
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
#include <array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_CONSTEXPR
|
#ifndef BOOST_NO_CXX11_CONSTEXPR
|
||||||
|
|
||||||
constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
// constexpr int two = arr_std.at (2);
|
|
||||||
constexpr int three = arr.at (3);
|
constexpr int three = arr.at (3);
|
||||||
int whatever [ arr.at(4) ];
|
int whatever [ arr.at(4) ];
|
||||||
(void)three;
|
(void)three;
|
||||||
@ -33,7 +21,9 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else // no constexpr means no constexpr tests!
|
#else // no constexpr means no constexpr tests!
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
38
test/array_convert_test.cpp
Normal file
38
test/array_convert_test.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, class U, std::size_t N> void test2()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1 = {};
|
||||||
|
|
||||||
|
boost::array<U, N> a2;
|
||||||
|
a2 = a1;
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class U> void test4()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a1 = { 1, 2, 3, 4 };
|
||||||
|
|
||||||
|
boost::array<U, 4> a2;
|
||||||
|
a2 = a1;
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test2<int, long, 0>();
|
||||||
|
test2<int, long, 1>();
|
||||||
|
test2<int, long, 7>();
|
||||||
|
|
||||||
|
test4<int, long>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
65
test/array_copy_test.cpp
Normal file
65
test/array_copy_test.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1 = {{}};
|
||||||
|
boost::array<T, N> a2 = a1;
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test2()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1 = {};
|
||||||
|
|
||||||
|
boost::array<T, N> a2;
|
||||||
|
a2 = a1;
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test3()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
boost::array<T, 4> a2 = a1;
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test4()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a1 = { 1, 2, 3, 4 };
|
||||||
|
|
||||||
|
boost::array<T, 4> a2;
|
||||||
|
a2 = a1;
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
// test1<int const, 0>();
|
||||||
|
test1<int const, 1>();
|
||||||
|
test1<int const, 7>();
|
||||||
|
|
||||||
|
test2<int, 0>();
|
||||||
|
test2<int, 1>();
|
||||||
|
test2<int, 7>();
|
||||||
|
|
||||||
|
test3<int>();
|
||||||
|
test3<int const>();
|
||||||
|
|
||||||
|
test4<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
58
test/array_copy_test_cx.cpp
Normal file
58
test/array_copy_test_cx.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 2> a1 = {};
|
||||||
|
constexpr boost::array<T, 2> a2 = a1;
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1[0] == a2[0] );
|
||||||
|
STATIC_ASSERT( a1[1] == a2[1] );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 3> a1 = {{ 1, 2, 3 }};
|
||||||
|
constexpr boost::array<T, 3> a2 = a1;
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1[0] == a2[0] );
|
||||||
|
STATIC_ASSERT( a1[1] == a2[1] );
|
||||||
|
STATIC_ASSERT( a1[2] == a2[2] );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test3()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 0> a1 = {};
|
||||||
|
constexpr boost::array<T, 0> a2 = a1;
|
||||||
|
|
||||||
|
(void)a1;
|
||||||
|
(void)a2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int>();
|
||||||
|
test2<int>();
|
||||||
|
test3<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
41
test/array_data_test.cpp
Normal file
41
test/array_data_test.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
T* p1 = a.data();
|
||||||
|
T* p2 = a.elems;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p1, p2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a = {{}};
|
||||||
|
|
||||||
|
T const* p1 = a.data();
|
||||||
|
T const* p2 = a.elems;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p1, p2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
// test<int const, 0>();
|
||||||
|
test<int const, 1>();
|
||||||
|
test<int const, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
47
test/array_data_test_cx.cpp
Normal file
47
test/array_data_test_cx.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, N> a = {};
|
||||||
|
STATIC_ASSERT( a.data() == a.elems );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 0> a = {};
|
||||||
|
STATIC_ASSERT( a.data() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
27
test/array_elems_test.cpp
Normal file
27
test/array_elems_test.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
T (&e)[ N ] = a.elems;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( static_cast<void const*>( e ), static_cast<void const*>( &a ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test<int const, 1>();
|
||||||
|
test<int const, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
83
test/array_eq_test.cpp
Normal file
83
test/array_eq_test.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a1 = {};
|
||||||
|
boost::array<T, N> const a2 = {};
|
||||||
|
|
||||||
|
BOOST_TEST( a1 == a2 );
|
||||||
|
BOOST_TEST_NOT( a1 != a2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a1 = {};
|
||||||
|
|
||||||
|
boost::array<T, N> a2 = a1;
|
||||||
|
a2[ i ] = 1;
|
||||||
|
|
||||||
|
BOOST_TEST( a1 != a2 );
|
||||||
|
BOOST_TEST_NOT( a1 == a2 );
|
||||||
|
|
||||||
|
boost::array<T, N> const a3 = a2;
|
||||||
|
|
||||||
|
BOOST_TEST( a1 != a3 );
|
||||||
|
BOOST_TEST_NOT( a1 == a3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1 = {};
|
||||||
|
boost::array<T, N> a2 = {};
|
||||||
|
|
||||||
|
a1.fill( 1 );
|
||||||
|
a2.fill( 1 );
|
||||||
|
|
||||||
|
BOOST_TEST( a1 == a2 );
|
||||||
|
BOOST_TEST_NOT( a1 != a2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, 4> const a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
boost::array<T, 4> const a2 = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
BOOST_TEST( a1 == a2 );
|
||||||
|
BOOST_TEST_NOT( a1 != a2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
boost::array<T, 4> const a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
boost::array<T, 4> a2 = a1;
|
||||||
|
a2[ i ] = 0;
|
||||||
|
|
||||||
|
BOOST_TEST( a1 != a2 );
|
||||||
|
BOOST_TEST_NOT( a1 == a2 );
|
||||||
|
|
||||||
|
boost::array<T, 4> const a3 = a2;
|
||||||
|
|
||||||
|
BOOST_TEST( a1 != a3 );
|
||||||
|
BOOST_TEST_NOT( a1 == a3 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
55
test/array_eq_test_cx.cpp
Normal file
55
test/array_eq_test_cx.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, N> a1 = {};
|
||||||
|
constexpr boost::array<T, N> a2 = {};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1 == a2 );
|
||||||
|
STATIC_ASSERT( !( a1 != a2 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1 == a2 );
|
||||||
|
STATIC_ASSERT( !( a1 != a2 ) );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 5 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( !( a1 == a2 ) );
|
||||||
|
STATIC_ASSERT( a1 != a2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
57
test/array_fill_test.cpp
Normal file
57
test/array_fill_test.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {};
|
||||||
|
|
||||||
|
a.fill( 1 );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
a.fill( 5 );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], 5 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test3()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
// aliasing
|
||||||
|
a.fill( a[ 1 ] );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
|
||||||
|
test3<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
40
test/array_get_test.cpp
Normal file
40
test/array_get_test.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T> void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, 4> const a = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( boost::get<0>( a ), 1 );
|
||||||
|
BOOST_TEST_EQ( boost::get<1>( a ), 2 );
|
||||||
|
BOOST_TEST_EQ( boost::get<2>( a ), 3 );
|
||||||
|
BOOST_TEST_EQ( boost::get<3>( a ), 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
boost::get<0>( a ) += 1;
|
||||||
|
boost::get<1>( a ) += 2;
|
||||||
|
boost::get<2>( a ) += 3;
|
||||||
|
boost::get<3>( a ) += 4;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( boost::get<0>( a ), 2 );
|
||||||
|
BOOST_TEST_EQ( boost::get<1>( a ), 4 );
|
||||||
|
BOOST_TEST_EQ( boost::get<2>( a ), 6 );
|
||||||
|
BOOST_TEST_EQ( boost::get<3>( a ), 8 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
42
test/array_get_test_cx.cpp
Normal file
42
test/array_get_test_cx.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T> void test()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( boost::get<0>( a ) == 1 );
|
||||||
|
STATIC_ASSERT( boost::get<1>( a ) == 2 );
|
||||||
|
STATIC_ASSERT( boost::get<2>( a ) == 3 );
|
||||||
|
STATIC_ASSERT( boost::get<3>( a ) == 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
81
test/array_init_test.cpp
Normal file
81
test/array_init_test.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], T() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test2()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {};
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a[i], T() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test3()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a = {{ 1, 2, 3, 4 }};
|
||||||
|
T b[ 4 ] = { 1, 2, 3, 4 };
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a.begin(), a.end(), b + 0, b + 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test4()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a = { 1, 2, 3, 4 };
|
||||||
|
T b[ 4 ] = { 1, 2, 3, 4 };
|
||||||
|
|
||||||
|
BOOST_TEST_ALL_EQ( a.begin(), a.end(), b + 0, b + 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
// test1<int const, 0>();
|
||||||
|
test1<int const, 1>();
|
||||||
|
test1<int const, 7>();
|
||||||
|
|
||||||
|
test2<int, 0>();
|
||||||
|
test2<int, 1>();
|
||||||
|
test2<int, 7>();
|
||||||
|
|
||||||
|
// test2<int const, 0>();
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
// = {} doesn't work for const T
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
test2<int const, 1>();
|
||||||
|
test2<int const, 7>();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
test3<int>();
|
||||||
|
test3<int const>();
|
||||||
|
|
||||||
|
test4<int>();
|
||||||
|
test4<int const>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
78
test/array_init_test_cx.cpp
Normal file
78
test/array_init_test_cx.cpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 1> a = {{}};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a[0] == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 2> a = {};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a[0] == 0 );
|
||||||
|
STATIC_ASSERT( a[1] == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test3()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 3> a = {{ 1, 2, 3 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a[0] == 1 );
|
||||||
|
STATIC_ASSERT( a[1] == 2 );
|
||||||
|
STATIC_ASSERT( a[2] == 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test4()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a = { 1, 2, 3, 4 };
|
||||||
|
|
||||||
|
STATIC_ASSERT( a[0] == 1 );
|
||||||
|
STATIC_ASSERT( a[1] == 2 );
|
||||||
|
STATIC_ASSERT( a[2] == 3 );
|
||||||
|
STATIC_ASSERT( a[3] == 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test5()
|
||||||
|
{
|
||||||
|
// constexpr boost::array<T, 0> a = {{}};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test6()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 0> a = {};
|
||||||
|
(void)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int>();
|
||||||
|
test2<int>();
|
||||||
|
test3<int>();
|
||||||
|
test4<int>();
|
||||||
|
test5<int>();
|
||||||
|
test6<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
108
test/array_iterator_test.cpp
Normal file
108
test/array_iterator_test.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
T* p1 = a.data();
|
||||||
|
|
||||||
|
{
|
||||||
|
T* p2 = a.begin();
|
||||||
|
T* p3 = a.end();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + N );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T const* p2 = a.cbegin();
|
||||||
|
T const* p3 = a.cend();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + N );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a = {{}};
|
||||||
|
|
||||||
|
T const* p1 = a.data();
|
||||||
|
|
||||||
|
{
|
||||||
|
T const* p2 = a.begin();
|
||||||
|
T const* p3 = a.end();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + N );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T const* p2 = a.cbegin();
|
||||||
|
T const* p3 = a.cend();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p1 );
|
||||||
|
BOOST_TEST_EQ( p3, p1 + N );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, 0> a = {};
|
||||||
|
|
||||||
|
{
|
||||||
|
T* p2 = a.begin();
|
||||||
|
T* p3 = a.end();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T const* p2 = a.cbegin();
|
||||||
|
T const* p3 = a.cend();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p3 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, 0> const a = {};
|
||||||
|
|
||||||
|
{
|
||||||
|
T const* p2 = a.begin();
|
||||||
|
T const* p3 = a.end();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T const* p2 = a.cbegin();
|
||||||
|
T const* p3 = a.cend();
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p2, p3 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
// test<int const, 0>();
|
||||||
|
test<int const, 1>();
|
||||||
|
test<int const, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
58
test/array_iterator_test_cx.cpp
Normal file
58
test/array_iterator_test_cx.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910")
|
||||||
|
|
||||||
|
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, N> a = {};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a.begin() == a.data() );
|
||||||
|
STATIC_ASSERT( a.end() == a.data() + N );
|
||||||
|
|
||||||
|
STATIC_ASSERT( a.cbegin() == a.data() );
|
||||||
|
STATIC_ASSERT( a.cend() == a.data() + N );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 0> a = {};
|
||||||
|
|
||||||
|
// iterator access is not constexpr for boost::array<T, 0>
|
||||||
|
// it is for std::array<T, 0>, though, so we should change it
|
||||||
|
|
||||||
|
STATIC_ASSERT( a.begin() == a.end() );
|
||||||
|
STATIC_ASSERT( a.cbegin() == a.cend() );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
// test2<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
85
test/array_lt_test.cpp
Normal file
85
test/array_lt_test.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a1 = {};
|
||||||
|
boost::array<T, N> const a2 = {};
|
||||||
|
|
||||||
|
BOOST_TEST_NOT( a1 < a2 );
|
||||||
|
BOOST_TEST_NOT( a1 > a2 );
|
||||||
|
BOOST_TEST( a1 <= a2 );
|
||||||
|
BOOST_TEST( a1 >= a2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1;
|
||||||
|
boost::array<T, N> a2;
|
||||||
|
|
||||||
|
a1.fill( 1 );
|
||||||
|
a2.fill( 1 );
|
||||||
|
|
||||||
|
BOOST_TEST_NOT( a1 < a2 );
|
||||||
|
BOOST_TEST_NOT( a1 > a2 );
|
||||||
|
BOOST_TEST( a1 <= a2 );
|
||||||
|
BOOST_TEST( a1 >= a2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1;
|
||||||
|
boost::array<T, N> a2;
|
||||||
|
|
||||||
|
a1.fill( 1 );
|
||||||
|
a2.fill( 1 );
|
||||||
|
|
||||||
|
a1[ i ] = 0;
|
||||||
|
|
||||||
|
BOOST_TEST( a1 < a2 );
|
||||||
|
BOOST_TEST( a1 <= a2 );
|
||||||
|
BOOST_TEST_NOT( a1 > a2 );
|
||||||
|
BOOST_TEST_NOT( a1 >= a2 );
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a3 = a1;
|
||||||
|
boost::array<T, N> const a4 = a2;
|
||||||
|
|
||||||
|
BOOST_TEST( a3 < a4 );
|
||||||
|
BOOST_TEST( a3 <= a4 );
|
||||||
|
BOOST_TEST_NOT( a3 > a4 );
|
||||||
|
BOOST_TEST_NOT( a3 >= a4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
a1[ i ] = 2;
|
||||||
|
|
||||||
|
BOOST_TEST( a1 > a2 );
|
||||||
|
BOOST_TEST( a1 >= a2 );
|
||||||
|
BOOST_TEST_NOT( a1 < a2 );
|
||||||
|
BOOST_TEST_NOT( a1 <= a2 );
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a3 = a1;
|
||||||
|
boost::array<T, N> const a4 = a2;
|
||||||
|
|
||||||
|
BOOST_TEST( a3 > a4 );
|
||||||
|
BOOST_TEST( a3 >= a4 );
|
||||||
|
BOOST_TEST_NOT( a3 < a4 );
|
||||||
|
BOOST_TEST_NOT( a3 <= a4 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
74
test/array_lt_test_cx.cpp
Normal file
74
test/array_lt_test_cx.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, N> a1 = {};
|
||||||
|
constexpr boost::array<T, N> a2 = {};
|
||||||
|
|
||||||
|
STATIC_ASSERT( !( a1 < a2 ) );
|
||||||
|
STATIC_ASSERT( !( a1 > a2 ) );
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1 <= a2 );
|
||||||
|
STATIC_ASSERT( a1 >= a2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( !( a1 < a2 ) );
|
||||||
|
STATIC_ASSERT( !( a1 > a2 ) );
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1 <= a2 );
|
||||||
|
STATIC_ASSERT( a1 >= a2 );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 5 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1 < a2 );
|
||||||
|
STATIC_ASSERT( !( a1 > a2 ) );
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1 <= a2 );
|
||||||
|
STATIC_ASSERT( !( a1 >= a2 ) );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 2 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( !( a1 < a2 ) );
|
||||||
|
STATIC_ASSERT( a1 > a2 );
|
||||||
|
|
||||||
|
STATIC_ASSERT( !( a1 <= a2 ) );
|
||||||
|
STATIC_ASSERT( a1 >= a2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
88
test/array_reverse_test.cpp
Normal file
88
test/array_reverse_test.cpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T*> r1( a.rbegin() );
|
||||||
|
std::reverse_iterator<T*> r2( a.end() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T*> r1( a.rend() );
|
||||||
|
std::reverse_iterator<T*> r2( a.begin() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T const*> r1( a.crbegin() );
|
||||||
|
std::reverse_iterator<T const*> r2( a.cend() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T const*> r1( a.crend() );
|
||||||
|
std::reverse_iterator<T const*> r2( a.cbegin() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a = {{}};
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T const*> r1( a.rbegin() );
|
||||||
|
std::reverse_iterator<T const*> r2( a.end() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T const*> r1( a.rend() );
|
||||||
|
std::reverse_iterator<T const*> r2( a.begin() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T const*> r1( a.crbegin() );
|
||||||
|
std::reverse_iterator<T const*> r2( a.cend() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::reverse_iterator<T const*> r1( a.crend() );
|
||||||
|
std::reverse_iterator<T const*> r2( a.cbegin() );
|
||||||
|
|
||||||
|
BOOST_TEST( r1 == r2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
// test<int const, 0>();
|
||||||
|
test<int const, 1>();
|
||||||
|
test<int const, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
73
test/array_size_test.cpp
Normal file
73
test/array_size_test.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::array<T, N> a = {{}};
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( a.size(), N );
|
||||||
|
BOOST_TEST_EQ( a.empty(), N == 0 );
|
||||||
|
BOOST_TEST_EQ( a.max_size(), N );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a = {{}};
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( a.size(), N );
|
||||||
|
BOOST_TEST_EQ( a.empty(), N == 0 );
|
||||||
|
BOOST_TEST_EQ( a.max_size(), N );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test2()
|
||||||
|
{
|
||||||
|
typedef boost::array<T, N> A;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( A().size(), N );
|
||||||
|
BOOST_TEST_EQ( A().empty(), N == 0 );
|
||||||
|
BOOST_TEST_EQ( A().max_size(), N );
|
||||||
|
}
|
||||||
|
|
||||||
|
// the functions are static, which deviates from the standard
|
||||||
|
template<class T, std::size_t N> void test3()
|
||||||
|
{
|
||||||
|
typedef boost::array<T, N> A;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( A::size(), N );
|
||||||
|
BOOST_TEST_EQ( A::empty(), N == 0 );
|
||||||
|
BOOST_TEST_EQ( A::max_size(), N );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( A::static_size, N );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
// test1<int const, 0>();
|
||||||
|
test1<int const, 1>();
|
||||||
|
test1<int const, 7>();
|
||||||
|
|
||||||
|
test2<int, 0>();
|
||||||
|
test2<int, 1>();
|
||||||
|
test2<int, 7>();
|
||||||
|
|
||||||
|
test3<int, 0>();
|
||||||
|
test3<int, 1>();
|
||||||
|
test3<int, 7>();
|
||||||
|
|
||||||
|
test3<int const, 0>();
|
||||||
|
test3<int const, 1>();
|
||||||
|
test3<int const, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
64
test/array_size_test_cx.cpp
Normal file
64
test/array_size_test_cx.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, N> a = {};
|
||||||
|
|
||||||
|
STATIC_ASSERT( a.size() == N );
|
||||||
|
STATIC_ASSERT( a.empty() == (N == 0) );
|
||||||
|
STATIC_ASSERT( a.max_size() == N );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test2()
|
||||||
|
{
|
||||||
|
typedef boost::array<T, N> A;
|
||||||
|
|
||||||
|
STATIC_ASSERT( A().size() == N );
|
||||||
|
STATIC_ASSERT( A().empty() == (N == 0) );
|
||||||
|
STATIC_ASSERT( A().max_size() == N );
|
||||||
|
}
|
||||||
|
|
||||||
|
// the functions are static, which deviates from the standard
|
||||||
|
template<class T, std::size_t N> void test3()
|
||||||
|
{
|
||||||
|
typedef boost::array<T, N> A;
|
||||||
|
|
||||||
|
STATIC_ASSERT( A::size() == N );
|
||||||
|
STATIC_ASSERT( A::empty() == (N == 0) );
|
||||||
|
STATIC_ASSERT( A::max_size() == N );
|
||||||
|
|
||||||
|
STATIC_ASSERT( A::static_size == N );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
test2<int, 0>();
|
||||||
|
test2<int, 1>();
|
||||||
|
test2<int, 7>();
|
||||||
|
|
||||||
|
test3<int, 0>();
|
||||||
|
test3<int, 1>();
|
||||||
|
test3<int, 7>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
49
test/array_swap_test.cpp
Normal file
49
test/array_swap_test.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1 = {};
|
||||||
|
boost::array<T, N> a2 = {};
|
||||||
|
|
||||||
|
a1.fill( 1 );
|
||||||
|
a2.fill( 2 );
|
||||||
|
|
||||||
|
a1.swap( a2 );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a1[i], 2 );
|
||||||
|
BOOST_TEST_EQ( a2[i], 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
boost::array<T, 4> a2 = {{ 5, 6, 7, 8 }};
|
||||||
|
|
||||||
|
a1.swap( a2 );
|
||||||
|
|
||||||
|
for( int i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a1[i], i+5 );
|
||||||
|
BOOST_TEST_EQ( a2[i], i+1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
49
test/array_swap_test2.cpp
Normal file
49
test/array_swap_test2.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1 = {};
|
||||||
|
boost::array<T, N> a2 = {};
|
||||||
|
|
||||||
|
a1.fill( 1 );
|
||||||
|
a2.fill( 2 );
|
||||||
|
|
||||||
|
swap( a1, a2 );
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a1[i], 2 );
|
||||||
|
BOOST_TEST_EQ( a2[i], 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
boost::array<T, 4> a2 = {{ 5, 6, 7, 8 }};
|
||||||
|
|
||||||
|
swap( a1, a2 );
|
||||||
|
|
||||||
|
for( int i = 0; i < 4; ++i )
|
||||||
|
{
|
||||||
|
BOOST_TEST_EQ( a1[i], i+5 );
|
||||||
|
BOOST_TEST_EQ( a2[i], i+1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
43
test/array_typedef_test.cpp
Normal file
43
test/array_typedef_test.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright 2025 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
typedef boost::array<T, N> A;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::value_type, T);
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::iterator, T*);
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::const_iterator, T const*);
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::reverse_iterator, std::reverse_iterator<T*>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::const_reverse_iterator, std::reverse_iterator<T const*>);
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::reference, T&);
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::const_reference, T const&);
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::size_type, std::size_t);
|
||||||
|
BOOST_TEST_TRAIT_SAME(typename A::difference_type, std::ptrdiff_t);
|
||||||
|
|
||||||
|
BOOST_TEST_EQ(A::static_size, N);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test<int const, 0>();
|
||||||
|
test<int const, 1>();
|
||||||
|
test<int const, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
17
test/cmake_install_test/CMakeLists.txt
Normal file
17
test/cmake_install_test/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Copyright 2018, 2019, 2021 Peter Dimov
|
||||||
|
# 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
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5...3.20)
|
||||||
|
|
||||||
|
project(cmake_install_test LANGUAGES CXX)
|
||||||
|
|
||||||
|
find_package(boost_array REQUIRED)
|
||||||
|
|
||||||
|
add_executable(quick ../quick.cpp)
|
||||||
|
target_link_libraries(quick Boost::array)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_test(quick quick)
|
||||||
|
|
||||||
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
23
test/cmake_subdir_test/CMakeLists.txt
Normal file
23
test/cmake_subdir_test/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Copyright 2018, 2019, 2021 Peter Dimov
|
||||||
|
# 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
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5...3.20)
|
||||||
|
|
||||||
|
project(cmake_subdir_test LANGUAGES CXX)
|
||||||
|
|
||||||
|
add_subdirectory(../.. boostorg/array)
|
||||||
|
|
||||||
|
add_subdirectory(../../../assert boostorg/assert)
|
||||||
|
add_subdirectory(../../../config boostorg/config)
|
||||||
|
add_subdirectory(../../../core boostorg/core)
|
||||||
|
add_subdirectory(../../../static_assert boostorg/static_assert)
|
||||||
|
add_subdirectory(../../../throw_exception boostorg/throw_exception)
|
||||||
|
|
||||||
|
add_executable(quick ../quick.cpp)
|
||||||
|
target_link_libraries(quick Boost::array)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_test(quick quick)
|
||||||
|
|
||||||
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
11
test/quick.cpp
Normal file
11
test/quick.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2023 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
boost::array<int, 2> a = {{ 0, 1 }};
|
||||||
|
return a[0];
|
||||||
|
}
|
@ -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