Compare commits

...

53 Commits

Author SHA1 Message Date
Peter Dimov 3df3aafd19 Add back cxxstd=03 to .drone.jsonnet 2026-01-23 05:53:50 +02:00
Peter Dimov 8643c3caa8 Update .drone.jsonnet 2026-01-23 05:26:16 +02:00
Peter Dimov c5501aced9 Merge pull request #30 from Lastique/feature/remove_static_assert
Remove dependencies on Boost.StaticAssert
2026-01-23 05:23:17 +02:00
Peter Dimov 7bfa9baf8d Update ci.yml 2026-01-22 22:13:57 +02:00
Andrey Semashev 8e93e2a517 Remove dependencies on Boost.StaticAssert.
Boost.StaticAssert has been merged into Boost.Config, so remove
the dependency.
2026-01-22 19:55:06 +03:00
Peter Dimov e988ef9c4a Merge pull request #28 from ashtum/patch-1
Update index.html
2025-04-03 14:10:17 +03:00
Mohammad Nejati a0be8d9537 Update index.html 2025-04-03 14:25:37 +03:30
Peter Dimov eee0d5bbc5 Update documentation 2025-02-23 22:02:50 +02:00
Peter Dimov ec61272c1f Remove stray parentheses 2025-02-23 21:04:28 +02:00
Peter Dimov e97dc53868 Add to_array_test_cx.cpp 2025-02-23 20:59:49 +02:00
Peter Dimov ffbced7a17 Disable initializer list test for GCC < 4.9 and Clang < 3.8 2025-02-23 20:54:43 +02:00
Peter Dimov 37289c5d92 Add to_array 2025-02-23 20:45:50 +02:00
Peter Dimov 9b508e3ad2 Disable <=> tests when <compare> isn't available 2025-01-29 04:26:00 +02:00
Peter Dimov 84d0f84c9b Check for the existence of <compare>, include it, use it; 0 <=> 0 doesn't work without it anyway. 2025-01-29 04:03:41 +02:00
Peter Dimov 37a4833e26 Add the rest of the Clangs to Drone 2025-01-29 03:14:12 +02:00
Peter Dimov 8991751e3b Regenerate CMakeLists.txt 2025-01-27 21:22:01 +02:00
Peter Dimov b2f6f0ca65 Update build.jam 2025-01-27 21:21:34 +02:00
Peter Dimov 703ad46b81 Fix test/Jamfile project requirements 2025-01-27 21:18:15 +02:00
Peter Dimov 7482efd0a1 Merge branch 'modular' of https://github.com/grafikrobot/boostorg.array into feature/pr-24 2025-01-27 21:16:20 +02:00
Peter Dimov 61bbcbf341 Disable warnings for compile-fail tests 2025-01-27 19:53:31 +02:00
Peter Dimov 59e9940d5b Suppress false -Warray-bounds positive with -fsanitize=undefined 2025-01-27 19:53:16 +02:00
Peter Dimov 771750f7e1 Supress GCC and Clang warnings 2025-01-27 19:00:30 +02:00
Peter Dimov 75db85d1e9 Suppress MSVC unreachable code warnings 2025-01-27 18:23:43 +02:00
Peter Dimov 49e2a46c3a Enable warnings=extra, warnings-as-errors=on in test suite 2025-01-27 17:41:50 +02:00
Peter Dimov 07a14f33ef Update revision history 2025-01-27 17:19:06 +02:00
Peter Dimov 047ba01807 Update documentation 2025-01-27 17:16:50 +02:00
Peter Dimov 45de3be80c Add array_thw_test_cx.cpp 2025-01-27 04:03:06 +02:00
Peter Dimov 68db6ebd2d Add operator<=> overload for zero-sized arrays 2025-01-27 03:59:32 +02:00
Peter Dimov 329e59454f Add float tests to array_thw_test, as floats use std::partial_ordering 2025-01-27 03:55:13 +02:00
Peter Dimov 9a4010b88b Add operator<=>, array_thw_test.cpp 2025-01-27 03:40:19 +02:00
Peter Dimov 527ff0a80d Update revision history 2025-01-26 22:07:42 +02:00
Peter Dimov f017dac435 Enable failing tests 2025-01-26 21:26:46 +02:00
Peter Dimov 567ba40840 Add a dummy element to array<T, 0> to enable initialization with = {{}} 2025-01-26 21:15:39 +02:00
Peter Dimov 29700ff270 Update revision history 2025-01-26 21:02:26 +02:00
Peter Dimov b147799665 Remove local hash_value overload; boost::hash supports array-like types natively. 2025-01-26 20:35:19 +02:00
Peter Dimov acef60446a Update revision history 2025-01-26 20:31:53 +02:00
Peter Dimov 3d9f39814c Re-enable failing tests 2025-01-26 19:23:41 +02:00
Peter Dimov 89f09e33f1 Change array<T, 0>::begin() to return nullptr and make it constexpr. 2025-01-26 19:21:39 +02:00
Peter Dimov 43326390d9 Reenable failing test 2025-01-26 08:19:00 +02:00
Peter Dimov c95d855018 Remove obsolete workaround from failed_rangecheck 2025-01-26 08:09:41 +02:00
Peter Dimov 0a72026887 Update revision history 2025-01-26 06:09:05 +02:00
Peter Dimov d2c295b85f Add array_access_test_cx2.cpp 2025-01-26 05:53:09 +02:00
Peter Dimov 324827cfc0 Add array_assign_test_cx.cpp 2025-01-26 05:45:36 +02:00
Peter Dimov 9253e8f1af Add array_fill_test_cx.cpp 2025-01-26 05:41:56 +02:00
Peter Dimov cd0532b8fa Remove inclusion of <algorithm> 2025-01-26 05:08:42 +02:00
Rene Rivera 78fb6a71dd Adjust self dependencies as inter-lib deps no longer apply globally. 2024-07-27 11:03:42 -05:00
Rene Rivera 40e2a2d4d8 Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:23 -05:00
Rene Rivera fc10453994 Update copyright dates. 2024-07-20 22:52:04 -05:00
Rene Rivera 28d8d30b57 Bump B2 require to 5.2 2024-06-14 11:33:55 -05:00
Rene Rivera fe1e99eb31 Add requires-b2 check to top-level build file. 2024-05-05 09:00:00 -05:00
Rene Rivera 1469f4b28e Sync from upstream. 2024-04-12 22:21:21 -05:00
Rene Rivera d535c37a57 Switch to library requirements instead of source. As source puts extra source in install targets. 2024-03-29 21:12:36 -05:00
Rene Rivera 36bba5af2d Make the library modular usable. 2024-03-11 08:27:02 -05:00
50 changed files with 1025 additions and 194 deletions
+107 -18
View File
@@ -34,7 +34,6 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
'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 []) +
@@ -207,6 +206,13 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"g++-14-multilib",
),
linux_pipeline(
"Linux 25.10 GCC 15 32/64",
"cppalliance/droneubuntu2510:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '11,14,17,20,23,2c', ADDRMD: '32,64' },
"g++-15-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
@@ -235,6 +241,76 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"clang-3.8",
),
linux_pipeline(
"Linux 18.04 Clang 3.9",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.9', CXXSTD: '03,11,14' },
"clang-3.9",
),
linux_pipeline(
"Linux 18.04 Clang 4.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-4.0', CXXSTD: '03,11,14' },
"clang-4.0",
),
linux_pipeline(
"Linux 18.04 Clang 5.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '03,11,14,1z' },
"clang-5.0",
),
linux_pipeline(
"Linux 18.04 Clang 6.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-6.0', CXXSTD: '03,11,14,17' },
"clang-6.0",
),
linux_pipeline(
"Linux 20.04 Clang 7",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-7', CXXSTD: '03,11,14,17' },
"clang-7",
),
linux_pipeline(
"Linux 20.04 Clang 8",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-8', CXXSTD: '03,11,14,17' },
"clang-8",
),
linux_pipeline(
"Linux 20.04 Clang 9",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-9', CXXSTD: '03,11,14,17,2a' },
"clang-9",
),
linux_pipeline(
"Linux 20.04 Clang 10",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-10', CXXSTD: '03,11,14,17,2a' },
"clang-10",
),
linux_pipeline(
"Linux 20.04 Clang 11",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-11', CXXSTD: '03,11,14,17,2a' },
"clang-11",
),
linux_pipeline(
"Linux 20.04 Clang 12",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-12', CXXSTD: '03,11,14,17,2a' },
"clang-12",
),
linux_pipeline(
"Linux 22.04 Clang 13",
"cppalliance/droneubuntu2204:1",
@@ -264,38 +340,45 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 24.04 Clang 17 UBSAN",
"Linux 24.04 Clang 17",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' },
"clang-17",
),
linux_pipeline(
"Linux 24.04 Clang 17 ASAN",
"Linux 24.04 Clang 18",
"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,
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' },
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 18 ASAN",
"Linux 24.04 Clang 19",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + asan,
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' },
"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",
"Linux 24.04 Clang 20 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
"clang-20",
),
linux_pipeline(
"Linux 24.04 Clang 20 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '03,11,14,17,20,2b' } + asan,
"clang-20",
),
linux_pipeline(
"Linux 25.10 Clang 21",
"cppalliance/droneubuntu2510:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '03,11,14,17,20,23,2c' },
"clang-21",
),
macos_pipeline(
@@ -343,4 +426,10 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"cppalliance/dronevs2022:1",
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
),
windows_pipeline(
"Windows VS2026 msvc-14.5",
"cppalliance/dronevs2026:1",
{ TOOLSET: 'msvc-14.5', CXXSTD: '14,17,20,latest' },
),
]
+89 -64
View File
@@ -19,157 +19,205 @@ jobs:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-latest
container: ubuntu:16.04
os: ubuntu-latest
install: g++-4.9-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
install: g++-11-multilib
address-model: 32,64
- toolset: gcc-12
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
install: g++-12-multilib
address-model: 32,64
- toolset: gcc-13
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-24.04
container: ubuntu:24.04
os: ubuntu-latest
install: g++-13-multilib
address-model: 32,64
- toolset: gcc-14
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-24.04
container: ubuntu:24.04
os: ubuntu-latest
install: g++-14-multilib
address-model: 32,64
- toolset: gcc-15
cxxstd: "03,11,14,17,20,23,2c"
container: ubuntu:25.10
os: ubuntu-latest
install: g++-15-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-12
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
install: clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-24.04
container: ubuntu:24.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-24.04
container: ubuntu:24.04
os: ubuntu-latest
install: clang-17
- toolset: clang
compiler: clang++-18
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-24.04
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
- toolset: clang
compiler: clang++-19
cxxstd: "03,11,14,17,20,2b"
os: macos-13
container: ubuntu:24.04
os: ubuntu-latest
install: clang-19
- toolset: clang
compiler: clang++-20
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-20
- toolset: clang
compiler: clang++-21
cxxstd: "03,11,14,17,20,23,2c"
container: ubuntu:25.10
os: ubuntu-latest
install: clang-21
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-14
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-15
- toolset: clang
cxxstd: "03,11,14,17,20,23,2c"
os: macos-26
runs-on: ${{matrix.os}}
@@ -243,26 +291,18 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: 14,latest
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
os: windows-2025
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
os: windows-2022
runs-on: ${{matrix.os}}
@@ -302,12 +342,8 @@ jobs:
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
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
@@ -351,12 +387,8 @@ jobs:
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
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
@@ -410,12 +442,8 @@ jobs:
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
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
@@ -467,8 +495,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
@@ -516,8 +543,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
@@ -583,8 +609,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
-1
View File
@@ -34,7 +34,6 @@ matrix:
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/assert.git ../assert
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/core.git ../core
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/static_assert.git ../static_assert
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/throw_exception.git ../throw_exception
script:
-2
View File
@@ -16,8 +16,6 @@ target_link_libraries(boost_array
INTERFACE
Boost::assert
Boost::config
Boost::core
Boost::static_assert
Boost::throw_exception
)
+23
View File
@@ -0,0 +1,23 @@
# Copyright 2023-2024 René Ferdinand Rivera Morell
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
require-b2 5.2 ;
constant boost_dependencies :
/boost/assert//boost_assert
/boost/config//boost_config
/boost/throw_exception//boost_throw_exception
;
project /boost/array ;
explicit
[ alias boost_array : : : : <include>include <library>$(boost_dependencies) ]
[ alias all : boost_array test ]
;
call-if : boost-library array
;
+8
View File
@@ -14,3 +14,11 @@ http://www.boost.org/LICENSE_1_0.txt
* Converted documentation to AsciiDoc (Christian Mazakas).
* Added `noexcept` and `constexpr` as appropriate.
* Marked obsolete functions as deprecated.
* Removed obsolete compiler workarounds.
* Changed `array<T, 0>::begin()`, `cbegin()`, `end()`, `cend()` to return `nullptr`, enabling `constexpr`.
This matches the behavior of `std::array`.
* Removed local `hash_value` overload; `boost::hash` supports array-like types natively.
* `array<T, 0>` can now be initialized with `= {{}}`.
* Added `operator\<\=>`.
* Added `to_array`.
+52 -5
View File
@@ -35,10 +35,20 @@ namespace boost {
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 auto 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;
template<class T, std::size_t N>
constexpr array<T, N> to_array( T const (&)[N] );
template<class T, std::size_t N>
constexpr array<T, N> to_array( T (&&)[N] );
template<class T, std::size_t N>
constexpr array<T, N> to_array( T const (&&)[N] );
}
```
@@ -136,7 +146,7 @@ public:
template<typename U> array& operator=(const array<U, N>& other);
```
[horizontal]
Effects: :: `std::copy(rhs.begin(), rhs.end(), begin())`.
Effects: :: For each `i` in `[0..N)`, performs `elems[i] = other.elems[i];`.
---
@@ -233,7 +243,7 @@ constexpr const_reference operator[](size_type i) const;
[horizontal]
Requires: :: `i < N`.
Returns: :: `elems[i]`.
Throws: :: nothing.
Throws: :: Nothing.
---
@@ -254,7 +264,7 @@ constexpr const_reference front() const;
[horizontal]
Requires: :: `N > 0`.
Returns: :: `elems[0]`.
Throws: :: nothing.
Throws: :: Nothing.
---
@@ -265,7 +275,7 @@ constexpr const_reference back() const;
[horizontal]
Requires: :: `N > 0`.
Returns: :: `elems[N-1]`.
Throws: :: nothing.
Throws: :: Nothing.
---
@@ -302,7 +312,7 @@ Complexity: :: linear in `N`.
void fill(const T& value);
```
[horizontal]
Effects: :: for each `i` in `[0..N)`, performs `elems[i] = value;`.
Effects: :: For each `i` in `[0..N)`, performs `elems[i] = value;`.
---
@@ -382,6 +392,17 @@ Returns: :: `!(x < y)`.
---
```
template<typename T, std::size_t N>
constexpr auto operator<=>(const array<T, N>& x, const array<T, N>& y)
-> decltype(x[0] <=> y[0]);
```
[horizontal]
Effects: :: For each `i` in `[0..N)`, if `(x[i] \<\=> y[i]) != 0`, returns `x[i] \<\=> y[i]`. Otherwise, returns `std::strong_ordering::equal`, converted to the return type.
Remarks: :: When `N` is 0, the return type is `std::strong_ordering` and the return value is `std::strong_ordering::equal`.
---
### Specializations
```
@@ -403,3 +424,29 @@ Mandates: :: `Idx < N`.
Returns: :: `arr[Idx]`.
---
### Creation
```
template<class T, std::size_t N>
constexpr array<T, N> to_array( T const (&a)[N] );
```
[horizontal]
Returns: :: an `array<T, N>` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`.
```
template<class T, std::size_t N>
constexpr array<T, N> to_array( T (&&a)[N] );
```
[horizontal]
Returns: :: an `array<T, N>` `r` such that for each `i` in `[0..N)`, `r[i]` is moved from `std::move(a[i])`.
```
template<class T, std::size_t N>
constexpr array<T, N> to_array( T const (&&a)[N] );
```
[horizontal]
Returns: :: an `array<T, N>` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`.
---
+119 -43
View File
@@ -37,20 +37,26 @@
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
# pragma warning(push)
# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe
# pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated
# pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required
# 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) // class 'boost::array<T,N>' can never be instantiated - user defined constructor required
# pragma warning(disable: 4702) // unreachable code
#endif
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <algorithm>
#include <iterator>
#include <stdexcept>
#include <utility>
#include <cstddef>
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L
# if __has_include(<compare>)
# include <compare>
# endif
#endif
namespace boost {
template<class T, std::size_t N>
@@ -158,15 +164,29 @@ namespace boost {
// assignment with type conversion
template <typename T2>
array<T,N>& operator= (const array<T2,N>& rhs) {
std::copy(rhs.begin(),rhs.end(), begin());
array<T,N>& operator= (const array<T2,N>& rhs)
{
for( std::size_t i = 0; i < N; ++i )
{
elems[ i ] = rhs.elems[ i ];
}
return *this;
}
// fill with one value
BOOST_CXX14_CONSTEXPR 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
@@ -182,6 +202,8 @@ namespace boost {
template< class T >
class array< T, 0 > {
public:
struct {} elems; // enables initialization with = {{}}
public:
// type definitions
@@ -194,13 +216,13 @@ namespace boost {
typedef std::ptrdiff_t difference_type;
// iterator support
iterator begin() BOOST_NOEXCEPT { return iterator( reinterpret_cast< T * >( this ) ); }
const_iterator begin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); }
const_iterator cbegin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); }
BOOST_CXX14_CONSTEXPR iterator begin() BOOST_NOEXCEPT { return data(); }
BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT { return data(); }
BOOST_CONSTEXPR const_iterator cbegin() const BOOST_NOEXCEPT { return data(); }
iterator end() BOOST_NOEXCEPT { return begin(); }
const_iterator end() const BOOST_NOEXCEPT { return begin(); }
const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); }
BOOST_CXX14_CONSTEXPR iterator end() BOOST_NOEXCEPT { return begin(); }
BOOST_CONSTEXPR const_iterator end() const BOOST_NOEXCEPT { return begin(); }
BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); }
// reverse iterator support
typedef std::reverse_iterator<iterator> reverse_iterator;
@@ -290,19 +312,10 @@ namespace boost {
BOOST_CXX14_CONSTEXPR void fill (const T& ) {}
// check range (may be private because it is static)
static reference failed_rangecheck () {
std::out_of_range e("attempt to access element of an empty array");
boost::throw_exception(e);
#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__))
//
// We need to return something here to keep
// some compilers happy: however we will never
// actually get here....
//
static T placeholder;
return placeholder;
#endif
}
static reference failed_rangecheck ()
{
boost::throw_exception( std::out_of_range( "attempt to access element of an empty array" ) );
}
};
// comparisons
@@ -320,7 +333,7 @@ namespace boost {
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
template<class T>
BOOST_CXX14_CONSTEXPR bool operator== (const array<T, 0>& x, const array<T, 0>& y)
BOOST_CXX14_CONSTEXPR bool operator== (const array<T, 0>& /*x*/, const array<T, 0>& /*y*/)
{
return true;
}
@@ -347,7 +360,7 @@ namespace boost {
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
template<class T>
BOOST_CXX14_CONSTEXPR bool operator< (const array<T, 0>& x, const array<T, 0>& y)
BOOST_CXX14_CONSTEXPR bool operator< (const array<T, 0>& /*x*/, const array<T, 0>& /*y*/)
{
return false;
}
@@ -375,6 +388,32 @@ namespace boost {
x.swap(y);
}
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L
# if __has_include(<compare>)
template<class T, std::size_t N>
constexpr auto operator<=> (const array<T,N>& x, const array<T,N>& y)
-> decltype( x.elems[ 0 ] <=> y.elems[ 0 ] )
{
for( std::size_t i = 0; i < N; ++i )
{
auto r = x.elems[ i ] <=> y.elems[ i ];
if( r != 0 ) return r;
}
return std::strong_ordering::equal;
}
template<class T>
constexpr auto operator<=> (const array<T,0>& /*x*/, const array<T,0>& /*y*/)
-> std::strong_ordering
{
return std::strong_ordering::equal;
}
# endif
#endif
// undocumented and obsolete
template <typename T, std::size_t N>
BOOST_DEPRECATED( "please use `elems` instead" )
@@ -391,25 +430,62 @@ namespace boost {
return arg.elems;
}
template <class It> std::size_t hash_range(It, It);
template<class T, std::size_t N>
std::size_t hash_value(const array<T,N>& arr)
template <size_t Idx, typename T, size_t N>
BOOST_CXX14_CONSTEXPR T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT
{
return boost::hash_range(arr.begin(), arr.end());
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
return arr[Idx];
}
template <size_t Idx, typename T, size_t N>
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" );
return arr[Idx];
}
template <size_t Idx, typename T, size_t N>
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" );
return arr[Idx];
}
template <size_t Idx, typename T, size_t N>
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" );
return arr[Idx];
}
template<class T, std::size_t N>
BOOST_CXX14_CONSTEXPR array<T, N> to_array( T const (&a)[ N ] )
{
array<T, N> r = {};
for( std::size_t i = 0; i < N; ++i )
{
r[ i ] = a[ i ];
}
return r;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T, std::size_t N>
BOOST_CXX14_CONSTEXPR array<T, N> to_array( T (&&a)[ N ] )
{
array<T, N> r = {};
for( std::size_t i = 0; i < N; ++i )
{
r[ i ] = std::move( a[ i ] );
}
return r;
}
template<class T, std::size_t N>
BOOST_CXX14_CONSTEXPR array<T, N> to_array( T const (&&a)[ N ] )
{
array<T, N> r = {};
for( std::size_t i = 0; i < N; ++i )
{
r[ i ] = a[ i ];
}
return r;
}
#endif
} /* namespace boost */
+2 -2
View File
@@ -4,8 +4,8 @@
</head>
<body>
Automatic redirection failed, please go to
<a href="../../doc/html/array.html">doc/html/array.html</a> &nbsp;<hr>
<p>© Copyright Beman Dawes, 2001</p>
<a href="doc/html/array.html">doc/html/array.html</a> &nbsp;<hr>
<p>© Copyright Beman Dawes, 2001</p>
<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
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
+47 -3
View File
@@ -7,6 +7,41 @@ import testing ;
import-search /boost/config/checks ;
import config : requires ;
project
: requirements
<library>/boost/array//boost_array
<library>/boost/core//boost_core
<warnings>extra
<toolset>msvc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>gcc-4.6:<cxxflags>-Wno-missing-braces
<toolset>gcc-4.7:<cxxflags>-Wno-missing-braces
<toolset>gcc-4.6:<cxxflags>-Wno-missing-field-initializers
<toolset>gcc-4.7:<cxxflags>-Wno-missing-field-initializers
<toolset>gcc-4.8:<cxxflags>-Wno-missing-field-initializers
<toolset>gcc-4.9:<cxxflags>-Wno-missing-field-initializers
<toolset>gcc-4.6:<cxxflags>-Wno-type-limits
<toolset>gcc-4.7:<cxxflags>-Wno-type-limits
<toolset>gcc-10:<cxxflags>-Wno-type-limits
<toolset>clang:<cxxflags>-Wno-unnamed-type-template-args
<toolset>clang-3.5:<cxxflags>-Wno-missing-braces
<toolset>clang-3.6:<cxxflags>-Wno-missing-braces
<toolset>clang-3.7:<cxxflags>-Wno-missing-braces
<toolset>clang-3.8:<cxxflags>-Wno-missing-braces
<toolset>clang-3.9:<cxxflags>-Wno-missing-braces
<toolset>clang-4:<cxxflags>-Wno-missing-braces
<toolset>clang-5:<cxxflags>-Wno-missing-braces
;
#
run array0.cpp ;
@@ -20,11 +55,13 @@ run array7.cpp ;
compile array_constexpr.cpp ;
compile-fail array_getfail1.cpp ;
compile-fail array_getfail2.cpp ;
compile-fail array_getfail1.cpp
: <warnings>off ;
compile-fail array_getfail2.cpp
: <warnings>off ;
run array_hash.cpp
: : : [ requires cxx11_noexcept ] ;
: : : <library>/boost/container_hash//boost_container_hash [ requires cxx11_noexcept ] ;
#
@@ -45,7 +82,9 @@ run array_swap_test.cpp ;
run array_swap_test2.cpp ;
run array_eq_test.cpp ;
run array_lt_test.cpp ;
run array_thw_test.cpp ;
run array_get_test.cpp ;
run to_array_test.cpp ;
# C++11 constexpr
@@ -59,8 +98,13 @@ compile array_get_test_cx.cpp ;
# C++14 constexpr
compile array_assign_test_cx.cpp ;
compile array_access_test_cx2.cpp ;
compile array_fill_test_cx.cpp ;
compile array_eq_test_cx.cpp ;
compile array_lt_test_cx.cpp ;
compile array_thw_test_cx.cpp ;
compile to_array_test_cx.cpp ;
#
+9 -4
View File
@@ -5,11 +5,11 @@
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/array.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <algorithm>
#include <string>
#include <iostream>
#include <boost/array.hpp>
#include <boost/core/lightweight_test_trait.hpp>
namespace {
@@ -44,7 +44,12 @@ void RunTests()
BOOST_TEST ( const_test_case.begin() == const_test_case.end());
BOOST_TEST ( const_test_case.cbegin() == const_test_case.cend());
BOOST_TEST ( test_case.begin() != const_test_case.begin() );
// BOOST_TEST ( test_case.begin() != const_test_case.begin() );
//
// TR1 specified that begin() must return a unique value for zero-sized
// arrays. However, this makes constexpr unimplementable, and all standard
// libraries have converged on using nullptr instead (see LWG issue 2157.)
if( test_case.data() == const_test_case.data() ) {
// Value of data is unspecified in TR1, so no requirement this test pass or fail
// However, it must compile!
+2
View File
@@ -5,6 +5,8 @@
* http://www.boost.org/LICENSE_1_0.txt)
*/
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // assign
#include <iostream>
#include <boost/array.hpp>
+10 -2
View File
@@ -5,12 +5,20 @@
* http://www.boost.org/LICENSE_1_0.txt)
*/
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // get_c_array
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <string>
#include <iostream>
#include <boost/array.hpp>
#include <algorithm>
#include <boost/core/lightweight_test_trait.hpp>
#if defined(BOOST_GCC) && BOOST_GCC / 10000 == 13
// false -Warray-bounds positive when using -fsanitize=undefined
// restricted to GCC 13 because that's what is tested on Drone
# pragma GCC diagnostic ignored "-Warray-bounds"
#endif
namespace {
template< class T >
+2
View File
@@ -5,6 +5,8 @@
* http://www.boost.org/LICENSE_1_0.txt)
*/
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // std::get
#include <string>
#include <iostream>
#include <boost/array.hpp>
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#define BOOST_ENABLE_ASSERT_HANDLER
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
+45
View File
@@ -0,0 +1,45 @@
// 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> constexpr boost::array<T, N> modified( boost::array<T, N> a1 )
{
a1.front() = 1;
a1[ 1 ] = 2;
a1.at( 2 ) = 3;
a1.back() = 4;
return a1;
}
template<class T> void test1()
{
constexpr boost::array<T, 4> a1 = {};
constexpr boost::array<T, 4> a2 = modified( a1 );
STATIC_ASSERT( a2[0] == 1 );
STATIC_ASSERT( a2[1] == 2 );
STATIC_ASSERT( a2[2] == 3 );
STATIC_ASSERT( a2[3] == 4 );
}
int main()
{
test1<int>();
}
#endif
+8 -3
View File
@@ -1,13 +1,18 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#define BOOST_ALLOW_DEPRECATED_SYMBOLS
// assign is a deprecated nonstandard equivalent of fill
#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
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
template<class T, std::size_t N> void test()
{
+54
View File
@@ -0,0 +1,54 @@
// 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> constexpr boost::array<T, N> assigned( boost::array<T, N> const& a1 )
{
boost::array<T, N> a2 = {};
a2 = a1;
return a2;
}
template<class T> void test1()
{
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
constexpr boost::array<T, 4> a2 = assigned( a1 );
STATIC_ASSERT( a1[0] == a2[0] );
STATIC_ASSERT( a1[1] == a2[1] );
STATIC_ASSERT( a1[2] == a2[2] );
STATIC_ASSERT( a1[3] == a2[3] );
}
template<class T> void test2()
{
constexpr boost::array<T, 0> a1 = {};
constexpr boost::array<T, 0> a2 = assigned( a1 );
(void)a1;
(void)a2;
}
int main()
{
test1<int>();
test2<int>();
}
#endif
+4 -3
View File
@@ -1,6 +1,8 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#define BOOST_ALLOW_DEPRECATED_SYMBOLS
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -8,8 +10,7 @@
#include <boost/config/workaround.hpp>
#include <cstddef>
// c_array and get_c_array are nonstandard extensions
// probably need to be deprecated and removed
// c_array and get_c_array are deprecated nonstandard extensions
template<class T, std::size_t N> void test()
{
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
+3 -3
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -44,11 +44,11 @@ template<class T> void test4()
int main()
{
// test1<int, 0>();
test1<int, 0>();
test1<int, 1>();
test1<int, 7>();
// test1<int const, 0>();
test1<int const, 0>();
test1<int const, 1>();
test1<int const, 7>();
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
+5 -1
View File
@@ -1,11 +1,15 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
template<class T, std::size_t N> void test()
{
{
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
+5 -1
View File
@@ -1,11 +1,15 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
template<class T, std::size_t N> void test()
{
boost::array<T, N> a = {};
+51
View File
@@ -0,0 +1,51 @@
// 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> constexpr boost::array<T, N> filled( T const& v )
{
boost::array<T, N> r = {};
r.fill( v );
return r;
}
template<class T> void test1()
{
constexpr boost::array<T, 4> a1 = filled<T, 4>( 7 );
STATIC_ASSERT( a1[0] == 7 );
STATIC_ASSERT( a1[1] == 7 );
STATIC_ASSERT( a1[2] == 7 );
STATIC_ASSERT( a1[3] == 7 );
}
template<class T> void test2()
{
constexpr boost::array<T, 0> a1 = filled<T, 0>( 7 );
(void)a1;
}
int main()
{
test1<int>();
test2<int>();
}
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
+8 -4
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -8,6 +8,10 @@
#include <boost/config/workaround.hpp>
#include <cstddef>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
template<class T, std::size_t N> void test1()
{
boost::array<T, N> a = {{}};
@@ -46,11 +50,11 @@ template<class T> void test4()
int main()
{
// test1<int, 0>();
test1<int, 0>();
test1<int, 1>();
test1<int, 7>();
// test1<int const, 0>();
test1<int const, 0>();
test1<int const, 1>();
test1<int const, 7>();
@@ -58,7 +62,7 @@ int main()
test2<int, 1>();
test2<int, 7>();
// test2<int const, 0>();
test2<int const, 0>();
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000)
+3 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
@@ -56,7 +56,8 @@ template<class T> void test4()
template<class T> void test5()
{
// constexpr boost::array<T, 0> a = {{}};
constexpr boost::array<T, 0> a = {{}};
(void)a;
}
template<class T> void test6()
+3 -3
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -94,11 +94,11 @@ template<class T> void test2()
int main()
{
// test<int, 0>();
test<int, 0>();
test<int, 1>();
test<int, 7>();
// test<int const, 0>();
test<int const, 0>();
test<int const, 1>();
test<int const, 7>();
+3 -6
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
@@ -39,20 +39,17 @@ 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, 0>();
test1<int, 1>();
test1<int, 7>();
// test2<int>();
test2<int>();
}
#endif
+5 -1
View File
@@ -1,11 +1,15 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
template<class T, std::size_t N> void test()
{
{
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
+3 -3
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -76,11 +76,11 @@ template<class T, std::size_t N> void test()
int main()
{
// test<int, 0>();
test<int, 0>();
test<int, 1>();
test<int, 7>();
// test<int const, 0>();
test<int const, 0>();
test<int const, 1>();
test<int const, 7>();
+7 -3
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -15,6 +15,8 @@ template<class T, std::size_t N> void test1()
BOOST_TEST_EQ( a.size(), N );
BOOST_TEST_EQ( a.empty(), N == 0 );
BOOST_TEST_EQ( a.max_size(), N );
(void)a; // msvc-12.0
}
{
@@ -23,6 +25,8 @@ template<class T, std::size_t N> void test1()
BOOST_TEST_EQ( a.size(), N );
BOOST_TEST_EQ( a.empty(), N == 0 );
BOOST_TEST_EQ( a.max_size(), N );
(void)a; // msvc-12.0
}
}
@@ -49,11 +53,11 @@ template<class T, std::size_t N> void test3()
int main()
{
// test1<int, 0>();
test1<int, 0>();
test1<int, 1>();
test1<int, 7>();
// test1<int const, 0>();
test1<int const, 0>();
test1<int const, 1>();
test1<int const, 7>();
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/config.hpp>
+5 -1
View File
@@ -1,11 +1,15 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
template<class T, std::size_t N> void test()
{
boost::array<T, N> a1 = {};
+5 -1
View File
@@ -1,11 +1,15 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
template<class T, std::size_t N> void test()
{
boost::array<T, N> a1 = {};
+102
View File
@@ -0,0 +1,102 @@
// 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/pragma_message.hpp>
#include <cstddef>
#if defined(__has_include)
# if __has_include(<compare>)
# define HAS_COMPARE
# endif
#endif
#if !defined(__cpp_impl_three_way_comparison)
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" )
int main() {}
#elif !( __cpp_impl_three_way_comparison >= 201907L )
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) )
int main() {}
#elif !defined(HAS_COMPARE)
BOOST_PRAGMA_MESSAGE( "Test skipped because <compare> is not available" )
int main() {}
#else
template<class T, std::size_t N> void test()
{
constexpr auto eq = 0 <=> 0;
constexpr auto lt = 0 <=> 1;
constexpr auto gt = 1 <=> 0;
{
boost::array<T, N> const a1 = {};
boost::array<T, N> const a2 = {};
BOOST_TEST( ( a1 <=> a2 ) == eq );
}
{
boost::array<T, N> a1;
boost::array<T, N> a2;
a1.fill( 1 );
a2.fill( 1 );
BOOST_TEST( ( a1 <=> a2 ) == eq );
}
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 ) == lt );
{
boost::array<T, N> const a3 = a1;
boost::array<T, N> const a4 = a2;
BOOST_TEST( ( a3 <=> a4 ) == lt );
}
a1[ i ] = 2;
BOOST_TEST( ( a1 <=> a2 ) == gt );
{
boost::array<T, N> const a3 = a1;
boost::array<T, N> const a4 = a2;
BOOST_TEST( ( a3 <=> a4 ) == gt );
}
}
}
int main()
{
test<int, 0>();
test<int, 1>();
test<int, 7>();
test<float, 0>();
test<float, 1>();
test<float, 7>();
return boost::report_errors();
}
#endif
+81
View 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/config.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/config/workaround.hpp>
#include <cstddef>
#if defined(__has_include)
# if __has_include(<compare>)
# define HAS_COMPARE
# endif
#endif
#if !defined(__cpp_impl_three_way_comparison)
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" )
int main() {}
#elif !( __cpp_impl_three_way_comparison >= 201907L )
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) )
int main() {}
#elif !defined(HAS_COMPARE)
BOOST_PRAGMA_MESSAGE( "Test skipped because <compare> is not available" )
int main() {}
#else
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
template<class T, std::size_t N> void test1()
{
constexpr auto eq = 0 <=> 0;
constexpr boost::array<T, N> a1 = {};
constexpr boost::array<T, N> a2 = {};
STATIC_ASSERT( ( a1 <=> a2 ) == eq );
}
template<class T> void test2()
{
constexpr auto eq = 0 <=> 0;
constexpr auto lt = 0 <=> 1;
constexpr auto gt = 1 <=> 0;
{
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 4 }};
STATIC_ASSERT( ( a1 <=> a2 ) == eq );
}
{
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 5 }};
STATIC_ASSERT( ( a1 <=> a2 ) == lt );
}
{
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 2 }};
STATIC_ASSERT( ( a1 <=> a2 ) == gt );
}
}
int main()
{
test1<int, 0>();
test1<int, 1>();
test1<int, 7>();
test2<int>();
}
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
#include <boost/core/lightweight_test_trait.hpp>
-1
View File
@@ -11,7 +11,6 @@ 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)
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright 2023 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/array.hpp>
+109
View File
@@ -0,0 +1,109 @@
// 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 <memory>
#include <utility>
boost::array<int, 3> f1()
{
boost::array<int, 3> r = {{ 1, 2, 3 }};
return r;
}
boost::array<int, 3> const f2()
{
boost::array<int, 3> r = {{ 1, 2, 3 }};
return r;
}
int main()
{
{
int a[] = { 1, 2, 3 };
boost::array<int, 3> b = boost::to_array( a );
BOOST_TEST_EQ( b[0], 1 );
BOOST_TEST_EQ( b[1], 2 );
BOOST_TEST_EQ( b[2], 3 );
}
{
int const a[] = { 1, 2, 3 };
boost::array<int, 3> b = boost::to_array( a );
BOOST_TEST_EQ( b[0], 1 );
BOOST_TEST_EQ( b[1], 2 );
BOOST_TEST_EQ( b[2], 3 );
}
{
boost::array<int, 3> b = boost::to_array( f1().elems );
BOOST_TEST_EQ( b[0], 1 );
BOOST_TEST_EQ( b[1], 2 );
BOOST_TEST_EQ( b[2], 3 );
}
{
boost::array<int, 3> b = boost::to_array( f2().elems );
BOOST_TEST_EQ( b[0], 1 );
BOOST_TEST_EQ( b[1], 2 );
BOOST_TEST_EQ( b[2], 3 );
}
#if BOOST_CXX_VERSION >= 201103L
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
{
int a[] = { 1, 2, 3 };
boost::array<int, 3> b = boost::to_array( std::move( a ) );
BOOST_TEST_EQ( b[0], 1 );
BOOST_TEST_EQ( b[1], 2 );
BOOST_TEST_EQ( b[2], 3 );
}
{
int const a[] = { 1, 2, 3 };
boost::array<int, 3> b = boost::to_array( std::move( a ) );
BOOST_TEST_EQ( b[0], 1 );
BOOST_TEST_EQ( b[1], 2 );
BOOST_TEST_EQ( b[2], 3 );
}
#endif
#if !BOOST_WORKAROUND(BOOST_GCC, < 40900) && !BOOST_WORKAROUND(BOOST_CLANG_VERSION, < 30800)
{
boost::array<int, 3> b = boost::to_array({ 1, 2, 3 });
BOOST_TEST_EQ( b[0], 1 );
BOOST_TEST_EQ( b[1], 2 );
BOOST_TEST_EQ( b[2], 3 );
}
#endif
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1920)
{
std::unique_ptr<int> a[] = { {}, {}, {} };
boost::array<std::unique_ptr<int>, 3> b = boost::to_array( std::move( a ) );
(void)b;
}
#endif
#endif
return boost::report_errors();
}
+32
View File
@@ -0,0 +1,32 @@
// 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__)
int main()
{
{
constexpr int a[] = { 1, 2, 3, 4 };
constexpr boost::array<int, 4> b = boost::to_array( a );
STATIC_ASSERT( b[0] == 1 );
STATIC_ASSERT( b[1] == 2 );
STATIC_ASSERT( b[2] == 3 );
STATIC_ASSERT( b[3] == 4 );
}
}
#endif