Compare commits

...

254 Commits

Author SHA1 Message Date
61bbcbf341 Disable warnings for compile-fail tests 2025-01-27 19:53:31 +02:00
59e9940d5b Suppress false -Warray-bounds positive with -fsanitize=undefined 2025-01-27 19:53:16 +02:00
771750f7e1 Supress GCC and Clang warnings 2025-01-27 19:00:30 +02:00
75db85d1e9 Suppress MSVC unreachable code warnings 2025-01-27 18:23:43 +02:00
49e2a46c3a Enable warnings=extra, warnings-as-errors=on in test suite 2025-01-27 17:41:50 +02:00
07a14f33ef Update revision history 2025-01-27 17:19:06 +02:00
047ba01807 Update documentation 2025-01-27 17:16:50 +02:00
45de3be80c Add array_thw_test_cx.cpp 2025-01-27 04:03:06 +02:00
68db6ebd2d Add operator<=> overload for zero-sized arrays 2025-01-27 03:59:32 +02:00
329e59454f Add float tests to array_thw_test, as floats use std::partial_ordering 2025-01-27 03:55:13 +02:00
9a4010b88b Add operator<=>, array_thw_test.cpp 2025-01-27 03:40:19 +02:00
527ff0a80d Update revision history 2025-01-26 22:07:42 +02:00
f017dac435 Enable failing tests 2025-01-26 21:26:46 +02:00
567ba40840 Add a dummy element to array<T, 0> to enable initialization with = {{}} 2025-01-26 21:15:39 +02:00
29700ff270 Update revision history 2025-01-26 21:02:26 +02:00
b147799665 Remove local hash_value overload; boost::hash supports array-like types natively. 2025-01-26 20:35:19 +02:00
acef60446a Update revision history 2025-01-26 20:31:53 +02:00
3d9f39814c Re-enable failing tests 2025-01-26 19:23:41 +02:00
89f09e33f1 Change array<T, 0>::begin() to return nullptr and make it constexpr. 2025-01-26 19:21:39 +02:00
43326390d9 Reenable failing test 2025-01-26 08:19:00 +02:00
c95d855018 Remove obsolete workaround from failed_rangecheck 2025-01-26 08:09:41 +02:00
0a72026887 Update revision history 2025-01-26 06:09:05 +02:00
d2c295b85f Add array_access_test_cx2.cpp 2025-01-26 05:53:09 +02:00
324827cfc0 Add array_assign_test_cx.cpp 2025-01-26 05:45:36 +02:00
9253e8f1af Add array_fill_test_cx.cpp 2025-01-26 05:41:56 +02:00
cd0532b8fa Remove inclusion of <algorithm> 2025-01-26 05:08:42 +02:00
6a9e8c78da Update documentation of swap. 2025-01-26 04:11:14 +02:00
55bc631d40 Remove use of core/invoke_swap 2025-01-26 04:08:06 +02:00
435b293467 Mark std::get illegal overloads as deprecated 2025-01-26 03:16:23 +02:00
6447b408b2 Remove idef-ed out overload of get_c_array 2025-01-26 03:10:59 +02:00
17b49d86ad Mark get_c_array as deprecated 2025-01-26 03:10:23 +02:00
fe60e163c7 Remove obsolete Sun workaround 2025-01-26 03:07:53 +02:00
16280f660b Mark assign as deprecated 2025-01-26 03:06:28 +02:00
16b6ba8d84 Mark c_array as deprecated 2025-01-25 23:20:31 +02:00
f5a3f1b34a Remove obsolete reverse_iterator workarounds 2025-01-25 23:12:34 +02:00
9e2868f8e2 Reorder includes 2025-01-25 23:10:41 +02:00
4f2ed73766 Add array_get_test_cx.cpp 2025-01-25 21:20:12 +02:00
b32a6cfcfd Work around GCC 5..8 constexpr comparison failures 2025-01-25 20:59:46 +02:00
50cf6ebba7 Disable array_access_test_cx for GCC 4.x 2025-01-25 20:51:36 +02:00
ec05d6ca34 Disable array_iterator_test_cx for GCC 4.x 2025-01-25 20:50:45 +02:00
18ec6239b2 Disable array_data_test_cx for GCC 4.x 2025-01-25 20:49:14 +02:00
b44be8da89 Disable array_copy_test_cx for GCC 4.x 2025-01-25 20:47:36 +02:00
ea9dbd5674 Disable array_init_test_cx for GCC 4.x 2025-01-25 20:46:20 +02:00
5c05254afb Add array_lt_test_cx.cpp 2025-01-25 20:32:38 +02:00
a211468866 Add array_eq_test_cx.cpp 2025-01-25 20:24:15 +02:00
c06cadc04f Add array_access_test_cx.cpp 2025-01-25 20:09:17 +02:00
f155831795 Add array_iterator_test_cx.cpp 2025-01-25 20:02:57 +02:00
7ca2f112a2 Disable constexpr data() test for msvc-14.0 2025-01-25 19:42:21 +02:00
19f02c7615 Add array_data_test_cx.cpp 2025-01-25 19:38:01 +02:00
66386e8eda Add array_copy_test_cx.cpp 2025-01-25 19:29:47 +02:00
54d839c8bc Add array_size_test_cx.cpp 2025-01-25 19:23:50 +02:00
e7663434ee Add array_init_test_cx.cpp 2025-01-25 19:18:22 +02:00
52406dfcc0 Add revision history 2025-01-25 18:06:00 +02:00
9b8a342f44 Update documentation 2025-01-25 18:00:27 +02:00
01983ff604 Remove GCC 4.4 from Drone 2025-01-15 21:12:57 +02:00
536412674f Add Drone support 2025-01-15 20:52:27 +02:00
8c5f36ae52 array<T, 0> access operations are never constexpr 2025-01-15 20:18:14 +02:00
9d6b871972 Work around GCC 4.x constexpr failure in operator[] 2025-01-15 19:57:39 +02:00
79ca787bfe Add more constexpr to match std::array 2025-01-12 03:31:49 +02:00
0da094a21d Add BOOST_NOEXCEPT as needed to match std::array 2025-01-12 03:31:49 +02:00
2099995189 Uncomment BOOST_CONSTEXPR; update and enable test/array_constexpr.cpp 2025-01-12 03:31:49 +02:00
31b9fdd397 Add array_get_test.cpp 2025-01-12 03:20:46 +02:00
dca9ae1a60 Add array_lt_test.cpp 2025-01-12 03:01:00 +02:00
ff5eb67906 Add array_eq_test.cpp 2025-01-12 02:51:15 +02:00
7223d3dfcb Add array_swap_test2.cpp 2025-01-11 22:05:37 +02:00
c549abb184 Add array_swap_test.cpp 2025-01-11 22:01:01 +02:00
cbd8e1a8dc Add array_assign_test.cpp 2025-01-11 21:56:12 +02:00
4e3d4ef99f Add array_fill_test.cpp 2025-01-11 21:51:06 +02:00
63f8f022e2 Add array_c_array_test.cpp 2025-01-11 21:29:33 +02:00
8d1871b4c2 Add array_access_test.cpp 2025-01-11 04:30:54 +02:00
c0488c00a3 Add array_size_test.cpp 2025-01-11 04:13:41 +02:00
48b07e63fb Add array_reverse_test.cpp 2025-01-10 05:00:39 +02:00
8999204cae Add array_iterator_test.cpp 2025-01-10 04:53:08 +02:00
c5741a92e7 Add array_data_test.cpp 2025-01-10 04:40:35 +02:00
1ae515a17d Update array_copy_test 2025-01-10 04:09:16 +02:00
72997add96 Add array_convert_test.cpp 2025-01-10 04:07:38 +02:00
51fbc208d9 Add array_copy_test.cpp 2025-01-10 04:03:14 +02:00
7fac30e1ab Fix msvc-14.0, gcc-4.x failures 2025-01-10 03:37:10 +02:00
049e98dd57 Add array_init_test.cpp 2025-01-10 03:30:57 +02:00
e0bd7e8560 Add array_elems_test.cpp 2025-01-10 03:00:00 +02:00
f9bb980a0b Add array_typedef_test.cpp 2025-01-09 21:01:41 +02:00
fd24e0592c Add boostdoc, boostrelease targets to doc/Jamfile.v2 2025-01-09 20:49:37 +02:00
ea54ab1610 Update index.html 2025-01-06 18:45:57 +02:00
cd6244f787 Merge pull request #26 from cmazakas/asciidoc-refactor
refactor documentation to use asciidoc
2025-01-06 18:41:38 +02:00
99c3a4b966 refactor documentation to use asciidoc 2024-12-19 10:57:58 -08:00
22b8eebc3c Apply Node20 workaround 2024-12-16 02:53:18 +02:00
fed8935fdf Add GCC 4.9 to ci.yml 2024-11-04 04:42:52 +02:00
9ea71dd967 Update ci.yml 2024-11-04 03:45:50 +02:00
9a11abcb9f Disable array_hash.cpp under C++03 2024-11-04 03:43:06 +02:00
f9c01c811a Update ci.yml 2024-11-04 03:31:57 +02:00
23f6b27c0d Add meaningless change to force rebuild 2024-04-11 11:37:03 -07:00
ecc47cb42c Merge branch 'feature/use_invoke_swap' of https://github.com/Lastique/array into feature/pr-20 2023-09-08 09:57:29 +03:00
d9ccba0907 Update ci.yml 2023-09-08 09:49:45 +03:00
bdc9ff1e24 Add CMake tests 2023-09-08 09:47:09 +03:00
8ad6749d4a Update test/Jamfile 2023-09-08 09:38:28 +03:00
ec72fd87a1 Regenerate CMakeLists.txt 2023-09-08 09:36:13 +03:00
3dfc2a089c Update ci.yml 2023-09-08 09:35:15 +03:00
b19ce675ad Trim trailing spaces. 2023-09-03 00:06:37 +03:00
c774c93b3b Switch to boost::core::invoke_swap.
boost::swap is deprecated and will be removed. Use boost::core::invoke_swap
as a replacement.
2023-09-03 00:05:33 +03:00
868af27d82 Merge pull request #19 from fanquake/use_core_swap
refactor: use core/swap.hpp over boost/swap.hpp
2022-08-23 09:23:28 -07:00
4647fc7095 refactor: use core/swap.hpp over boost/swap.hpp
The later is deprecated:
```cpp
ifndef BOOST_SWAP_HPP
define BOOST_SWAP_HPP

// The header file at this path is deprecated;
// use boost/core/swap.hpp instead.

include <boost/core/swap.hpp>

endif

```
2022-08-23 15:55:19 +01:00
9cc63ae0dd Merge pull request #18 from renbaoshuo/patch-1
chore: bump macos runner version
2022-07-26 09:51:51 -07:00
a3f15458b8 chore: bump macos runner version
GitHub Action is sunsetting the macOS 10.15 Actions runner. It will stop working intermittently until being completely removed by 2022-8-30: https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22
2022-07-25 18:03:08 +08:00
a9a3dbbc41 Merge pull request #16 from sdarwin/feature/gha_fix_1
Update GitHub Actions CI file
2021-08-04 07:08:17 -07:00
e384e3780b Update GitHub Actions CI file 2021-07-30 16:10:15 +00:00
63f83dc350 Merge branch 'master' into develop 2021-06-10 01:29:29 +03:00
37c18b3094 Update CMakeLists.txt 2021-06-10 01:22:46 +03:00
42d974e5df Merge pull request #15 from sdarwin/githubactions
GitHub Actions config
2021-03-03 18:17:33 -08:00
1572eac629 Add GitHub Actions config [ci skip] 2021-03-01 15:31:58 +00:00
0db8c56d3f Merge pull request #14 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-18 18:26:54 -08:00
674234d401 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-18 20:49:35 -05:00
427c8fad2f Merge pull request #13 from sdarwin/drone
Drone config; I have no idea if this is right or not; Let's give it a try.
2021-01-07 20:47:11 -08:00
f0e79b8ebc add drone config [ci skip] 2021-01-07 18:08:52 +00:00
d026fbcee3 Merge changes from develop for the 1.74.0 release 2020-06-26 10:22:51 -07:00
92f66a9f14 Merge pull request #11 from Lastique/patch-1
Avoid using deprecated header iterator.hpp
2020-05-10 12:40:34 -07:00
e329330031 Avoid using deprecated header iterator.hpp
<boost/detail/iterator.hpp> is marked deprecated and is going to be removed in a future release. Replace it with <iterator> to avoid deprecation warnings.
2020-05-10 19:39:21 +03:00
32b074c9ae Array: Merge bug fixes to master for 1.72.0 beta 2019-12-03 07:47:51 -08:00
453cf59eb9 Replace Boost.Test with lightweight_test from Boost.Core. Modified version of https://github.com/boostorg/array/pull/6. Thanks to mloskot for the patch. 2019-07-10 15:25:46 -07:00
520d8987f7 Merge bug fixes to master for 1.70 2019-03-07 06:33:59 -08:00
b279a9005b Fix off-by-one error in range-checking for 'at()'. thanks to DHilbrich for the bug report. 2019-02-07 07:52:11 -08:00
854215e54c Merge pull request #7 from Mike-Devel/feature/min_cmake
Add minimal make file; Sorry for the long delay.
2019-01-14 09:52:33 -08:00
ee03e0bae8 [CI] Add travis file 2018-12-07 11:34:20 +01:00
e5f4af3dd2 [CMake] Add self-test for cmake 2018-12-07 11:34:20 +01:00
85e33cd138 [CMake] Generate cmake target that other libraries can use
... to express their dependency on this library and retrieve any
configuration information such as the include directory, binary
to link to (if any), transitive dependencies, necessary compiler
options or the required c++ standards level.
2018-12-07 11:31:02 +01:00
8f3aea2200 Merge array bug fixes to master 2017-01-31 08:00:48 -08:00
cef221d8b4 Merge pull request #5 from Lastique/patch-1
Fix compilation for Oracle Studio 12.5
2017-01-23 20:00:25 -08:00
5d06f1074a Fix compilation for Oracle Studio 12.5
The compiler expects a qualified dependent name after `typename`, so move `const` after the name.
2017-01-24 02:31:27 +04:00
4c27456a43 Copy doc jamfile from develop
It's need to build the documentation now.
2016-10-27 20:12:38 +01:00
16824fe0f1 Add, and update, documentation build targets. 2016-10-07 23:03:40 -05:00
0d4fa276f4 Merge pull request #3 from boostorg/pull_request/remove_hash_fwd
Replace inclusion of hash_fwd.hpp with a declaration of hash_range. Patch from Peter Dimov.
2015-01-08 14:10:08 -08:00
cb4df41bd6 Replace inclusion of hash_fwd.hpp with a declaration of hash_range 2015-01-09 00:01:41 +02:00
cd9888316a Merge pull request #2 from danieljames/metadata
Create metadata file.
2014-08-18 09:16:48 -07:00
ce71078681 Add metadata file. 2014-08-18 14:57:18 +01:00
9678f6aa3b Create merge base for git. 2014-04-06 13:53:46 +01:00
c0b1609ddb Merge r86524 (Correct broken links to C++ standard papers); fixes #9212
[SVN r86673]
2013-11-13 03:22:55 +00:00
dfeb6bd0a5 Correct broken links to C++ standard papers. Refs #9212.
[SVN r86524]
2013-10-30 12:51:24 +00:00
1966dd034b Updated license and copyright
[SVN r86311]
2013-10-14 21:35:20 +00:00
40c5dae84c Remove tabs
[SVN r86310]
2013-10-14 21:31:19 +00:00
4584f63f01 Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
[SVN r86248]
2013-10-11 23:20:59 +00:00
2e0052d49f Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Process #ifndef...#endif conditions.

[SVN r86244]
2013-10-11 23:15:00 +00:00
6ad6249e1c Array: Remove obsolete MSVC version check.
[SVN r85903]
2013-09-25 13:51:37 +00:00
a73b6fb582 Merged boost::algorithm::gather and updated tests for Utility, Algorithm and Utility libraries
[SVN r83154]
2013-02-25 18:43:26 +00:00
12fcbb59c2 Back out some of the constexpr support Boost.Array; it crashes gcc
[SVN r82906]
2013-02-15 17:11:09 +00:00
4a60b8c146 Add constexpr support to Boost.Array
[SVN r82834]
2013-02-12 18:07:15 +00:00
117584a2ce Update Boost.Array tests to use newer Boost.Test features
[SVN r82822]
2013-02-11 17:16:55 +00:00
97a26a1599 Documented boost::get support in Boost.Array
[SVN r82105]
2012-12-19 20:32:34 +00:00
88abb34b4d Fix bug where failure test failed for the wrong reason on C++03
[SVN r82102]
2012-12-19 17:49:04 +00:00
e02e7dcc00 Add boost::get<> support to Boost.Array
[SVN r82089]
2012-12-19 00:53:31 +00:00
daeb19f693 Add support for std::get<> to Boost.Array
[SVN r82083]
2012-12-18 17:59:08 +00:00
ba1a2437cf Merge doc changes to release; fixes #6988
[SVN r78948]
2012-06-14 16:01:03 +00:00
f41b1d2d4c Added a note about std::array in C++11
[SVN r78947]
2012-06-14 15:52:44 +00:00
3db6930a22 Added support Boost.Hash; checked in a test yesterday, but forgot to merge the actual code
[SVN r78581]
2012-05-24 13:04:02 +00:00
859fb5aa97 Merged changes for Boost.Array to release; adds support for Boost.Hash
[SVN r78558]
2012-05-23 16:35:13 +00:00
f4a0cbd364 Added support for Boost.Hash to Boost.Array; fixes #6791
[SVN r77976]
2012-04-14 18:07:34 +00:00
992299f2bf Use BOOST_ASSERT_MSG instead of naked BOOST_ASSERT
[SVN r77135]
2012-02-28 18:47:28 +00:00
5a97de6f2e Merge changes in Boost.Array to release
[SVN r70698]
2011-03-29 14:49:32 +00:00
eea368fadf Merge changes in Boost.Array to release
[SVN r70697]
2011-03-29 14:47:50 +00:00
e6a44cf529 Removed tabs
[SVN r70442]
2011-03-22 23:55:20 +00:00
111e93aa4c qualify array to avoid conflict with std::array; Refs #5233
[SVN r69291]
2011-02-26 01:35:48 +00:00
5072c551ec Pathscale-4.0 configuration code/workarounds.
[SVN r68142]
2011-01-14 02:59:34 +00:00
26edbea113 Merging changes to release; fixes #4761
[SVN r68100]
2011-01-13 15:49:03 +00:00
97e912e82e Added crbegin and crend to Boost.Array; refs #4761. Will close ticket when merged to release branch
[SVN r67481]
2010-12-28 19:14:23 +00:00
05aa660128 Added cbegin and cend to Boost.Array; refs #4761. Will close ticket when merged to release branch
[SVN r67478]
2010-12-28 18:39:14 +00:00
9644ee6662 Merged array changes to release; fixes #4757
[SVN r67477]
2010-12-28 18:28:22 +00:00
7256882760 Fix? for borland
[SVN r66781]
2010-11-26 20:16:34 +00:00
5329bd6f1c Slight tweak of get_c_array
[SVN r66712]
2010-11-24 16:13:12 +00:00
80fa50df2e SunPro workaround; references #4757
[SVN r66651]
2010-11-20 00:48:33 +00:00
6fbc8ee741 Added a test for 'get_c_array'
[SVN r66294]
2010-10-31 02:25:04 +00:00
38217688e1 Fix elems for Sun compilers
[SVN r66154]
2010-10-23 19:11:16 +00:00
a603bffc48 Merged Array changes to release
[SVN r63410]
2010-06-28 17:59:21 +00:00
2595eda739 Removed tabs
[SVN r62803]
2010-06-11 14:46:31 +00:00
64e5394540 Added get_c_array to Boost.Array
[SVN r62487]
2010-06-06 16:05:13 +00:00
c37498364e Detab array.hpp
[SVN r61415]
2010-04-19 21:41:21 +00:00
0c8902e8c2 Merged array changes from trunk to release; Fixes #3893 and #3168
[SVN r60824]
2010-03-25 15:32:12 +00:00
5e81100035 Added support for SunCC and 'fill' operation; tickets #3893 and #3168 respectively
[SVN r60436]
2010-03-10 18:03:30 +00:00
79cadb97d7 Changed exception throwing to use boost::throw_exception
[SVN r60417]
2010-03-10 14:23:49 +00:00
9609395af0 Applied patches to fix #2886
[SVN r59476]
2010-02-04 18:22:13 +00:00
fb72e72640 MSVC warning suppression - fixes #3599.
[SVN r59439]
2010-02-03 12:10:56 +00:00
88868ba0df Merged array changes from trunk to release
[SVN r58921]
2010-01-12 05:55:52 +00:00
e875287d55 rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
99631823f6 rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release.
[SVN r56941]
2009-10-17 01:10:45 +00:00
100b5d687b Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
5661b8cd63 Add basic copyright/license to keep cmake out of the inspection report
[SVN r55095]
2009-07-22 21:51:01 +00:00
7fb9412ea8 removed warning on vc++ for using std::equal
[SVN r54541]
2009-06-30 20:04:45 +00:00
86b069ad0e Merge [53104] and [53105] from the trunk
[SVN r53198]
2009-05-23 06:00:42 +00:00
471bc9bf06 Supress warnings in array
[SVN r53105]
2009-05-19 03:00:53 +00:00
9cf5e0c9a1 Use boost::swap instead of std::swap_ranges to enable ADL. Fixes #2753.
[SVN r53104]
2009-05-19 02:37:04 +00:00
3d20bb1310 merge of cmake build files from trunk per beman
[SVN r50756]
2009-01-24 18:57:20 +00:00
e7122b3f20 merge tests and Jamfiles for 7 libraries
[SVN r50456]
2009-01-04 05:17:02 +00:00
d2910e195a Updating dependency information for modularized libraries.
[SVN r49628]
2008-11-07 17:05:27 +00:00
b3ace9fb6e Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
a6b531b5b1 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
9804292dad Move array test into canonical test subdir structure.
[SVN r44376]
2008-04-13 22:12:12 +00:00
4dd2cf1b64 Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41370]
2007-11-25 18:38:02 +00:00
2e88dc228d Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2007-11-25 18:07:19 +00:00
0a4d7e81ef Starting point for releases
[SVN r39706]
2007-10-05 14:25:06 +00:00
96d4c5f737 This commit was manufactured by cvs2svn to create tag
'Version_1_34_1'.

[SVN r38286]
2007-07-24 19:28:14 +00:00
069b5e2ca1 Throw out_of_range rather than range_error. See 21.1.1 paragraph 13.
[SVN r36304]
2006-12-08 16:54:30 +00:00
526953fc5e Test for out_of_range rather than range_error. See 21.1.1 paragraph 13.
[SVN r36303]
2006-12-08 16:53:49 +00:00
5a23b06a83 Merged L & C issue fixes from trunk to branch.
[SVN r36225]
2006-12-01 11:34:43 +00:00
b06f12b0b7 Fixed license & copyright issues.
[SVN r36224]
2006-12-01 10:29:49 +00:00
e85feee293 Merged copyright and license addition
[SVN r35907]
2006-11-07 19:27:00 +00:00
f0bbb8b211 Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
b6522b3f60 (merge from head)
http://www.josuttis.com/ hasn't the latest version any more


[SVN r34856]
2006-08-08 18:53:30 +00:00
d7a5408143 http://www.josuttis.com/ hasn't the latest version any more
[SVN r34855]
2006-08-08 18:49:30 +00:00
3044ab376c Simplified code.
[SVN r34384]
2006-06-24 11:31:19 +00:00
564e4029d0 Simplified code.
[SVN r34384]
2006-06-24 11:31:19 +00:00
69188c998f Fix compiler errors resulting from missing return values.
[SVN r34259]
2006-06-09 11:40:07 +00:00
0dc11c2f23 Fix compiler errors resulting from missing return values.
[SVN r34259]
2006-06-09 11:40:07 +00:00
4c5212f5e4 Remove size zero support for old compilers that do not support partial template specialization
[SVN r34162]
2006-06-04 12:10:17 +00:00
7da1c4b310 Remove size zero support for old compilers that do not support partial template specialization
[SVN r34161]
2006-06-04 11:01:59 +00:00
276cd991f3 Support for zero length arrays
[SVN r34156]
2006-06-03 13:04:27 +00:00
8f10fdf27e Support for zero length arrays
[SVN r34154]
2006-06-03 12:51:13 +00:00
1f8298fb08 This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
b41f7fdebe Merged from Version_1_33_1
[SVN r31949]
2005-12-08 03:23:02 +00:00
2fde5e334b License update
[SVN r24990]
2004-09-09 13:59:01 +00:00
4ee6e051fe *** empty log message ***
[SVN r24128]
2004-07-27 20:00:34 +00:00
bac6446111 added debug bounds checking; added new empty() definition
[SVN r24127]
2004-07-27 19:58:09 +00:00
cfb6d6eae6 array.xml: documentation updates from Nico
[SVN r22066]
2004-01-30 03:51:06 +00:00
0543286830 Installed some updates from Nicolai Josuttis
[SVN r22065]
2004-01-30 03:32:19 +00:00
1c6f9ef038 index.htm renamed index.html
[SVN r21230]
2003-12-11 23:13:19 +00:00
d38c367afd Switch over to BoostBook documentation
[SVN r21068]
2003-12-02 06:40:44 +00:00
a5a75f81bd Updated to reflect BoostBook changes
[SVN r17941]
2003-03-15 23:12:35 +00:00
ab72ec517c Lots of cleanups as BoostBook becomes more strict
[SVN r17871]
2003-03-13 00:29:57 +00:00
8a119110be Import of BoostBook documentation for any, array, bind, function, ref, and
signals libraries.


[SVN r17866]
2003-03-12 23:27:25 +00:00
3daa34744f Added copyright
[SVN r17183]
2003-02-04 07:21:29 +00:00
0f3969f9e0 Add /libs/lib-name to comment
[SVN r16685]
2002-12-23 02:43:12 +00:00
c501468b53 Fixed reverse iterator workaround test, should now work with Intel C++ as well as VC7.
[SVN r16195]
2002-11-11 12:40:56 +00:00
faf0005e86 Added BOOST_DINKUMWARE_STDLIB macro
[SVN r16172]
2002-11-09 11:54:05 +00:00
785e98fcac No sense in failing just because a compiler doesn't implement correct for loop scoping!
[SVN r15327]
2002-09-15 04:04:10 +00:00
13d4e8bc40 Stripped tabs, added VC7+STLport fixes
[SVN r15193]
2002-09-07 10:45:04 +00:00
9ea2182afa One more attempt to get Intel config right.
[SVN r15166]
2002-09-05 10:18:10 +00:00
bf3b240686 Second try at fixing Intel errors, without messing up Intel+STLport config.
[SVN r15141]
2002-09-03 11:34:12 +00:00
6b9c6c9de3 Added (hopeful) Intel C++ fixes for broken std::reverse_iterator.
[SVN r15124]
2002-09-01 10:43:04 +00:00
fe013c42b7 Added a fix for non Microsoft compilers using Microsoft libraries.
[SVN r15068]
2002-08-23 14:32:39 +00:00
b87433497e array5.cpp:
- Add (redundant) braces around initializer to silence GCC


[SVN r12528]
2002-01-27 18:22:19 +00:00
09c271cf34 array3.cpp:
- Qualify std::swap for compilers that don't have Koenig lookup

array5.cpp:
  - Don't use std::boolalpha, because it isn't portable


[SVN r12463]
2002-01-23 18:07:11 +00:00
f5699ae164 Fixed reverse iterator declarations so that they work with VC7b2.
[SVN r12173]
2001-12-29 12:33:32 +00:00
f96ac657dd update from Nico
[SVN r10918]
2001-08-23 20:33:35 +00:00
7f73413eed Fix some broken links. Fix order of constructor initializers.
[SVN r10913]
2001-08-23 17:42:07 +00:00
640d1434bf Change absolute URL's to relative
[SVN r10594]
2001-07-12 15:31:15 +00:00
624bd0e218 1.21.1 run up, including new download instructions and fix broken hyperlinks
[SVN r9557]
2001-03-14 15:11:55 +00:00
ad82e2b25c All final 1.20.2 changes, including fixing broken hyperlinks
[SVN r9071]
2001-02-10 14:42:14 +00:00
44887bfe59 Added changelog
[SVN r8662]
2001-01-21 05:02:37 +00:00
fd76085150 Fix for STLport on MSVC
[SVN r8660]
2001-01-20 22:58:11 +00:00
aac83e6667 Replaced boolalpha use with something that the stock gcc library can handle.
[SVN r8659]
2001-01-20 22:36:49 +00:00
a673bc6e82 Broken iterator fix needs to apply to the Intel compiler too, because it uses the MSVC library
[SVN r8639]
2001-01-18 21:20:42 +00:00
a91e96a8ab Docs fixes (Nico)+ add return 0; to test files (Beman)
[SVN r8496]
2000-12-27 02:03:29 +00:00
debb0f0908 libraries.htm and people.htm moved to sub-directories to make root directory cleaner.
[SVN r8166]
2000-11-10 15:39:05 +00:00
52dadb9764 Cosmetic changes from Nico
[SVN r7881]
2000-09-30 21:14:45 +00:00
b62e1aa4e7 Cosmetic changes from Nico
[SVN r7880]
2000-09-30 20:54:15 +00:00
8c5daba6b3 I have no idea why CVS wants this file re-committed
[SVN r7867]
2000-09-28 12:41:28 +00:00
6533fa4606 Initial Graph and Regex HTML integration
[SVN r7849]
2000-09-26 19:02:50 +00:00
e3d87e942c Minor html fixes
[SVN r7771]
2000-09-22 18:10:39 +00:00
77 changed files with 5013 additions and 1004 deletions

346
.drone.jsonnet Normal file
View 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' },
),
]

23
.drone/drone.bat Normal file
View 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
View 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}

643
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,643 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-latest
container: ubuntu:16.04
install: g++-4.9-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-20.04
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: g++-11-multilib
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"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
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}}
container:
image: ${{matrix.container}}
volumes:
- /node20217:/node20217:rw,rshared
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
defaults:
run:
shell: bash
steps:
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python3 git g++ curl xz-utils
- name: Install nodejs20glibc2.17
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
run: |
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
ldd /__e/node20/bin/node
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: |
sudo apt-get update
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
python3 tools/boostdep/depinst/depinst.py -I examples $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
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
windows:
strategy:
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"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
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 -I examples --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- 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
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
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: 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
posix-cmake-install:
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 -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

217
.travis.yml Normal file
View File

@ -0,0 +1,217 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2018, Mike-Dev
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
python: "2.7"
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
# cmake self-test
- os: linux
env: TEST_CMAKE=TRUE #Only for easier identification in travis web gui
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/assert.git ../assert
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/core.git ../core
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/static_assert.git ../static_assert
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/throw_exception.git ../throw_exception
script:
- mkdir __build__ && cd __build__
- cmake ../test/test_cmake
- cmake --build .
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/array
- python tools/boostdep/depinst/depinst.py array
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
on_success: always

28
CMakeLists.txt Normal file
View File

@ -0,0 +1,28 @@
# Generated by `boostdep --cmake array`
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.20)
project(boost_array VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_array INTERFACE)
add_library(Boost::array ALIAS boost_array)
target_include_directories(boost_array INTERFACE include)
target_link_libraries(boost_array
INTERFACE
Boost::assert
Boost::config
Boost::core
Boost::static_assert
Boost::throw_exception
)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@ -1,169 +0,0 @@
<HTML>
<HEAD>
<TITLE>array.hpp</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;array.hpp
</B></FONT>
</TD></TR></TABLE><BR>
<BR><BR>
<TT>
<SPAN class="Source">
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;The&nbsp;following&nbsp;code&nbsp;declares&nbsp;class&nbsp;array,</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;an&nbsp;STL&nbsp;container&nbsp;(as&nbsp;wrapper)&nbsp;for&nbsp;arrays&nbsp;of&nbsp;constant&nbsp;size.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;See</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.josuttis.com/cppcode</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;for&nbsp;details&nbsp;and&nbsp;the&nbsp;latest&nbsp;version.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;(C)&nbsp;Copyright&nbsp;Nicolai&nbsp;M.&nbsp;Josuttis&nbsp;1999.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;Permission&nbsp;to&nbsp;copy,&nbsp;use,&nbsp;modify,&nbsp;sell&nbsp;and&nbsp;distribute&nbsp;this&nbsp;software</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;is&nbsp;granted&nbsp;provided&nbsp;this&nbsp;copyright&nbsp;notice&nbsp;appears&nbsp;in&nbsp;all&nbsp;copies.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;This&nbsp;software&nbsp;is&nbsp;provided&nbsp;"as&nbsp;is"&nbsp;without&nbsp;express&nbsp;or&nbsp;implied</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;warranty,&nbsp;and&nbsp;with&nbsp;no&nbsp;claim&nbsp;as&nbsp;to&nbsp;its&nbsp;suitability&nbsp;for&nbsp;any&nbsp;purpose.</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;Jul&nbsp;31,&nbsp;2000</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
#ifndef&nbsp;BOOST_ARRAY_HPP<BR>
#define&nbsp;BOOST_ARRAY_HPP<BR>
<BR>
#include&nbsp;&lt;cstddef&gt;<BR>
#include&nbsp;&lt;stdexcept&gt;<BR>
#include&nbsp;&lt;iterator&gt;<BR>
#include&nbsp;&lt;algorithm&gt;<BR>
<BR>
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;BUG-FIX&nbsp;for&nbsp;compilers&nbsp;that&nbsp;don't&nbsp;support</FONT></I><BR>
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;std::size_t&nbsp;and&nbsp;std::ptrdiff_t&nbsp;yet</FONT></I><BR>
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;(such&nbsp;as&nbsp;gcc)</FONT></I><BR>
#include&nbsp;&lt;<A href="./config.hpp.html">boost/config.hpp</A>&gt;<BR>
<BR>
namespace&nbsp;boost&nbsp;{<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;class&nbsp;array&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public:<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T&nbsp;elems[N];&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;fixed-size&nbsp;array&nbsp;of&nbsp;elements&nbsp;of&nbsp;type&nbsp;T</FONT></I><BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public:<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;type&nbsp;definitions</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;T&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value_type;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;T*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iterator;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;const&nbsp;T*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_iterator;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;T&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reference;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;const&nbsp;T&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reference;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::size_t&nbsp;&nbsp;&nbsp;&nbsp;size_type;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::ptrdiff_t&nbsp;difference_type;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;iterator&nbsp;support</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iterator&nbsp;begin()&nbsp;{&nbsp;return&nbsp;elems;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_iterator&nbsp;begin()&nbsp;const&nbsp;{&nbsp;return&nbsp;elems;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iterator&nbsp;end()&nbsp;{&nbsp;return&nbsp;elems+N;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_iterator&nbsp;end()&nbsp;const&nbsp;{&nbsp;return&nbsp;elems+N;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;reverse&nbsp;iterator&nbsp;support</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;iterator&gt;&nbsp;reverse_iterator;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;std::reverse_iterator&lt;const_iterator&gt;&nbsp;const_reverse_iterator;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reverse_iterator&nbsp;rbegin()&nbsp;{&nbsp;return&nbsp;reverse_iterator(end());&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reverse_iterator&nbsp;rbegin()&nbsp;const&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;const_reverse_iterator(end());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reverse_iterator&nbsp;rend()&nbsp;{&nbsp;return&nbsp;reverse_iterator(begin());&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reverse_iterator&nbsp;rend()&nbsp;const&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;const_reverse_iterator(begin());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;operator[]</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reference&nbsp;operator[](size_type&nbsp;i)&nbsp;{&nbsp;return&nbsp;elems[i];&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reference&nbsp;operator[](size_type&nbsp;i)&nbsp;const&nbsp;{&nbsp;return&nbsp;elems[i];&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;at()&nbsp;with&nbsp;range&nbsp;check</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reference&nbsp;at(size_type&nbsp;i)&nbsp;{&nbsp;rangecheck(i);&nbsp;return&nbsp;elems[i];&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reference&nbsp;at(size_type&nbsp;i)&nbsp;const&nbsp;{&nbsp;rangecheck(i);&nbsp;return&nbsp;elems[i];&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;front()&nbsp;and&nbsp;back()</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reference&nbsp;front()&nbsp;{&nbsp;return&nbsp;elems[0];&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reference&nbsp;front()&nbsp;const&nbsp;{&nbsp;return&nbsp;elems[0];&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reference&nbsp;back()&nbsp;{&nbsp;return&nbsp;elems[N-1];&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_reference&nbsp;back()&nbsp;const&nbsp;{&nbsp;return&nbsp;elems[N-1];&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;size&nbsp;is&nbsp;constant</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;size_type&nbsp;size()&nbsp;{&nbsp;return&nbsp;N;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;bool&nbsp;empty()&nbsp;{&nbsp;return&nbsp;false;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;size_type&nbsp;max_size()&nbsp;{&nbsp;return&nbsp;N;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enum&nbsp;{&nbsp;static_size&nbsp;=&nbsp;N&nbsp;};<BR>
<BR>
&nbsp;&nbsp;public:<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;swap&nbsp;(note:&nbsp;linear&nbsp;complexity)</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;swap&nbsp;(array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::swap_ranges(begin(),end(),y.begin());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;direct&nbsp;access&nbsp;to&nbsp;data</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;T*&nbsp;data()&nbsp;const&nbsp;{&nbsp;return&nbsp;elems;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;assignment&nbsp;with&nbsp;type&nbsp;conversion</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template&nbsp;&lt;typename&nbsp;T2&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array&lt;T,N&gt;&&nbsp;operator=&nbsp;(const&nbsp;array&lt;T2,N&gt;&&nbsp;rhs)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::copy(rhs.begin(),rhs.end(),&nbsp;begin());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;*this;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;assign&nbsp;one&nbsp;value&nbsp;to&nbsp;all&nbsp;elements</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;assign&nbsp;(const&nbsp;T&&nbsp;value)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::fill_n(begin(),size(),value);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private:<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;check&nbsp;range&nbsp;(may&nbsp;be&nbsp;private&nbsp;because&nbsp;it&nbsp;is&nbsp;static)</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;void&nbsp;rangecheck&nbsp;(size_type&nbsp;i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(i&nbsp;&gt;=&nbsp;size())&nbsp;{&nbsp;throw&nbsp;std::range_error("array");&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;};<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;comparisons</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;operator==&nbsp;(const&nbsp;array&lt;T,N&gt;&&nbsp;x,&nbsp;const&nbsp;array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;std::equal(x.begin(),&nbsp;x.end(),&nbsp;y.begin());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;operator&lt;&nbsp;(const&nbsp;array&lt;T,N&gt;&&nbsp;x,&nbsp;const&nbsp;array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;operator!=&nbsp;(const&nbsp;array&lt;T,N&gt;&&nbsp;x,&nbsp;const&nbsp;array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;!(x==y);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;operator&gt;&nbsp;(const&nbsp;array&lt;T,N&gt;&&nbsp;x,&nbsp;const&nbsp;array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;y&lt;x;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;operator&lt;=&nbsp;(const&nbsp;array&lt;T,N&gt;&&nbsp;x,&nbsp;const&nbsp;array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;!(y&lt;x);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;operator&gt;=&nbsp;(const&nbsp;array&lt;T,N&gt;&&nbsp;x,&nbsp;const&nbsp;array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;!(x&lt;y);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;global&nbsp;swap()</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;template&lt;class&nbsp;T,&nbsp;std::size_t&nbsp;N&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;inline&nbsp;void&nbsp;swap&nbsp;(array&lt;T,N&gt;&&nbsp;x,&nbsp;array&lt;T,N&gt;&&nbsp;y)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.swap(y);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
}&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >/*&nbsp;namespace&nbsp;boost&nbsp;*/</FONT></I><BR>
<BR>
#endif&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >/*BOOST_ARRAY_HPP*/</FONT></I><BR>
</SPAN>
</TT>
</BODY>
</HTML>

View File

@ -1,320 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Keywords" content="array, block, carray, c_array, array wrapper, adapter, adaptor, STL, C++ Standard Library, array.hpp">
<title>array.hpp, an STL Array Wrapper</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#186ABF">
<font face="Arial, Helvetica, sans-serif">&nbsp; </font>
<table width="100%" height="40">
<tr>
<td BGCOLOR="#DDDDDD"><b><font face="Arial,helvetica" color="#000000" size="+1">Class
<font face="Courier New, Courier, mono">array</font>, an STL Container (as
Wrapper) for Arrays of Constant Size</font></b></td>
</tr>
</table>
<p><font face="Arial, Helvetica, sans-serif" size="-1">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).</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1">As replacement for ordinary
arrays, the STL provides class <font face="Courier New, Courier, mono">vector&lt;&gt;</font>.
However, <font face="Courier New, Courier, mono">vector&lt;&gt;</font> 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.</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1">In his book, <i>Generic
Programming and the STL</i>, Matthew H. Austern introduces a useful wrapper
class for ordinary arrays with static size, called <font face="Courier New, Courier, mono"><b>block</b></font>.
It is safer and has no worse performance than ordinary arrays. In <i>The C++
Programming Language</i>, 3rd edition, Bjarne Stroustrup introduces a similar
class, called <font face="Courier New, Courier, mono"><b>c_array</b></font>,
which I (<a href="http://www.josuttis.com">Nicolai Josuttis</a>) present slightly
modified in my book <i>The C++ Standard Library - A Tutorial and Reference</i>,
called <font face="Courier New, Courier, mono"><b>carray</b></font>. This is
the essence of these approaches spiced with many feedback from <a href="http://www.boost.org">boost</a>.</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1">After considering different
names, we decided to name this class simply <font face="Courier New, Courier, mono"><b>array</b></font>.</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1">The class provides the
following interface:</font>
<table border="0">
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="-1"><b>Types:</b></font></td>
<td><font size="-1"></font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">value_type</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of the elements</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">iterator</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of the iterator
(random-access iterator)</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">const_iterator</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of iterator that
considers elements as being constant</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">reference</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of element reference</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">const_reference</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">type of element reference
that considers elements as being constant</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">size_type</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">type for signed size
values</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">difference_type</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">type for unsigned
difference values</font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="-1"><b>Operations:</b></font></td>
<td><font size="-1"></font></td>
</tr>
<tr>
<td>
<p><font face="Courier New, Courier, mono" size="-1">array&lt;<i>type</i>,<i>num</i>&gt;</font></p>
</td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">default constructor,
creates array of <i><font face="Courier New, Courier, mono">num</font></i>
element of <i><font face="Courier New, Courier, mono">type</font></i>, see
comment below</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">array&lt;<i>type</i>,<i>num</i>&gt;(<i>a</i>)</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">copy constructor,
copies all elements of <i><font face="Courier New, Courier, mono">a</font></i>
(<i><font face="Courier New, Courier, mono">a</font></i> must have same
<i> <font face="Courier New, Courier, mono">type</font></i><font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">
and </font></font><i><font face="Courier New, Courier, mono">num</font></i>)</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">operator=</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">assignment, assigns
all elements</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">assign(<i>val</i>)</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">assigns <i>val</i>
to all elements</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">begin()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns iterator for
the first element</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">end()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns iterator for
position after the last element</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">rbegin()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse iterator
for position of first element of reverse iteration</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">rend()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns reverse iterator
for posistion behind last element of reverese iteration </font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">operator[<i>i</i>]</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns element with
index <i><font face="Courier New, Courier, mono">i</font></i> (no range
checking)</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">at(<i>i</i>)</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns element with
index <font face="Courier New, Courier, mono"><i>i</i></font> (throw std::range_error
if <i><font face="Courier New, Courier, mono">i</font></i> is not valid)</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">front()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns first element
(caller has to ensure that it exists)</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">back()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns last element
(caller has to ensure that it exists)</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">data()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns raw element
array for read-only element access</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">size()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns number of
elements</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">empty()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns whether array
is empty</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">max_size()</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">returns maximum possible
number of elements (same as size())</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">swap(a)</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">swap elements with
array a</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">==<font face="Arial, Helvetica, sans-serif">,
</font>!=</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">checks for equality</font></td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">&lt;<font face="Arial, Helvetica, sans-serif">,
</font>&lt;=<font face="Arial, Helvetica, sans-serif">, </font>&gt;<font face="Arial, Helvetica, sans-serif">,
</font>&gt;=</font></td>
<td><font face="Arial, Helvetica, sans-serif" size="-1">compares array</font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="-1"><b>Values:</b></font></td>
<td>&nbsp;</td>
</tr>
<tr>
<td><font face="Courier New, Courier, mono" size="-1">static_size</font></td>
<td><font size="-1" face="Arial, Helvetica, sans-serif">yields size at compile
time</font></td>
</tr>
</table>
<p><font face="Arial, Helvetica, sans-serif" size="-1">Class array fulfills most
but not all of the requirements of &quot;reversible containers&quot; (see Section
23.1, [lib.container.requirements] of the C++ Standard). The reasons array is
not an reversible STL container is because: </font> <font face="Arial, Helvetica, sans-serif" size="-1"><br>
- No constructors are provided<br>
- Elements may have an indetermined initial value (see below)<br>
- swap() has no constant complexity<br>
- size() is always constant, based on the second template argument of the type<br>
- The container provides no allocator support</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1">It doesn't fulfill the
requirements of a &quot;sequence&quot; (see Section 23.1.1, [lib.sequence.reqmts]
of the C++ Standard), except that</font> <font face="Arial, Helvetica, sans-serif" size="-1"><br>
- front() and back() are provided<br>
- operator[] and at() are provided</font>
<p><font face="Arial, Helvetica, sans-serif" size="-1">Regarding the constructors
there was an important design tradeoff: We could implement array as an &quot;<b>aggregate</b>&quot;
(see Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would mean:</font></p>
<ul>
<li><font face="Arial, Helvetica, sans-serif" size="-1">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:</font>
<blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="-1">boost::array&lt;int,4&gt;
a = { { 1, 2, 3 } };</font></p>
</blockquote>
<p><font face="Arial, Helvetica, sans-serif" size="-1">Note that if there
are fewer elements in the initializer list, then each remaining element
gets default-initialized (thus, it has a defined value).</font></p>
</li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">However, <b>passing
no initializer list means that the elements have an indetermined initial value</b>.</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no user-declared
constructors.</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no private or
protected non-static data members.</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no base classes.</font></li>
<li><font face="Arial, Helvetica, sans-serif" size="-1">It has no virtual functions.</font></li>
</ul>
<p><font face="Arial, Helvetica, sans-serif" size="-1">The current implementation
useus this approach. However, being able to have indetermined initial values
is a big drawback. So, please give me some feedback, how useful you consider
this feature to be. This leads to the list of <b>Open issues:</b></font>
<ul>
<li><font face="Arial, Helvetica, sans-serif">Do we want initializer list support
or would the following be OK?:</font>
<blockquote>
<p><font face="Courier New, Courier, mono">int data[] = { 1, 2, 3, 4 }</font></p>
<p><font face="Courier New, Courier, mono">array&lt;int,5&gt; x(data); <font face="Arial, Helvetica, sans-serif">or
</font>&nbsp;&nbsp;array&lt;int,data&gt; x;</font></p>
</blockquote>
</li>
<li><font face="Arial, Helvetica, sans-serif">Could &quot;<font face="Courier New, Courier, mono">{
</font>...<font face="Courier New, Courier, mono"> }</font>&quot; be used
portably instead of &quot;<font face="Courier New, Courier, mono">{ { </font>...<font face="Courier New, Courier, mono">
} }</font>&quot; to initialize values?</font> </li>
<blockquote>
<p><font face="Arial, Helvetica, sans-serif">8.5.1 (11) of the Standard seem
to allow it; however, gcc 2.95.2 printa warning message.</font></p>
</blockquote>
<li><font face="Arial, Helvetica, sans-serif">Any way to have determined initial
values and initializer list support?</font></li>
<li><font face="Arial, Helvetica, sans-serif">Static_casts for reverse iterator
stuff</font><font face="Arial, Helvetica, sans-serif">?</font></li>
</ul>
<p><font face="Arial, Helvetica, sans-serif">I'd appreciate any constructive <a href="mailto:solutions@josuttis.com">feedback</a>.
<b>Please note: I don't have time to read all boost mails. Thus, to make sure
that feedback arrives me, please send me a copy of each mail regarding this
class.</b></font>
<p><font face="Arial, Helvetica, sans-serif">The code is provided "as is" without
expressed or implied warranty.</font>
<p><font face="Arial, Helvetica, sans-serif"><b>array.hpp</b>, the implementation
of <font face="Courier New, Courier, mono">array&lt;&gt;</font><b>:</b> </font>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array.hpp.html">as HTML file</a></font></li>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array.hpp">as plain file</a></font></li>
<p> <font face="Arial, Helvetica, sans-serif">Simple Example for using <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array1.cpp.html">as HTML file</a></font> </li>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array1.cpp">as plain file</a></font></li>
<p> <font face="Arial, Helvetica, sans-serif">Another Example for using <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array2.cpp.html">as HTML file</a></font></li>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array2.cpp">as plain file</a></font></li>
<p> <font face="Arial, Helvetica, sans-serif">A third Example for using <font face="Courier New, Courier, mono">array&lt;&gt;<font face="Arial, Helvetica, sans-serif">:</font></font></font>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array3.cpp.html">as HTML file</a></font></li>
<li><font face="Arial, Helvetica, sans-serif">
<a href="array3.cpp">as plain file</a></font></li>
<p> <font face="Arial, Helvetica, sans-serif">An Example for using <font face="Courier New, Courier, mono">array</font>s
of <font face="Courier New, Courier, mono">array</font>s<font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">:</font></font></font>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array4.cpp.html">as HTML
file</a></font></li>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array4.cpp">as plain file</a></font></li>
<p><font face="Arial, Helvetica, sans-serif">An Example for testing other operations
of <font face="Courier New, Courier, mono">array&lt;&gt;</font><font face="Courier New, Courier, mono"><font face="Arial, Helvetica, sans-serif">:</font></font></font>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array5.cpp.html">as HTML
file</a></font></li>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array5.cpp">as plain file</a></font></li>
<p><b><font face="Arial, Helvetica, sans-serif">All files</font></b>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array.zip">as ZIP file
(24KB)</a></font></li>
<li><font face="Arial, Helvetica, sans-serif"> <a href="array.tgz">as TGZ file
(13KB)</a><br>
<br>
To find more details about using ordinary arrays in C++ and the framework of
the STL, see e.g.</font> <font face="Arial, Helvetica, sans-serif"><br>
<i>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.josuttis.com/libbook/">The C++
Standard Library - A Tutorial and Reference</a></i> <br>
&nbsp;&nbsp;&nbsp;&nbsp; by <a href="http://www.josuttis.com" target="_top">Nicolai
M. Josuttis</a></font> <font face="Arial, Helvetica, sans-serif"><br>
&nbsp;&nbsp;&nbsp;&nbsp; Addison Wesley Longman, 1999</font> <font face="Arial, Helvetica, sans-serif"><br>
&nbsp;&nbsp;&nbsp;&nbsp; ISBN 0-201-37926-0</font> <font face="Arial, Helvetica, sans-serif"><br>
</font></li>
<p><font face="Arial, Helvetica, sans-serif"><a href="http://www.josuttis.com/" TARGET="_top">Home
Page of Nicolai Josuttis</a></font> <font face="Arial, Helvetica, sans-serif"><br>
&nbsp; </font>
</body>
</html>

View File

@ -1,67 +0,0 @@
<HTML>
<HEAD>
<TITLE>array1.cpp</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;array1.cpp
</B></FONT>
</TD></TR></TABLE><BR>
<BR><BR>
<TT>
<SPAN class="Source">
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;simple&nbsp;example&nbsp;for&nbsp;using&nbsp;class&nbsp;array&lt;&gt;</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
#include&nbsp;&lt;iostream&gt;<BR>
#include&nbsp;&lt;<A href="./array.hpp.html">boost/array.hpp</A>&gt;<BR>
<BR>
int&nbsp;main()<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;define&nbsp;special&nbsp;type&nbsp;name</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;boost::array&lt;float,6&gt;&nbsp;Array;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;create&nbsp;and&nbsp;initialize&nbsp;an&nbsp;array</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;a&nbsp;=&nbsp;{&nbsp;{&nbsp;42&nbsp;}&nbsp;};<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;access&nbsp;elements</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=1;&nbsp;i&lt;a.size();&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a[i]&nbsp;=&nbsp;a[i-1]+1;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;use&nbsp;some&nbsp;common&nbsp;STL&nbsp;container&nbsp;operations</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"size:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a.size()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"empty:&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;std::boolalpha&nbsp;&lt;&lt;&nbsp;a.empty()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"max_size:&nbsp;"&nbsp;&lt;&lt;&nbsp;a.max_size()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"front:&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a.front()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"back:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a.back()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"elems:&nbsp;&nbsp;&nbsp;&nbsp;";<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;iterate&nbsp;through&nbsp;all&nbsp;elements</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(Array::const_iterator&nbsp;pos=a.begin();&nbsp;pos&lt;a.end();&nbsp;++pos)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;*pos&nbsp;&lt;&lt;&nbsp;'&nbsp;';<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;check&nbsp;copy&nbsp;constructor&nbsp;and&nbsp;assignment&nbsp;operator</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;b(a);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;c;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;=&nbsp;a;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(a==b&nbsp;&&&nbsp;a==c)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
}<BR>
<BR>
</SPAN>
</TT>
</BODY>
</HTML>

View File

@ -1,54 +0,0 @@
<HTML>
<HEAD>
<TITLE>array2.cpp</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;array2.cpp
</B></FONT>
</TD></TR></TABLE><BR>
<BR><BR>
<TT>
<SPAN class="Source">
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;example&nbsp;for&nbsp;using&nbsp;class&nbsp;array&lt;&gt;</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
#include&nbsp;&lt;algorithm&gt;<BR>
#include&nbsp;&lt;functional&gt;<BR>
#include&nbsp;&lt;<A href="./array.hpp.html">boost/array.hpp</A>&gt;<BR>
#include&nbsp;"<A href="print.hpp.html">print.hpp</A>"<BR>
using&nbsp;namespace&nbsp;std;<BR>
using&nbsp;namespace&nbsp;boost;<BR>
<BR>
int&nbsp;main()<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;create&nbsp;and&nbsp;initialize&nbsp;array</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;array&lt;int,10&gt;&nbsp;a&nbsp;=&nbsp;{&nbsp;{&nbsp;1,&nbsp;2,&nbsp;3,&nbsp;4,&nbsp;5&nbsp;}&nbsp;};<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;modify&nbsp;elements&nbsp;directly</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=0;&nbsp;i&lt;a.size();&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++a[i];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;change&nbsp;order&nbsp;using&nbsp;an&nbsp;STL&nbsp;algorithm</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;reverse(a.begin(),a.end());<BR>
&nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;negate&nbsp;elements&nbsp;using&nbsp;STL&nbsp;framework</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;transform(a.begin(),a.end(),&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;source</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.begin(),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;destination</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;negate&lt;int&gt;());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;operation</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(a);<BR>
}<BR>
<BR>
</SPAN>
</TT>
</BODY>
</HTML>

View File

@ -1,69 +0,0 @@
<HTML>
<HEAD>
<TITLE>array3.cpp</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;array3.cpp
</B></FONT>
</TD></TR></TABLE><BR>
<BR><BR>
<TT>
<SPAN class="Source">
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;example&nbsp;for&nbsp;using&nbsp;class&nbsp;array&lt;&gt;</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
#include&nbsp;&lt;string&gt;<BR>
#include&nbsp;&lt;iostream&gt;<BR>
#include&nbsp;&lt;<A href="./array.hpp.html">boost/array.hpp</A>&gt;<BR>
<BR>
template&nbsp;&lt;class&nbsp;T&gt;<BR>
void&nbsp;print_elements&nbsp;(const&nbsp;T&&nbsp;x);<BR>
<BR>
int&nbsp;main()<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;create&nbsp;array&nbsp;of&nbsp;four&nbsp;seasons</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;boost::array&lt;std::string,4&gt;&nbsp;seasons&nbsp;=&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;"spring",&nbsp;"summer",&nbsp;"autumn",&nbsp;"winter"&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;};<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;copy&nbsp;and&nbsp;change&nbsp;order</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;boost::array&lt;std::string,4&gt;&nbsp;seasons_orig&nbsp;=&nbsp;seasons;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=seasons.size()-1;&nbsp;i&gt;0;&nbsp;--i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;swap(seasons.at(i),seasons.at((i+1)%seasons.size()));<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"one&nbsp;way:&nbsp;&nbsp;&nbsp;";<BR>
&nbsp;&nbsp;&nbsp;&nbsp;print_elements(seasons);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;try&nbsp;swap()</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"other&nbsp;way:&nbsp;";<BR>
&nbsp;&nbsp;&nbsp;&nbsp;swap(seasons,seasons_orig);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;print_elements(seasons);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;try&nbsp;reverse&nbsp;iterators</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"reverse:&nbsp;&nbsp;&nbsp;";<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(boost::array&lt;std::string,4&gt;::reverse_iterator&nbsp;pos<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=seasons.rbegin();&nbsp;pos&lt;seasons.rend();&nbsp;++pos)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"&nbsp;"&nbsp;&lt;&lt;&nbsp;*pos;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
}<BR>
<BR>
template&nbsp;&lt;class&nbsp;T&gt;<BR>
void&nbsp;print_elements&nbsp;(const&nbsp;T&&nbsp;x)<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=0;&nbsp;i&lt;x.size();&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"&nbsp;"&nbsp;&lt;&lt;&nbsp;x[i];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
}<BR>
<BR>
</SPAN>
</TT>
</BODY>
</HTML>

View File

@ -1,57 +0,0 @@
<HTML>
<HEAD>
<TITLE>array4.cpp</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;array4.cpp
</B></FONT>
</TD></TR></TABLE><BR>
<BR><BR>
<TT>
<SPAN class="Source">
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;example&nbsp;for&nbsp;using&nbsp;class&nbsp;array&lt;&gt;</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
#include&nbsp;&lt;algorithm&gt;<BR>
#include&nbsp;&lt;functional&gt;<BR>
#include&nbsp;&lt;string&gt;<BR>
#include&nbsp;&lt;iostream&gt;<BR>
#include&nbsp;&lt;<A href="./array.hpp.html">boost/array.hpp</A>&gt;<BR>
<BR>
int&nbsp;main()<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;array&nbsp;of&nbsp;arrays&nbsp;of&nbsp;seasons</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;boost::array&lt;boost::array&lt;std::string,4&gt;,2&gt;&nbsp;seasons_i18n&nbsp;=&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;{&nbsp;{&nbsp;"spring",&nbsp;"summer",&nbsp;"autumn",&nbsp;"winter",&nbsp;}&nbsp;},<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;{&nbsp;"Fruehling",&nbsp;"Sommer",&nbsp;"Herbst",&nbsp;"Winter"&nbsp;}&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;};<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;for&nbsp;any&nbsp;array&nbsp;of&nbsp;seasons&nbsp;print&nbsp;seasons</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=0;&nbsp;i&lt;seasons_i18n.size();&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boost::array&lt;std::string,4&gt;&nbsp;seasons&nbsp;=&nbsp;seasons_i18n[i];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;j=0;&nbsp;j&lt;seasons.size();&nbsp;++j)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;seasons[j]&nbsp;&lt;&lt;&nbsp;"&nbsp;";<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;print&nbsp;first&nbsp;element&nbsp;of&nbsp;first&nbsp;array</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"first&nbsp;element&nbsp;of&nbsp;first&nbsp;array:&nbsp;"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;seasons_i18n[0][0]&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;print&nbsp;last&nbsp;element&nbsp;of&nbsp;last&nbsp;array</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"last&nbsp;element&nbsp;of&nbsp;last&nbsp;array:&nbsp;"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
}<BR>
<BR>
</SPAN>
</TT>
</BODY>
</HTML>

View File

@ -1,85 +0,0 @@
<HTML>
<HEAD>
<TITLE>array5.cpp</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;array5.cpp
</B></FONT>
</TD></TR></TABLE><BR>
<BR><BR>
<TT>
<SPAN class="Source">
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;simple&nbsp;example&nbsp;for&nbsp;using&nbsp;class&nbsp;array&lt;&gt;</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
#include&nbsp;&lt;iostream&gt;<BR>
#include&nbsp;&lt;<A href="./array.hpp.html">boost/array.hpp</A>&gt;<BR>
<BR>
template&nbsp;&lt;typename&nbsp;T&gt;<BR>
void&nbsp;test_static_size&nbsp;(const&nbsp;T&&nbsp;cont)<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;tmp[T::static_size];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=0;&nbsp;i&lt;T::static_size;&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmp[i]&nbsp;=&nbsp;int(cont[i]);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(unsigned&nbsp;i=0;&nbsp;i&lt;T::static_size;&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;tmp[i]&nbsp;&lt;&lt;&nbsp;'&nbsp;';<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
}<BR>
<BR>
int&nbsp;main()<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;define&nbsp;special&nbsp;type&nbsp;name</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;boost::array&lt;float,6&gt;&nbsp;Array;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;create&nbsp;and&nbsp;initialize&nbsp;an&nbsp;array</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;Array&nbsp;a&nbsp;=&nbsp;{&nbsp;{&nbsp;42.42&nbsp;}&nbsp;};<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;use&nbsp;some&nbsp;common&nbsp;STL&nbsp;container&nbsp;operations</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"static_size:&nbsp;"&nbsp;&lt;&lt;&nbsp;a.size()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"size:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a.size()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"empty:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;std::boolalpha&nbsp;&lt;&lt;&nbsp;a.empty()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"max_size:&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a.max_size()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"front:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a.front()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"back:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a.back()&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"[0]:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;&lt;&lt;&nbsp;a[0]&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"elems:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;iterate&nbsp;through&nbsp;all&nbsp;elements</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(Array::const_iterator&nbsp;pos=a.begin();&nbsp;pos&lt;a.end();&nbsp;++pos)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;*pos&nbsp;&lt;&lt;&nbsp;'&nbsp;';<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;test_static_size(a);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >//&nbsp;check&nbsp;copy&nbsp;constructor&nbsp;and&nbsp;assignment&nbsp;operator</FONT></I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;b(a);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Array&nbsp;c;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;=&nbsp;a;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(a==b&nbsp;&&&nbsp;a==c)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;"copy&nbsp;construction&nbsp;and&nbsp;copy&nbsp;assignment&nbsp;are&nbsp;OK"<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;boost::array&lt;double,6&gt;&nbsp;DArray;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;typedef&nbsp;boost::array&lt;int,6&gt;&nbsp;IArray;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;IArray&nbsp;ia&nbsp;=&nbsp;{&nbsp;1,&nbsp;2,&nbsp;3,&nbsp;4,&nbsp;5,&nbsp;6&nbsp;};<BR>
&nbsp;&nbsp;&nbsp;&nbsp;DArray&nbsp;da;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;da&nbsp;=&nbsp;ia;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;da.assign(42);<BR>
}<BR>
<BR>
</SPAN>
</TT>
</BODY>
</HTML>

1
doc/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/html

22
doc/Jamfile.v2 Normal file
View File

@ -0,0 +1,22 @@
#~ Copyright Marshall Clow 2013
#~ Copyright Christian Mazakas 2024
#~ 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)
import asciidoctor ;
html array.html : array.adoc ;
install html_ : array.html : <location>html ;
pdf array.pdf : array.adoc ;
explicit array.pdf ;
install pdf_ : array.pdf : <location>pdf ;
explicit pdf_ ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : html_ ;
explicit boostrelease ;

28
doc/array.adoc Normal file
View 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

23
doc/array/changes.adoc Normal file
View File

@ -0,0 +1,23 @@
////
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.
* 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\<\=>`.

15
doc/array/copyright.adoc Normal file
View 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].

View 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 };
```

View 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]

View 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.

419
doc/array/reference.adoc Normal file
View File

@ -0,0 +1,419 @@
////
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<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;
}
```
## 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: :: For each `i` in `[0..N)`, performs `elems[i] = other.elems[i];`.
---
### 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)`.
---
```
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
```
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]`.
---

View File

@ -1,30 +1,55 @@
#ifndef BOOST_ARRAY_HPP_INCLUDED
#define BOOST_ARRAY_HPP_INCLUDED
/* The following code declares class array,
* an STL container (as wrapper) for arrays of constant size.
*
* See
* http://www.josuttis.com/cppcode
* for details and the latest version.
* http://www.boost.org/libs/array/
* for documentation.
*
* (C) Copyright Nicolai M. Josuttis 1999.
* Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied
* warranty, and with no claim as to its suitability for any purpose.
* The original author site is at: http://www.josuttis.com/
*
* Jul 31, 2000
* (C) Copyright Nicolai M. Josuttis 2001.
*
* 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)
*
* 9 Jan 2013 - (mtc) Added constexpr
* 14 Apr 2012 - (mtc) Added support for boost::hash
* 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility.
* 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group.
* See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
* Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow)
* 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow)
* 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis)
* 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries.
* 05 Aug 2001 - minor update (Nico Josuttis)
* 20 Jan 2001 - STLport fix (Beman Dawes)
* 29 Sep 2000 - Initial Revision (Nico Josuttis)
*
* Jan 29, 2004
*/
#ifndef BOOST_ARRAY_HPP
#define BOOST_ARRAY_HPP
#include <cstddef>
#include <stdexcept>
#include <iterator>
#include <algorithm>
// BUG-FIX for compilers that don't support
// std::size_t and std::ptrdiff_t yet
// (such as gcc)
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
# pragma warning(push)
# 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 <iterator>
#include <stdexcept>
#include <utility>
#include <cstddef>
namespace boost {
@ -44,114 +69,394 @@ namespace boost {
typedef std::ptrdiff_t difference_type;
// iterator support
iterator begin() { return elems; }
const_iterator begin() const { return elems; }
iterator end() { return elems+N; }
const_iterator end() const { return elems+N; }
BOOST_CXX14_CONSTEXPR iterator begin() BOOST_NOEXCEPT { return elems; }
BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT { return elems; }
BOOST_CONSTEXPR const_iterator cbegin() const BOOST_NOEXCEPT { return elems; }
BOOST_CXX14_CONSTEXPR iterator end() BOOST_NOEXCEPT { return elems+N; }
BOOST_CONSTEXPR const_iterator end() const BOOST_NOEXCEPT { return elems+N; }
BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return elems+N; }
// reverse iterator support
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
# else
// workaround for broken reverse_iterator implementations due to no partial specialization
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()); }
const_reverse_iterator rbegin() const {
reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const BOOST_NOEXCEPT {
return const_reverse_iterator(end());
}
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const {
const_reverse_iterator crbegin() const BOOST_NOEXCEPT {
return const_reverse_iterator(end());
}
reverse_iterator rend() BOOST_NOEXCEPT { return reverse_iterator(begin()); }
const_reverse_iterator rend() const BOOST_NOEXCEPT {
return const_reverse_iterator(begin());
}
const_reverse_iterator crend() const BOOST_NOEXCEPT {
return const_reverse_iterator(begin());
}
// operator[]
reference operator[](size_type i) { return elems[i]; }
const_reference operator[](size_type i) const { return elems[i]; }
BOOST_CXX14_CONSTEXPR reference operator[](size_type i)
{
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
}
#if !BOOST_WORKAROUND(BOOST_GCC, < 50000)
BOOST_CONSTEXPR
#endif
const_reference operator[](size_type i) const
{
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
}
// at() with range check
reference at(size_type i) { rangecheck(i); return elems[i]; }
const_reference at(size_type i) const { rangecheck(i); return 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]; }
// front() and back()
reference front() { return elems[0]; }
const_reference front() const { return elems[0]; }
reference back() { return elems[N-1]; }
const_reference back() const { return elems[N-1]; }
BOOST_CXX14_CONSTEXPR reference front()
{
return elems[0];
}
BOOST_CONSTEXPR const_reference front() const
{
return elems[0];
}
BOOST_CXX14_CONSTEXPR reference back()
{
return elems[N-1];
}
BOOST_CONSTEXPR const_reference back() const
{
return elems[N-1];
}
// size is constant
static size_type size() { return N; }
static bool empty() { return false; }
static size_type max_size() { return N; }
static BOOST_CONSTEXPR size_type size() BOOST_NOEXCEPT { return N; }
static BOOST_CONSTEXPR bool empty() BOOST_NOEXCEPT { return false; }
static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return N; }
enum { static_size = N };
public:
// swap (note: linear complexity)
void swap (array<T,N>& y) {
std::swap_ranges(begin(),end(),y.begin());
BOOST_CXX14_CONSTEXPR void swap (array<T,N>& y)
{
std::swap( elems, y.elems );
}
// direct access to data
const T* data() const { return elems; }
BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return elems; }
BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return elems; }
// obsolete
BOOST_DEPRECATED( "please use `data()` instead" )
T* c_array() BOOST_NOEXCEPT { return elems; }
// 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;
}
// assign one value to all elements
void assign (const T& value)
// 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 ];
}
}
# ifndef BOOST_NO_PRIVATE_IN_AGGREGATE
private:
# endif
// private member functions are allowed in aggregates [ISO 8.5.1]
static void rangecheck (size_type i) {
if (i >= size()) { throw std::range_error("array"); }
// 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)
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;
}
};
template< class T >
class array< T, 0 > {
public:
struct {} elems; // enables initialization with = {{}}
public:
// type definitions
typedef T value_type;
typedef T* iterator;
typedef const T* const_iterator;
typedef T& reference;
typedef const T& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// iterator support
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(); }
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;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const BOOST_NOEXCEPT {
return const_reverse_iterator(end());
}
const_reverse_iterator crbegin() const BOOST_NOEXCEPT {
return const_reverse_iterator(end());
}
reverse_iterator rend() BOOST_NOEXCEPT { return reverse_iterator(begin()); }
const_reverse_iterator rend() const BOOST_NOEXCEPT {
return const_reverse_iterator(begin());
}
const_reverse_iterator crend() const BOOST_NOEXCEPT {
return const_reverse_iterator(begin());
}
// operator[]
reference operator[](size_type /*i*/)
{
return failed_rangecheck();
}
const_reference operator[](size_type /*i*/) const
{
return failed_rangecheck();
}
// at() with range check
reference at(size_type /*i*/) { return failed_rangecheck(); }
const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
// front() and back()
reference front()
{
return failed_rangecheck();
}
const_reference front() const
{
return failed_rangecheck();
}
reference back()
{
return failed_rangecheck();
}
const_reference back() const
{
return failed_rangecheck();
}
// size is constant
static BOOST_CONSTEXPR size_type size() BOOST_NOEXCEPT { return 0; }
static BOOST_CONSTEXPR bool empty() BOOST_NOEXCEPT { return true; }
static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return 0; }
enum { static_size = 0 };
BOOST_CXX14_CONSTEXPR void swap (array<T,0>& /*y*/)
{
}
// direct access to data
BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return 0; }
BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return 0; }
// obsolete
BOOST_DEPRECATED( "please use `data()` instead" )
T* c_array() BOOST_NOEXCEPT { return 0; }
// assignment with type conversion
template <typename T2>
array<T,0>& operator= (const array<T2,0>& ) {
return *this;
}
// an obsolete synonym for fill
BOOST_DEPRECATED( "please use `fill` instead" )
void assign (const T& value) { fill ( value ); }
// fill with one value
BOOST_CXX14_CONSTEXPR void fill (const T& ) {}
// check range (may be private because it is static)
static reference failed_rangecheck ()
{
boost::throw_exception( std::out_of_range( "attempt to access element of an empty array" ) );
}
};
// comparisons
template<class T, std::size_t N>
bool operator== (const array<T,N>& x, const array<T,N>& y) {
return std::equal(x.begin(), x.end(), y.begin());
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 false;
}
template<class T, std::size_t N>
bool operator< (const array<T,N>& x, const array<T,N>& y) {
return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
return true;
}
#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 true;
}
#endif
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);
}
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;
}
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);
}
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);
}
// global swap()
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);
}
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L
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 0 <=> 0; // std::strong_ordering::equal
}
template<class T>
constexpr auto operator<=> (const array<T,0>& /*x*/, const array<T,0>& /*y*/)
-> decltype( 0 <=> 0 )
{
return 0 <=> 0; // std::strong_ordering::equal
}
#endif
// undocumented and obsolete
template <typename T, std::size_t N>
BOOST_DEPRECATED( "please use `elems` instead" )
T(&get_c_array(boost::array<T,N>& arg))[N]
{
return arg.elems;
}
// Const version.
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]
{
return arg.elems;
}
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];
}
} /* namespace boost */
#endif /*BOOST_ARRAY_HPP*/
#ifndef BOOST_NO_CXX11_HDR_ARRAY
// If we don't have std::array, I'm assuming that we don't have std::get
namespace std {
template <size_t Idx, typename T, size_t N>
BOOST_DEPRECATED( "please use `boost::get` instead" )
T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" );
return arr[Idx];
}
template <size_t Idx, typename T, size_t N>
BOOST_DEPRECATED( "please use `boost::get` instead" )
const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(const boost::array &) index out of range" );
return arr[Idx];
}
}
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
# pragma warning(pop)
#endif
#endif // #ifndef BOOST_ARRAY_HPP_INCLUDED

View File

@ -1,36 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Array Wrapper Libary</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table border="1" bgcolor="#007F7F" cellpadding="2">
<tr>
<td bgcolor="#FFFFFF"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
<td><a href="../../index.htm"><font face="Arial" color="#FFFFFF"><big>Home</big></font></a></td>
<td><a href="../../libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries</big></font></a></td>
<td><a href="../../people.htm"><font face="Arial" color="#FFFFFF"><big>People</big></font></a></td>
<td><a href="../../more/faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ</big></font></a></td>
<td><a href="../../more/index.htm"><font face="Arial" color="#FFFFFF"><big>More</big></font></a></td>
</tr>
</table>
<h1>Array wrapper library</h1>
<p>The header array.hpp provides an STL compliant container wrapper for arrays
of constant size.
<ul>
<li><a href="array.htm">Documentation</a> (HTML).</li>
<li>Header <a href="../../boost/array.hpp">array.hpp</a></li>
<li>See docs for links to example programs.</li>
<li>Download <a href="../../boost_all.zip">all of Boost</a> (ZIP format).</li>
<li>Submitted by <a href="http://www.josuttis.com">Nicolai M. Josuttis</a>.</li>
</ul>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->02 Aug 2000<!--webbot bot="Timestamp" endspan i-checksum="14748" --></p>
</body>
</html>

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=doc/html/array.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../../doc/html/array.html">doc/html/array.html</a> &nbsp;<hr>
<p><EFBFBD> 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>
</body>
</html>

18
meta/libraries.json Normal file
View File

@ -0,0 +1,18 @@
{
"key": "array",
"name": "Array",
"authors": [
"Nicolai Josuttis"
],
"description": "STL compliant container wrapper for arrays of constant size.",
"std": [
"tr1"
],
"category": [
"Containers"
],
"maintainers": [
"Marshall Clow <marshall -at- idio.com>"
],
"cxxstd": "03"
}

View File

@ -1,48 +0,0 @@
<HTML>
<HEAD>
<TITLE>PRINT_ELEMENTS()</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;PRINT_ELEMENTS()
</B></FONT>
</TD></TR></TABLE><BR>
<FONT face="Arial,Helvetica"><B>
The following code example is taken from the book<BR>
<A HREF="http://www.josuttis.com/libbook/" TARGET="_top">
The C++ Standard Library - A Tutorial and Reference</A><BR>
by Nicolai M. Josuttis, Addison-Wesley, 1999<BR>
<A HREF="http://www.josuttis.com/libbook/copyright.html">
&copy; Copyright</A> Nicolai M. Josuttis 1999<BR>
</B></FONT>
<BR><BR>
<TT>
<SPAN class="Source">
#include&nbsp;&lt;iostream&gt;<BR>
<BR>
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;PRINT_ELEMENTS()</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;prints&nbsp;optional&nbsp;C-string&nbsp;optcstr&nbsp;followed&nbsp;by</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;all&nbsp;elements&nbsp;of&nbsp;the&nbsp;collection&nbsp;coll</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*&nbsp;-&nbsp;separated&nbsp;by&nbsp;spaces</FONT></I><BR>
&nbsp;<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
template&nbsp;&lt;class&nbsp;T&gt;<BR>
inline&nbsp;void&nbsp;PRINT_ELEMENTS&nbsp;(const&nbsp;T&&nbsp;coll,&nbsp;const&nbsp;char*&nbsp;optcstr="")<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;typename&nbsp;T::const_iterator&nbsp;pos;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;optcstr;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(pos=coll.begin();&nbsp;pos!=coll.end();&nbsp;++pos)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;*pos&nbsp;&lt;&lt;&nbsp;'&nbsp;';<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;&lt;&lt;&nbsp;std::endl;<BR>
}<BR>
</SPAN>
</TT>
</BODY>
</HTML>

12
test/CMakeLists.txt Normal file
View 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()

106
test/Jamfile.v2 Normal file
View File

@ -0,0 +1,106 @@
#~ Copyright Rene Rivera 2008
#~ 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)
require-b2 5.0.1 ;
import testing ;
import-search /boost/config/checks ;
import config : requires ;
project
: requirements
<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 ;
run array1.cpp ;
run array2.cpp ;
run array3.cpp ;
run array4.cpp ;
run array5.cpp ;
run array6.cpp ;
run array7.cpp ;
compile array_constexpr.cpp ;
compile-fail array_getfail1.cpp
: <warnings>off ;
compile-fail array_getfail2.cpp
: <warnings>off ;
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_thw_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_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 ;
#
run quick.cpp ;

94
test/array0.cpp Normal file
View File

@ -0,0 +1,94 @@
/* tests for using class array<> specialization for size 0
* (C) Copyright Alisdair Meredith 2006.
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/array.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <algorithm>
#include <string>
#include <iostream>
namespace {
template< class T >
void BadValue( const T & )
{
BOOST_TEST ( false );
}
template< class T >
void RunTests()
{
typedef boost::array< T, 0 > test_type;
// Test value and aggegrate initialization
test_type test_case = {};
const boost::array< T, 0 > const_test_case = test_type();
test_case.fill ( T() );
// front/back and operator[] must compile, but calling them is undefined
// Likewise, all tests below should evaluate to false, avoiding undefined behaviour
BOOST_TEST ( test_case.empty());
BOOST_TEST ( const_test_case.empty());
BOOST_TEST ( test_case.size() == 0 );
BOOST_TEST ( const_test_case.size() == 0 );
// Assert requirements of TR1 6.2.2.4
BOOST_TEST ( test_case.begin() == test_case.end());
BOOST_TEST ( test_case.cbegin() == test_case.cend());
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() );
//
// 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!
}
// Check can safely use all iterator types with std algorithms
std::for_each( test_case.begin(), test_case.end(), BadValue< T > );
std::for_each( test_case.rbegin(), test_case.rend(), BadValue< T > );
std::for_each( test_case.cbegin(), test_case.cend(), BadValue< T > );
std::for_each( const_test_case.begin(), const_test_case.end(), BadValue< T > );
std::for_each( const_test_case.rbegin(), const_test_case.rend(), BadValue< T > );
std::for_each( const_test_case.cbegin(), const_test_case.cend(), BadValue< T > );
// Check swap is well formed
std::swap( test_case, test_case );
// Check assignment operator and overloads are well formed
test_case = const_test_case;
// Confirm at() throws the std lib defined exception
try {
BadValue( test_case.at( 0 ));
} catch ( const std::out_of_range & ) {
}
try {
BadValue( const_test_case.at( 0 ) );
} catch ( const std::out_of_range & ) {
}
}
}
int main()
{
RunTests< bool >();
RunTests< void * >();
RunTests< long double >();
RunTests< std::string >();
return boost::report_errors();
}

View File

@ -1,5 +1,15 @@
/* simple example for using class array<>
*
* (C) Copyright Nicolai M. Josuttis 2001.
* 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)
*
* Changelog:
* 20 Jan 2001 - Removed boolalpha use since stock GCC doesn't support it
* (David Abrahams)
*/
#include <iostream>
#include <boost/array.hpp>
@ -18,7 +28,7 @@ int main()
// use some common STL container operations
std::cout << "size: " << a.size() << std::endl;
std::cout << "empty: " << std::boolalpha << a.empty() << std::endl;
std::cout << "empty: " << (a.empty() ? "true" : "false") << std::endl;
std::cout << "max_size: " << a.max_size() << std::endl;
std::cout << "front: " << a.front() << std::endl;
std::cout << "back: " << a.back() << std::endl;
@ -39,8 +49,10 @@ int main()
<< std::endl;
}
else {
std::cout << "copy construction and copy assignment are OK"
std::cout << "copy construction and copy assignment FAILED"
<< std::endl;
}
return 0; // makes Visual-C++ compiler happy
}

View File

@ -1,33 +1,44 @@
/* example for using class array<>
* (C) Copyright Nicolai M. Josuttis 2001.
* 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)
*/
#ifndef _SCL_SECURE_NO_WARNINGS
// Suppress warnings from the std lib:
# define _SCL_SECURE_NO_WARNINGS
#endif
#include <algorithm>
#include <functional>
#include <boost/array.hpp>
#include "print.hpp"
using namespace std;
using namespace boost;
int main()
{
// create and initialize array
array<int,10> a = { { 1, 2, 3, 4, 5 } };
boost::array<int,10> a = { { 1, 2, 3, 4, 5 } };
PRINT_ELEMENTS(a);
print_elements(a);
// modify elements directly
for (unsigned i=0; i<a.size(); ++i) {
++a[i];
}
PRINT_ELEMENTS(a);
print_elements(a);
// change order using an STL algorithm
reverse(a.begin(),a.end());
PRINT_ELEMENTS(a);
print_elements(a);
// negate elements using STL framework
transform(a.begin(),a.end(), // source
a.begin(), // destination
negate<int>()); // operation
PRINT_ELEMENTS(a);
print_elements(a);
return 0; // makes Visual-C++ compiler happy
}

View File

@ -1,5 +1,10 @@
/* example for using class array<>
* (C) Copyright Nicolai M. Josuttis 2001.
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include <string>
#include <iostream>
#include <boost/array.hpp>
@ -16,8 +21,8 @@ int main()
// copy and change order
boost::array<std::string,4> seasons_orig = seasons;
for (unsigned i=seasons.size()-1; i>0; --i) {
swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
for (std::size_t i=seasons.size()-1; i>0; --i) {
std::swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
}
std::cout << "one way: ";
@ -25,7 +30,7 @@ int main()
// try swap()
std::cout << "other way: ";
swap(seasons,seasons_orig);
std::swap(seasons,seasons_orig);
print_elements(seasons);
// try reverse iterators
@ -34,7 +39,16 @@ int main()
=seasons.rbegin(); pos<seasons.rend(); ++pos) {
std::cout << " " << *pos;
}
// try constant reverse iterators
std::cout << "reverse: ";
for (boost::array<std::string,4>::const_reverse_iterator pos
=seasons.crbegin(); pos<seasons.crend(); ++pos) {
std::cout << " " << *pos;
}
std::cout << std::endl;
return 0; // makes Visual-C++ compiler happy
}
template <class T>

View File

@ -1,5 +1,10 @@
/* example for using class array<>
* (C) Copyright Nicolai M. Josuttis 2001.
* 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 <algorithm>
#include <functional>
#include <string>
@ -32,5 +37,7 @@ int main()
std::cout << "last element of last array: "
<< seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]
<< std::endl;
return 0; // makes Visual-C++ compiler happy
}

View File

@ -1,5 +1,12 @@
/* simple example for using class array<>
* (C) Copyright Nicolai M. Josuttis 2001.
* 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)
*/
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // assign
#include <iostream>
#include <boost/array.hpp>
@ -10,8 +17,8 @@ void test_static_size (const T& cont)
for (unsigned i=0; i<T::static_size; ++i) {
tmp[i] = int(cont[i]);
}
for (unsigned i=0; i<T::static_size; ++i) {
std::cout << tmp[i] << ' ';
for (unsigned j=0; j<T::static_size; ++j) {
std::cout << tmp[j] << ' ';
}
std::cout << std::endl;
}
@ -22,12 +29,13 @@ int main()
typedef boost::array<float,6> Array;
// create and initialize an array
const Array a = { { 42.42 } };
const Array a = { { 42.42f } };
// use some common STL container operations
std::cout << "static_size: " << a.size() << std::endl;
std::cout << "size: " << a.size() << std::endl;
std::cout << "empty: " << std::boolalpha << a.empty() << std::endl;
// Can't use std::boolalpha because it isn't portable
std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl;
std::cout << "max_size: " << a.max_size() << std::endl;
std::cout << "front: " << a.front() << std::endl;
std::cout << "back: " << a.back() << std::endl;
@ -50,15 +58,17 @@ int main()
<< std::endl;
}
else {
std::cout << "copy construction and copy assignment are OK"
std::cout << "copy construction and copy assignment are BROKEN"
<< std::endl;
}
typedef boost::array<double,6> DArray;
typedef boost::array<int,6> IArray;
IArray ia = { 1, 2, 3, 4, 5, 6 };
IArray ia = { { 1, 2, 3, 4, 5, 6 } } ; // extra braces silence GCC warning
DArray da;
da = ia;
da.assign(42);
return 0; // makes Visual-C++ compiler happy
}

68
test/array6.cpp Normal file
View File

@ -0,0 +1,68 @@
/* tests for using class array<> specialization for size 0
* (C) Copyright Alisdair Meredith 2006.
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#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 <algorithm>
#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 >
void RunTests()
{
typedef boost::array< T, 5 > test_type;
typedef T arr[5];
test_type test_case; // = { 1, 1, 2, 3, 5 };
arr &aRef = get_c_array ( test_case );
BOOST_TEST ( &*test_case.begin () == &aRef[0] );
const arr &caRef = get_c_array ( test_case );
typename test_type::const_iterator iter = test_case.begin ();
BOOST_TEST ( &*iter == &caRef[0] );
// Confirm at() throws the std lib defined exception
try {
test_case.at( test_case.size());
BOOST_TEST(false);
}
catch ( const std::out_of_range & ) {}
try {
test_case.at( test_case.size() + 1);
BOOST_TEST(false);
}
catch ( const std::out_of_range & ) {}
try {
test_case.at( test_case.size() + 100);
BOOST_TEST(false);
}
catch ( const std::out_of_range & ) {}
}
}
int main ()
{
RunTests< bool >();
RunTests< void * >();
RunTests< long double >();
RunTests< std::string >();
return boost::report_errors();
}

68
test/array7.cpp Normal file
View File

@ -0,0 +1,68 @@
/* tests using std::get on boost:array
* (C) Copyright Marshall Clow 2012
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // std::get
#include <string>
#include <iostream>
#include <boost/array.hpp>
#include <algorithm>
#ifndef BOOST_NO_CXX11_HDR_ARRAY
#include <array>
#endif
#include <boost/core/lightweight_test_trait.hpp>
namespace {
#ifndef BOOST_NO_CXX11_HDR_ARRAY
template< class T >
void RunStdTests()
{
typedef boost::array< T, 5 > test_type;
test_type test_case; // = { 1, 1, 2, 3, 5 };
T &aRef = std::get<0> ( test_case );
BOOST_TEST ( &*test_case.begin () == &aRef );
const T &caRef = std::get<0> ( test_case );
BOOST_TEST ( &*test_case.cbegin () == &caRef );
}
#endif
template< class T >
void RunBoostTests()
{
typedef boost::array< T, 5 > test_type;
test_type test_case; // = { 1, 1, 2, 3, 5 };
T &aRef = boost::get<0> ( test_case );
BOOST_TEST ( &*test_case.begin () == &aRef );
const T &caRef = boost::get<0> ( test_case );
BOOST_TEST ( &*test_case.cbegin () == &caRef );
}
}
int main()
{
RunBoostTests< bool >();
RunBoostTests< void * >();
RunBoostTests< long double >();
RunBoostTests< std::string >();
#ifndef BOOST_NO_CXX11_HDR_ARRAY
RunStdTests< bool >();
RunStdTests< void * >();
RunStdTests< long double >();
RunStdTests< std::string >();
#endif
return boost::report_errors();
}

117
test/array_access_test.cpp Normal file
View 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();
}

View 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

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

View 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)
#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>
#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 = {};
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();
}

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

View File

@ -0,0 +1,71 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
#define BOOST_ALLOW_DEPRECATED_SYMBOLS
#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 deprecated nonstandard extensions
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();
}

29
test/array_constexpr.cpp Normal file
View File

@ -0,0 +1,29 @@
/* tests using constexpr on boost:array
* (C) Copyright Marshall Clow 2012
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/array.hpp>
#include <boost/config.hpp>
#ifndef BOOST_NO_CXX11_CONSTEXPR
constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
int main()
{
constexpr int three = arr.at (3);
int whatever [ arr.at(4) ];
(void)three;
(void) whatever;
}
#else // no constexpr means no constexpr tests!
int main()
{
}
#endif

View 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
View 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();
}

View 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
View 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();
}

View 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
View 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();
}

87
test/array_eq_test.cpp Normal file
View File

@ -0,0 +1,87 @@
// 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>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
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
View 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

61
test/array_fill_test.cpp Normal file
View File

@ -0,0 +1,61 @@
// 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>
#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 = {};
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();
}

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

40
test/array_get_test.cpp Normal file
View 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();
}

View 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

50
test/array_getfail1.cpp Normal file
View File

@ -0,0 +1,50 @@
/* tests using std::get on boost:array
* (C) Copyright Marshall Clow 2012
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/array.hpp>
#include <boost/static_assert.hpp>
#include <string>
#include <iostream>
#include <algorithm>
#ifndef BOOST_NO_CXX11_HDR_ARRAY
#include <array>
#endif
#include <boost/core/lightweight_test_trait.hpp>
namespace {
#ifndef BOOST_NO_CXX11_HDR_ARRAY
template< class T >
void RunStdTests()
{
typedef boost::array< T, 5 > test_type;
typedef T arr[5];
test_type test_case; // = { 1, 1, 2, 3, 5 };
T &aRef = std::get<5> ( test_case ); // should fail to compile
BOOST_TEST ( &*test_case.begin () == &aRef );
}
#endif
}
int main()
{
#ifndef BOOST_NO_CXX11_HDR_ARRAY
RunStdTests< bool >();
RunStdTests< void * >();
RunStdTests< long double >();
RunStdTests< std::string >();
#else
BOOST_STATIC_ASSERT ( false ); // fail on C++03 systems.
#endif
return boost::report_errors();
}

65
test/array_getfail2.cpp Normal file
View File

@ -0,0 +1,65 @@
/* tests using std::get on boost:array
* (C) Copyright Marshall Clow 2012
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include <string>
#include <iostream>
#include <boost/array.hpp>
#include <algorithm>
#ifndef BOOST_NO_CXX11_HDR_ARRAY
#include <array>
#endif
#include <boost/core/lightweight_test_trait.hpp>
namespace {
#ifndef BOOST_NO_CXX11_HDR_ARRAY
template< class T >
void RunStdTests()
{
typedef boost::array< T, 5 > test_type;
typedef T arr[5];
test_type test_case; // = { 1, 1, 2, 3, 5 };
T &aRef = std::get<0> ( test_case );
BOOST_TEST ( &*test_case.begin () == &aRef );
const T &caRef = std::get<0> ( test_case );
BOOST_TEST ( &*test_case.cbegin () == &caRef );
}
#endif
template< class T >
void RunBoostTests()
{
typedef boost::array< T, 5 > test_type;
typedef T arr[5];
test_type test_case; // = { 1, 1, 2, 3, 5 };
T &aRef = boost::get<5> ( test_case );
BOOST_TEST ( &*test_case.begin () == &aRef );
}
}
int main()
{
RunBoostTests< bool >();
RunBoostTests< void * >();
RunBoostTests< long double >();
RunBoostTests< std::string >();
#ifndef BOOST_NO_CXX11_HDR_ARRAY
RunStdTests< bool >();
RunStdTests< void * >();
RunStdTests< long double >();
RunStdTests< std::string >();
#endif
return boost::report_errors();
}

44
test/array_hash.cpp Normal file
View File

@ -0,0 +1,44 @@
/* tests for using boost::hash with boost::array
* (C) Copyright Marshall Clow 2012
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
#include <string>
#include <iostream>
#include <boost/array.hpp>
#include <algorithm>
#include <boost/functional/hash.hpp>
#include <boost/core/lightweight_test_trait.hpp>
namespace {
template< class T >
void RunTests()
{
// std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ());
// std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ());
typedef boost::array< T, 5 > barr;
typedef T arr[5];
barr test_barr = {{ 1, 1, 2, 3, 5 }};
arr test_arr = { 1, 1, 2, 3, 5 };
std::size_t bhash = boost::hash<barr> () ( test_barr );
std::size_t ahash = boost::hash<arr> () ( test_arr );
BOOST_TEST ( ahash == bhash );
}
}
int main()
{
RunTests< int >();
RunTests< long >();
RunTests< long double >();
return boost::report_errors();
}

85
test/array_init_test.cpp Normal file
View 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 <boost/config.hpp>
#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 = {{}};
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();
}

View File

@ -0,0 +1,79 @@
// 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 = {{}};
(void)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

View 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();
}

View 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_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 = {};
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

89
test/array_lt_test.cpp Normal file
View File

@ -0,0 +1,89 @@
// 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>
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
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
View 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

View 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();
}

77
test/array_size_test.cpp Normal file
View File

@ -0,0 +1,77 @@
// 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 );
(void)a; // msvc-12.0
}
{
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 );
(void)a; // msvc-12.0
}
}
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();
}

View 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

53
test/array_swap_test.cpp Normal file
View File

@ -0,0 +1,53 @@
// 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>
#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 = {};
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();
}

53
test/array_swap_test2.cpp Normal file
View File

@ -0,0 +1,53 @@
// 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>
#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 = {};
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();
}

91
test/array_thw_test.cpp Normal file
View File

@ -0,0 +1,91 @@
// 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(__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() {}
#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

View 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/config.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/config/workaround.hpp>
#include <cstddef>
#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() {}
#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

View 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();
}

View 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>)

View 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>)

View File

@ -3,20 +3,19 @@
* by Nicolai M. Josuttis, Addison-Wesley, 1999
*
* (C) Copyright Nicolai M. Josuttis 1999.
* Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied
* warranty, and with no claim as to its suitability for any purpose.
* 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 <iostream>
/* PRINT_ELEMENTS()
/* print_elements()
* - prints optional C-string optcstr followed by
* - all elements of the collection coll
* - separated by spaces
*/
template <class T>
inline void PRINT_ELEMENTS (const T& coll, const char* optcstr="")
inline void print_elements (const T& coll, const char* optcstr="")
{
typename T::const_iterator pos;

11
test/quick.cpp Normal file
View 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];
}