Compare commits

...

110 Commits

Author SHA1 Message Date
43238b75ce Added AppVeyor CI config.
AppVeyor CI is useful for testing older MSVC versions that are no longer
supported by GitHub Actions.
2025-06-13 15:43:18 +03:00
8651f245fe Added new gcc and clang jobs to GitHub Actions. 2025-06-13 15:43:18 +03:00
5628638ade Added a workaround for MSVC 14.0 for BOOST_BITMASK.
Apparently, MSVC 14.0 does not import type aliases into namespaces via
a using-declaration. Work around the problem by enabling the use of
a compiler intrinsic for deducing the underlyng type of the enum.
2025-06-12 23:56:02 +03:00
d3a556f694 Removed gcc 4.6 GitHub Action job.
The compiler doesn't support std::underlying_type trait,
which is needed by BOOST_BITMASK.
2025-06-12 19:01:48 +03:00
d533b69b87 Removed windows-2019 GitHub Actions jobs.
The windows-2019 image is deprecated and will soon be removevd.
2025-06-12 18:41:01 +03:00
1a28d9d60f Mark bitmask_set generated by BOOST_BITMASK as deprecated.
This function is not really needed and can be replaced with double
negation (!!) or comparison with an enum value of zero. We should
prefer to minimize polluting the user's namespace with new names.
2025-06-12 18:41:01 +03:00
002caaa54f Added tests for BOOST_BITMASK. 2025-06-12 18:41:01 +03:00
f7fdaf08a3 Use C++11 underlying_type trait in BOOST_BITMASK.
This bumps the language requirement to C++11, although for compilers
that support the __underlying_type intrinsic this may work even in C++03
mode.

The operators generated by BOOST_BITMASK now use proper underlying types
for casts, which means the operators will no longer truncate bits from
large enums.

Also mark the operators as noexcept and constexpr (since C++14).
2025-06-12 18:40:55 +03:00
5b10a0b9b5 Removed outdated GHA images, added new compilers. 2025-04-19 19:19:12 +03:00
a54b2619f8 Add support for modular build structure. (#24)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Add missing b2 testing module import.

* Add missing import-search for cconfig/predef checks.

* Add requires-b2 check to top-level build file.

* Bump B2 require to 5.2

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Update build deps.
2024-08-19 01:25:34 +03:00
804767983f Added macos-12 and 13 testing in addition to latest (which is 14). 2024-05-21 01:18:57 +03:00
a8a43b4778 Use macos-latest image as macos-11 is being removed. 2024-05-21 00:59:59 +03:00
080df0554b Added a missing trailing newline. 2024-04-27 19:35:02 +03:00
9c3a0022b2 Added gcc-13 and clang-17 CI jobs. 2024-02-06 00:44:24 +03:00
6488652b08 Reduced CI job timeouts. 2024-02-05 23:43:39 +03:00
8a0d14a862 Replaced actions/checkout usage with manual download commands.
This fixes the deprecation warnings for actions/checkout@v3. actions/checkout@v4
is not functional because of the upstream bug:

https://github.com/actions/checkout/issues/1590
2024-02-05 23:39:59 +03:00
845567f026 Remove C++03 CI jobs, use gcc-11 libstdc++ in clang-12 through 15. 2023-11-17 20:07:56 +03:00
b75c261492 Add clang-16 CI jobs, switch to clang-15 from stock Ubuntu repos. 2023-06-05 15:36:30 +03:00
c6dac76110 Updated to GHA checkout@v3 to avoid deprecation warnings. 2022-10-18 17:56:52 +03:00
15cc27d2bd GitHub Actions config update.
- Added gcc-12 and clang-13 through 15 jobs.
- Added C++23 testing for gcc and clang on Linux.
- Updated clang version for UBSAN job.
- Updated Ubuntu version for clang jobs to avoid having to use external APT
  repository.
- Updated python package installation for compatibility with Ubuntu 22.04.
2022-09-10 01:09:35 +03:00
f9888ad051 Use ubuntu-latest for GHA CI jobs that run in a container. 2022-08-14 14:05:52 +03:00
00efa0a0fb Removed compiler options that are not supported by clang-cl. 2022-08-14 11:36:17 +03:00
c22d18ee32 Updated GHA config to resolve CI failures. 2022-08-14 11:01:16 +03:00
0583b51d35 Updated GHA CI config to remove deprecated Windows and Ubuntu images. 2022-08-14 02:06:31 +03:00
90d5395868 Switch to macos-11 GHA image as macos-10.15 is deprecated. 2022-08-12 15:56:52 +03:00
8c603a1894 Fixed copyright character encoding in css.
Replaced ISO-8859-1 copyright character with (c) and changed the order
of date and name to be consistent with other copyrights.

Closes https://github.com/boostorg/detail/pull/22.
2022-02-03 11:58:40 +03:00
fc31e65e0d Updated check for apt-add-repository capabilities.
In Ubuntu 20.04 there appeared an updated version of the
software-properties-common package in focal-updates, which ships a newer
apt-add-repository version that doesn't support -P/-S/-U command line arguments.

Since we cannot rely on package version checks to determine apt-add-repository
capabilities, we have to parse its --help output instead.

Also, made source list processing more protected against spaces.
2021-11-16 00:38:41 +03:00
c5de1e6848 Another fix in git version check. 2021-09-26 20:36:43 +03:00
ab84a1cb11 Fixed git version check on Mac OS. 2021-09-26 20:34:00 +03:00
2ca25f118d Fix running multiple configs of test_utf8_codecvt in parallel.
When running multiple different configurations of test_utf8_codecvt, e.g.
debug/release or different C++ versions, the test used to spuriously fail
because the test processes would conflict through the files the test creates.

To work around this, the test now creates the files in the same directory
where the test executable is located. With Boost.Build, that means the files
will be created in different directories for different configs.

This should fix spurious test failures in CI.
2021-09-16 01:26:08 +03:00
399a7a65b8 Added GHA CI timeout. 2021-09-15 21:30:44 +03:00
3986d6b7e6 Updated test_utf8_codecvt to show data differences on test failures. 2021-09-12 20:57:37 +03:00
b9f29ff43a Added GitHub Actions config. 2021-09-12 19:34:54 +03:00
3ec1c642f0 Removed Travis CI config file.
Since Travis CI no longer runs free jobs for open source projects,
we are switching to GitHub Actions.
2021-09-12 19:24:52 +03:00
87489a4346 Fixed inconsistent linkage specification on MSVC. Code cleanup.
cc32906071 introduced inconsistent
BOOST_UTF8_DECL markup between function declarations and definitions,
which caused MSVC build errors. This commit fixes this.

Also, replaced unneeded BOOST_UTF8_DECL markup with inline for functions
that are only used internally. Made get_cont_octet_out_count static.

Additionally, removed duplicate octet1_modifier_table definitions
and moved it to a function-local static.

Whitespace and formatting cleanup.

Closes https://github.com/boostorg/filesystem/issues/204.
2021-08-18 00:47:12 +03:00
db4c8248c0 Merge commit 'a01fe6d57b906edf0400daebfb5ea88bb4582f44' into develop
* commit 'a01fe6d57b906edf0400daebfb5ea88bb4582f44':
  Update CMakeLists.txt
  Fixed out-of-bounds access in utf8_codecvt_facet::do_length.
  Update maintainer list
  Disabled libstdc++ debug mode to work around gcc 10.1 bug.
  Added a workaround for removed nested typedefs in std::allocator.
  Added a workaround for C++20 ostream having deleted operator<< for wchar_t.
  Added gcc 10 build jobs to Travis CI.
  Use more up-to-date location of lightweight_test.hpp
  Converted binary_search_test to lightweight_test.hpp
  Converted allocator_utilities_test to lightweight_test.hpp
  Converted blank_test to lightweight_test.hpp.
  Removed use of deprecated header boost/detail/iterator.hpp.
  Reordered includes.
  Added boost/config.hpp.
  Changed because config.hpp is not being included
  Added clang-10 jobs to Travis CI.
  Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers.
  Disabled OS X builds because they are slow on Travis CI.
  Updated CI configs, added compilers.
2021-08-14 11:08:29 -07:00
cc32906071 adjustments to visibiity 2021-08-14 11:08:14 -07:00
a01fe6d57b Update CMakeLists.txt 2021-06-10 01:15:48 +03:00
131208d8cc Fixed out-of-bounds access in utf8_codecvt_facet::do_length.
The loop in do_length used to dereference from_end pointer, which
could point to an out-of-bounds memory. Rewritten the loop to
avoid this and also make the logic a bit more clear.

Closes https://github.com/boostorg/detail/pull/21.
2021-03-17 14:12:36 +03:00
99fc546b78 Update maintainer list 2021-01-26 15:53:19 -05:00
5d285a2d5a Disabled libstdc++ debug mode to work around gcc 10.1 bug.
The debug mode fails to compile in C++11 mode because of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95289.
2020-05-23 19:02:45 +03:00
d3da3ed070 Added a workaround for removed nested typedefs in std::allocator. 2020-05-23 18:45:20 +03:00
4bb5ef3b38 Added a workaround for C++20 ostream having deleted operator<< for wchar_t. 2020-05-23 18:36:02 +03:00
e539c056f6 Added gcc 10 build jobs to Travis CI. 2020-05-22 18:39:16 +03:00
01c1bf1906 Use more up-to-date location of lightweight_test.hpp 2020-05-10 23:27:22 +03:00
be1294c8a8 Converted binary_search_test to lightweight_test.hpp 2020-05-10 23:24:58 +03:00
f26a04df65 Converted allocator_utilities_test to lightweight_test.hpp 2020-05-10 23:20:53 +03:00
5f456ffe33 Converted blank_test to lightweight_test.hpp. 2020-05-10 23:20:22 +03:00
63f2e170cb Removed use of deprecated header boost/detail/iterator.hpp. 2020-05-10 23:14:19 +03:00
c281caa89f Reordered includes. 2020-05-06 20:31:14 +03:00
925c8ba02e Merge pull request #17 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74. Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost conf…
2020-05-06 20:29:53 +03:00
f5bb480082 Added boost/config.hpp. 2020-05-06 13:16:18 -04:00
3e36eaf79e Merge branch 'develop' of https://github.com/boostorg/detail into cppbuilder 2020-05-06 11:17:03 -04:00
3b9267be46 Changed because config.hpp is not being included 2020-05-06 11:15:57 -04:00
52b610e32b Added clang-10 jobs to Travis CI. 2020-05-05 23:14:53 +03:00
116cc18560 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-23 09:35:45 -04:00
8dbbfe372b Disabled OS X builds because they are slow on Travis CI. 2019-10-22 15:01:40 +03:00
d3c853eb08 Updated CI configs, added compilers. 2019-10-22 00:13:26 +03:00
fc781c8a5a Added a missing include. 2019-05-06 13:24:18 +03:00
7ce5543198 Merge pull request #16 from MarcelRaad/extra_semi
Fix -Wextra-semi clang warnings
2019-02-25 12:31:39 +03:00
1e5a4ad35e Fix -Wextra-semi clang warnings
Remove superfluous semicola.
2019-02-25 10:19:45 +01:00
313bc2a36b Enabled multiple git fetch jobs while executing depinst in CI. 2019-01-15 13:40:40 +03:00
1b778d703b Made git branch selection less obscure and more POSIX shell conforming. 2019-01-03 23:46:36 +03:00
e529fca266 Use the actual number of logical CPUs for the number of CI build/test jobs. 2019-01-03 23:06:59 +03:00
9439ae62d6 Re-added manual checkout of libs/config in CI as Boost.Build depends on it. 2018-12-20 20:49:01 +03:00
4c5f549c6e Use a separate submodule update step with parallel checkouts to speedup CI job startup. 2018-12-18 22:20:40 +03:00
f86480f6eb Added tools/boost_install and libs/headers manual checkout to CI jobs. 2018-12-18 21:55:03 +03:00
d78dd02a90 Added an experimental partial CMakeLists.txt for dependency tracking in CMake projects. 2018-12-18 19:52:41 +03:00
622c7c4ee6 Added gcc 8, clang 6.0 and 7 CI jobs. 2018-11-01 20:43:45 +03:00
b29edf18cb Move ~utf_codecvt_facet to .ipp file to try to fix visibility issues 2018-09-17 21:46:12 +03:00
9b95b29c59 Add more Travis configurations 2018-05-03 16:03:14 +03:00
1a9b7bccc3 Remove typename/template uses outside of templates 2018-05-03 15:52:42 +03:00
83d7ee837d Remove use of BOOST_MPL_AUX_LAMBDA_SUPPORT
It's only need when compilers don't support template template parameters or
partial specialization. I don't think there are any such compilers in use.
2018-04-08 20:57:32 +01:00
3fc08cca25 Stop using mpl::void_ in reference_content 2018-04-08 20:57:31 +01:00
abfaa1443a Use type traits bool type in reference_content 2018-04-08 20:57:31 +01:00
121cbef225 Use true_type/false_type from type traits in is_xxx.hpp 2018-04-08 20:57:31 +01:00
be57f3c000 Remove mpl dependency from allocator_utilities.hpp 2018-04-08 20:57:31 +01:00
941fff4dc0 Stop using mpl binary logic classes in indirect_traits
Was going to use the ice_* classes from type traits, but they're deprecated.
2018-04-08 20:57:07 +01:00
6172f9a30e Use type traits' true type in boost::blank 2018-04-08 20:55:53 +01:00
adaa82e03e Add some tests
Test classes which I'm going to remove the MPL dependency from: blank,
allocator_utilities, is_xxx and reference_content.  I'm also going to change
indirect_traits, but that's tested in the python module.
2018-04-08 20:55:38 +01:00
824721a753 Trim trailing spaces. 2018-01-01 15:52:37 +03:00
bb0840b9c8 Merge pull request #15 from DanielaE/fix/replace-deprecated-allocator-members
Most members of std::allocate are deprecated in C++17
2017-12-30 22:12:21 +03:00
1631ba8134 Most members of std::allocate are deprecated in C++17
Replace them by their cousins from std::allocator_traits.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-12-30 18:15:56 +01:00
40b75dae5f Merge branch 'develop' 2017-10-30 01:08:52 +03:00
367c13fd20 Updated utf8_codecvt test to verify that length() detects character boundaries. 2017-10-29 21:29:38 +03:00
ac88c3f24c Updated utf8_codecvt test to verify that length() detects character boundaries. 2017-10-29 21:27:54 +03:00
d6f601b90e Add .travis.yml 2017-10-29 19:06:09 +02:00
cf6808b26f Swapped the standard and non-standard overrides for do_length. 2017-10-29 19:31:28 +03:00
aee87734a8 Fixed do_length virtual override.
Fixed a bug introduced by b47fccb4a4, which
commented the correct virtual function override and thus broke length() result.
2017-10-29 19:27:04 +03:00
b47fccb4a4 adjusted visibility to permit passing of tests on mingw for serialization library 2017-10-22 11:22:45 -07:00
15d8f9a59c Actualized numeric_traits implementation.
1. Ported to Boost.TypeTraits primitives for type inspection and simple
   metaprogramming instead of local implementations. This effectively
   drops any workarounds for compilers without support for partial template
   specializations. Such compilers are long outdated.

2. Include more fine-grained headers from Boost.TypeTraits to optimize
   compilation times.

3. Made numeric_distance function constexpr.

4. Updated the test accordingly (i.e. replaced the use of now removed local
   components with Boost.TypeTraits). Also replaced lexical_cast with
   standard streams to further reduce dependencies.

None of these changes should affect functionality.
2017-09-20 02:01:51 +03:00
9b2065c0ca Enabled numeric_traits test that has been moved from Boost.Utility. 2017-09-20 01:37:06 +03:00
13b49041e1 Move test files to test/ 2017-09-20 01:33:10 +03:00
08bb964247 Replaced left shift of signed integer values with multiplication to keep the expressions constant according to C++11. 2017-09-20 01:33:10 +03:00
4da971f715 Merged from Version_1_33_1
[SVN r31949]
2017-09-20 01:33:10 +03:00
07fe4630f6 Apply typo fixes from Julio M. Merino Vidal
[SVN r27513]
2017-09-20 01:33:10 +03:00
51baccb399 Added new types boost::long_long_type and boost::ulong_long_type in boost/config.hpp and applied these types in place of "long long" throughout. As a result, almost all of boost now compiles cleanly with -ansi -pedantic with gcc. Changes tested with gcc 3.3, 2.95, VC7.1 and Intel 8.
[SVN r24899]
2017-09-20 01:33:10 +03:00
6e36d0d70a Converted to Boost Software License, Version 1.0
[SVN r24055]
2017-09-20 01:33:10 +03:00
c0ced7e14d avoid default parameters for function templates, they confuse SunCC
[SVN r19100]
2017-09-20 01:33:10 +03:00
6adadccbde VC++ fixes
[SVN r14435]
2017-09-20 01:33:10 +03:00
40d73a99e9 Updated preprocessor logic to use BOOST_HAS_LONG_LONG
[SVN r11399]
2017-09-20 01:33:10 +03:00
3db9d2e843 Fixes for ICL
[SVN r10613]
2017-09-20 01:33:10 +03:00
2c7b0fe600 Fixes for Borland
[SVN r9117]
2017-09-20 01:33:10 +03:00
bf772a322f Added test for wchar_t
[SVN r8748]
2017-09-20 01:33:10 +03:00
4b233854aa Now statically selecting a test for signed numbers to avoid warnings with fancy compilers. Added commentary and additional dumping of traits data for tested types.
[SVN r8746]
2017-09-20 01:33:10 +03:00
5d2660f113 minor fix: move "static" storage specifier to the front of a declaration
[SVN r8714]
2017-09-20 01:33:10 +03:00
172a0a1062 Initial checkin
[SVN r8702]
2017-09-20 01:33:10 +03:00
ce79a887c4 Add BOOST_CONSTEXPR where required by C++ Std [bitmark.types].
Add operator! and function bitmask_set as Boost extensions.
2017-08-28 07:32:08 -04:00
782208b04d Revert "adjustment to avoid linking problem: vtable not found found for ~utf8_codecvt_facet.hpp"
This reverts commit 73c12230c3.

Reverted because the change broke GCC/MinGW builds of Filesystem.
2017-08-28 07:27:30 -04:00
73c12230c3 adjustment to avoid linking problem: vtable not found found for ~utf8_codecvt_facet.hpp 2017-08-13 15:11:17 -07:00
33 changed files with 1909 additions and 380 deletions

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

@ -0,0 +1,594 @@
# Copyright 2021-2025 Andrey Semashev
#
# 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)
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: debug,release
jobs:
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- toolset: gcc-4.7
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.7
- toolset: gcc-4.8
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:20.04
install:
- g++-9
- toolset: gcc-10
cxxstd: "11,14,17,20"
os: ubuntu-latest
container: ubuntu:20.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "11,14,17,20,23"
os: ubuntu-22.04
install:
- g++-11
- toolset: gcc-12
cxxstd: "11,14,17,20,23"
os: ubuntu-22.04
install:
- g++-12
- toolset: gcc-13
cxxstd: "11,14,17,20,23"
os: ubuntu-24.04
install:
- g++-13
- toolset: gcc-14
cxxstd: "11,14,17,20,23,26"
os: ubuntu-24.04
install:
- g++-14
- toolset: gcc-15
cxxstd: "11,14,17,20,23,26"
os: ubuntu-latest
container: ubuntu:25.04
install:
- g++-15
- name: UBSAN
toolset: gcc-13
cxxstd: "11,14,17,20,23"
ubsan: 1
build_variant: debug
os: ubuntu-24.04
install:
- g++-13
# Linux, clang
- toolset: clang
compiler: clang++-3.5
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-7
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-8
- g++-7
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17,2a"
os: ubuntu-latest
container: ubuntu:20.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,20"
os: ubuntu-latest
container: ubuntu:20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,20"
os: ubuntu-22.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-12
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-13
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-13
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-14
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-14
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-15
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-15
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-16
cxxstd: "11,14,17,20,2b"
os: ubuntu-24.04
install:
- clang-16
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-17
cxxstd: "11,14,17,20,23"
os: ubuntu-24.04
install:
- clang-17
- g++-11
gcc_toolchain: 11
- toolset: clang
compiler: clang++-18
cxxstd: "11,14,17,20,23,26"
os: ubuntu-24.04
install:
- clang-18
- g++-13
- toolset: clang
compiler: clang++-19
cxxstd: "11,14,17,20,23,26"
os: ubuntu-24.04
install:
- clang-19
- toolset: clang
compiler: clang++-20
cxxstd: "11,14,17,20,23,26"
os: ubuntu-latest
container: ubuntu:25.04
install:
- clang-20
- toolset: clang
compiler: clang++-20
cxxstd: "11,14,17,20,23,26"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
os: ubuntu-latest
container: ubuntu:25.04
install:
- clang-20
- libc++-20-dev
- libc++abi-20-dev
- name: UBSAN
toolset: clang
compiler: clang++-18
cxxstd: "11,14,17,20,23,26"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
ubsan: 1
build_variant: debug
os: ubuntu-24.04
install:
- clang-18
- libc++-18-dev
- libc++abi-18-dev
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-13
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-14
timeout-minutes: 15
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Setup environment
run: |
if [ -f "/etc/debian_version" ]
then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
fi
if [ -n "${{matrix.container}}" ]
then
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
if [ -f "/etc/debian_version" ]
then
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
then
PYTHON_PACKAGE="python-is-python3"
else
PYTHON_PACKAGE="python"
fi
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake
fi
fi
git config --global pack.threads 0
- name: Install packages
if: matrix.install
run: |
declare -a SOURCE_KEYS SOURCES
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
then
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
fi
if [ -n "${{join(matrix.sources, ' ')}}" ]
then
SOURCES=("${{join(matrix.sources, '" "')}}")
fi
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
echo "Adding key: $key"
wget -O - "$key" | sudo apt-key add - && break || sleep 2
done
done
if [ ${#SOURCES[@]} -gt 0 ]
then
APT_ADD_REPO_COMMON_ARGS=("-y")
APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
for source in "${SOURCES[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
then
case "$source" in
"ppa:"*)
APT_ADD_REPO_ARGS+=("-P")
;;
"deb "*)
APT_ADD_REPO_ARGS+=("-S")
;;
*)
APT_ADD_REPO_ARGS+=("-U")
;;
esac
fi
APT_ADD_REPO_ARGS+=("$source")
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
done
done
fi
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
- name: Setup GCC Toolchain
if: matrix.gcc_toolchain
run: |
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
mkdir -p "$GCC_TOOLCHAIN_ROOT"
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
- 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
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
DEPINST_ARGS=()
GIT_VERSION="$(git --version | sed -e 's/git version //')"
GIT_HAS_JOBS=1
if [ -f "/etc/debian_version" ]
then
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
then
GIT_HAS_JOBS=0
fi
else
declare -a GIT_VER=(${GIT_VERSION//./ })
declare -a GIT_MIN_VER=(2 8 0)
for ((i=0; i<${#GIT_VER[@]}; i++))
do
if [ -z "${GIT_MIN_VER[i]}" ]
then
GIT_MIN_VER[i]=0
fi
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
then
GIT_HAS_JOBS=0
break
fi
done
fi
if [ "$GIT_HAS_JOBS" -ne 0 ]
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
fi
mkdir -p snapshot
cd snapshot
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
then
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
ls -la
exit 1
fi
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
mkdir -p libs
rm -rf "libs/$LIBRARY"
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
rm -rf "../snapshot"
git submodule update --init tools/boostdep
DEPINST_ARGS+=("$LIBRARY")
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
if [ -z "${{matrix.cmake_tests}}" ]
then
./bootstrap.sh
./b2 headers
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
fi
echo " ;" >> ~/user-config.jam
fi
fi
- name: Run tests
if: matrix.cmake_tests == ''
run: |
cd boost-root
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
if [ -n "${{matrix.build_variant}}" ]
then
B2_ARGS+=("variant=${{matrix.build_variant}}")
else
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
fi
if [ -n "${{matrix.threading}}" ]
then
B2_ARGS+=("threading=${{matrix.threading}}")
fi
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
fi
B2_ARGS+=("libs/$LIBRARY/test")
./b2 "${B2_ARGS[@]}"
windows:
strategy:
fail-fast: false
matrix:
include:
- 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: "11,14,17,20,23"
addrmd: 64
os: windows-2022
timeout-minutes: 15
runs-on: ${{matrix.os}}
steps:
- 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%
mkdir snapshot
cd snapshot
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
dir
exit /b 1
)
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
if not exist "libs\" mkdir libs
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
rmdir /s /q "..\snapshot"
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
cmd /c bootstrap
b2 headers
- name: Run tests
shell: cmd
run: |
cd boost-root
set BUILD_VARIANT=${{matrix.build_variant}}
if "%BUILD_VARIANT%" == "" set BUILD_VARIANT=%DEFAULT_BUILD_VARIANT%
b2 -j %NUMBER_OF_PROCESSORS% toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=%BUILD_VARIANT% embed-manifest-via=linker libs/%LIBRARY%/test

22
CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
# Copyright 2018 Peter Dimov
# Copyright 2018 Andrey Semashev
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.20)
project(boost_detail VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_detail INTERFACE)
add_library(Boost::detail ALIAS boost_detail)
target_include_directories(boost_detail INTERFACE include)
target_link_libraries(boost_detail
INTERFACE
Boost::config
Boost::core
Boost::preprocessor
Boost::static_assert
Boost::type_traits
)

88
appveyor.yml Normal file
View File

@ -0,0 +1,88 @@
# Copyright 2025 Andrey Semashev
# 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)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- TOOLSET: msvc-12.0
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: msvc-14.0
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: msvc-14.1
CXXSTD: 14,17,latest
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- TOOLSET: msvc-14.2
ADDRMD: 32,64
CXXSTD: 14,17,20,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: msvc-14.3
ADDRMD: 32,64
CXXSTD: 14,17,20,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
- TOOLSET: clang-win
ADDRMD: 32
CXXSTD: 14,17,latest
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: clang-win
ADDRMD: 64
CXXSTD: 14,17,latest
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: gcc
CXXSTD: 11,14,1z
ADDPATH: C:\cygwin\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 11,14,1z
ADDPATH: C:\cygwin64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 11,14,17
ADDPATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 11,14,17,2a
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
install:
- set GIT_FETCH_JOBS=8
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_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 init tools/build
- git submodule init tools/boostdep
- git submodule init tools/boost_install
- git submodule init libs/headers
- git submodule init libs/config
- git submodule update --jobs %GIT_FETCH_JOBS%
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\detail
- python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" detail
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%ENV_SCRIPT%" == "" call "%ENV_SCRIPT%"
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- if not "%THREADING%" == "" set THREADING=threading=%THREADING%
- b2 -j %NUMBER_OF_PROCESSORS% libs/detail/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% %THREADING%

27
build.jam Normal file
View File

@ -0,0 +1,27 @@
# Copyright René Ferdinand Rivera Morell 2023-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)
require-b2 5.2 ;
constant boost_dependencies :
/boost/config//boost_config
/boost/core//boost_core
/boost/preprocessor//boost_preprocessor
/boost/static_assert//boost_static_assert
/boost/type_traits//boost_type_traits ;
project /boost/detail
: common-requirements
<include>include
;
explicit
[ alias boost_detail : : : : <library>$(boost_dependencies) ]
[ alias all : boost_detail test ]
;
call-if : boost-library detail
;

View File

@ -23,7 +23,7 @@ boostbook standalone
<xsl:param>generate.section.toc.level=3
<xsl:param>chunk.section.depth=2
#<xsl:param>chunk.first.sections=1
<dependency>images
<dependency>callouts
<dependency>css

View File

@ -1,6 +1,6 @@
/*
<20> Copyright Beman Dawes, 2007
Copyright (c) 2007 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
See www.boost.org/LICENSE_1_0.txt

View File

@ -20,7 +20,7 @@
#include "boost/detail/templated_streams.hpp"
#endif // BOOST_NO_IOSTREAM
#include "boost/mpl/bool.hpp"
#include "boost/type_traits/integral_constant.hpp"
#include "boost/type_traits/is_empty.hpp"
#include "boost/type_traits/is_pod.hpp"
#include "boost/type_traits/is_stateless.hpp"
@ -36,19 +36,19 @@ struct blank
template <>
struct is_pod< blank >
: mpl::true_
: boost::true_type
{
};
template <>
struct is_empty< blank >
: mpl::true_
: boost::true_type
{
};
template <>
struct is_stateless< blank >
: mpl::true_
: boost::true_type
{
};

View File

@ -11,7 +11,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/detail/workaround.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/detail/select_type.hpp>
#include <boost/type_traits/is_same.hpp>
#include <cstddef>
#include <memory>
@ -44,7 +44,7 @@ public:
typedef Type value_type;
partial_std_allocator_wrapper(){};
partial_std_allocator_wrapper(){}
template<typename Other>
partial_std_allocator_wrapper(const partial_std_allocator_wrapper<Other>&){}
@ -52,7 +52,7 @@ public:
partial_std_allocator_wrapper(const std::allocator<Type>& x):
std::allocator<Type>(x)
{
};
}
#if defined(BOOST_DINKUMWARE_STDLIB)
/* Dinkumware guys didn't provide a means to call allocate() without
@ -121,8 +121,13 @@ struct rebinder
template<typename Type>
struct result
{
typedef typename Allocator::BOOST_NESTED_TEMPLATE
#ifdef BOOST_NO_CXX11_ALLOCATOR
typedef typename Allocator::BOOST_NESTED_TEMPLATE
rebind<Type>::other other;
#else
typedef typename std::allocator_traits<Allocator>::BOOST_NESTED_TEMPLATE
rebind_alloc<Type> other;
#endif
};
};
@ -137,11 +142,12 @@ struct compliant_allocator_rebind_to
template<typename Allocator,typename Type>
struct rebind_to:
mpl::eval_if_c<
is_partial_std_allocator<Allocator>::value,
boost::detail::if_true<
is_partial_std_allocator<Allocator>::value
>::template then<
partial_std_allocator_rebind_to<Allocator,Type>,
compliant_allocator_rebind_to<Allocator,Type>
>
>::type
{
};
@ -159,7 +165,7 @@ void construct(void* p,const Type& t)
*/
#pragma warning(push)
#pragma warning(disable:4100)
#pragma warning(disable:4100)
#endif
template<typename Type>

View File

@ -1,11 +1,11 @@
// Copyright (c) 2000 David Abrahams.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// Copyright (c) 2000 David Abrahams.
// 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)
//
//
// Copyright (c) 1994
// Hewlett-Packard Company
//
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
@ -13,10 +13,10 @@
// in supporting documentation. Hewlett-Packard Company makes no
// representations about the suitability of this software for any
// purpose. It is provided "as is" without express or implied warranty.
//
//
// Copyright (c) 1996
// Silicon Graphics Computer Systems, Inc.
//
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
@ -24,22 +24,22 @@
// in supporting documentation. Silicon Graphics makes no
// representations about the suitability of this software for any
// purpose. It is provided "as is" without express or implied warranty.
//
//
#ifndef BINARY_SEARCH_DWA_122600_H_
# define BINARY_SEARCH_DWA_122600_H_
# include <boost/detail/iterator.hpp>
# include <utility>
# include <iterator>
namespace boost { namespace detail {
template <class ForwardIter, class Tp>
ForwardIter lower_bound(ForwardIter first, ForwardIter last,
const Tp& val)
const Tp& val)
{
typedef detail::iterator_traits<ForwardIter> traits;
typename traits::difference_type len = boost::detail::distance(first, last);
typedef std::iterator_traits<ForwardIter> traits;
typename traits::difference_type len = std::distance(first, last);
typename traits::difference_type half;
ForwardIter middle;
@ -62,9 +62,9 @@ template <class ForwardIter, class Tp, class Compare>
ForwardIter lower_bound(ForwardIter first, ForwardIter last,
const Tp& val, Compare comp)
{
typedef detail::iterator_traits<ForwardIter> traits;
typedef std::iterator_traits<ForwardIter> traits;
typename traits::difference_type len = boost::detail::distance(first, last);
typename traits::difference_type len = std::distance(first, last);
typename traits::difference_type half;
ForwardIter middle;
@ -87,9 +87,9 @@ template <class ForwardIter, class Tp>
ForwardIter upper_bound(ForwardIter first, ForwardIter last,
const Tp& val)
{
typedef detail::iterator_traits<ForwardIter> traits;
typedef std::iterator_traits<ForwardIter> traits;
typename traits::difference_type len = boost::detail::distance(first, last);
typename traits::difference_type len = std::distance(first, last);
typename traits::difference_type half;
ForwardIter middle;
@ -112,9 +112,9 @@ template <class ForwardIter, class Tp, class Compare>
ForwardIter upper_bound(ForwardIter first, ForwardIter last,
const Tp& val, Compare comp)
{
typedef detail::iterator_traits<ForwardIter> traits;
typedef std::iterator_traits<ForwardIter> traits;
typename traits::difference_type len = boost::detail::distance(first, last);
typename traits::difference_type len = std::distance(first, last);
typename traits::difference_type half;
ForwardIter middle;
@ -137,9 +137,9 @@ template <class ForwardIter, class Tp>
std::pair<ForwardIter, ForwardIter>
equal_range(ForwardIter first, ForwardIter last, const Tp& val)
{
typedef detail::iterator_traits<ForwardIter> traits;
typedef std::iterator_traits<ForwardIter> traits;
typename traits::difference_type len = boost::detail::distance(first, last);
typename traits::difference_type len = std::distance(first, last);
typename traits::difference_type half;
ForwardIter middle, left, right;
@ -169,9 +169,9 @@ std::pair<ForwardIter, ForwardIter>
equal_range(ForwardIter first, ForwardIter last, const Tp& val,
Compare comp)
{
typedef detail::iterator_traits<ForwardIter> traits;
typedef std::iterator_traits<ForwardIter> traits;
typename traits::difference_type len = boost::detail::distance(first, last);
typename traits::difference_type len = std::distance(first, last);
typename traits::difference_type half;
ForwardIter middle, left, right;
@ -194,7 +194,7 @@ equal_range(ForwardIter first, ForwardIter last, const Tp& val,
}
}
return std::pair<ForwardIter, ForwardIter>(first, first);
}
}
template <class ForwardIter, class Tp>
bool binary_search(ForwardIter first, ForwardIter last,

View File

@ -1,47 +1,91 @@
// boost/detail/bitmask.hpp ------------------------------------------------//
// Copyright Beman Dawes 2006
// Copyright Andrey Semashev 2025
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
// Usage: enum foo { a=1, b=2, c=4 };
// BOOST_BITMASK( foo );
// BOOST_BITMASK( foo )
//
// void f( foo arg );
// ...
// f( a | c );
//
// See [bitmask.types] in the C++ standard for the formal specification
#ifndef BOOST_BITMASK_HPP
#define BOOST_BITMASK_HPP
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#define BOOST_BITMASK(Bitmask) \
\
inline Bitmask operator| (Bitmask x , Bitmask y ) \
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
| static_cast<boost::int_least32_t>(y)); } \
\
inline Bitmask operator& (Bitmask x , Bitmask y ) \
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
& static_cast<boost::int_least32_t>(y)); } \
\
inline Bitmask operator^ (Bitmask x , Bitmask y ) \
{ return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
^ static_cast<boost::int_least32_t>(y)); } \
\
inline Bitmask operator~ (Bitmask x ) \
{ return static_cast<Bitmask>(~static_cast<boost::int_least32_t>(x)); } \
\
inline Bitmask & operator&=(Bitmask & x , Bitmask y) \
{ x = x & y ; return x ; } \
\
inline Bitmask & operator|=(Bitmask & x , Bitmask y) \
{ x = x | y ; return x ; } \
\
inline Bitmask & operator^=(Bitmask & x , Bitmask y) \
{ x = x ^ y ; return x ; }
#if defined(__has_builtin)
#if __has_builtin(__underlying_type)
#define BOOST_BITMASK_DETAIL_UNDERLYING_TYPE(enum_type) __underlying_type(enum_type)
#endif
#endif
#if !defined(BOOST_BITMASK_DETAIL_UNDERLYING_TYPE) && \
((defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700)) || (defined(_MSC_VER) && (_MSC_VER >= 1700)))
#define BOOST_BITMASK_DETAIL_UNDERLYING_TYPE(enum_type) __underlying_type(enum_type)
#endif
#if !defined(BOOST_BITMASK_DETAIL_UNDERLYING_TYPE)
#include <type_traits>
#endif
namespace boost {
namespace detail {
namespace bitmask {
#if defined(BOOST_BITMASK_DETAIL_UNDERLYING_TYPE)
template< typename Enum >
using underlying_type_t = BOOST_BITMASK_DETAIL_UNDERLYING_TYPE(Enum);
#elif (BOOST_CXX_VERSION >= 201402)
using std::underlying_type_t;
#else
template< typename Enum >
using underlying_type_t = typename std::underlying_type< Enum >::type;
#endif
}}}
#undef BOOST_BITMASK_DETAIL_UNDERLYING_TYPE
#define BOOST_BITMASK(Bitmask) \
\
inline BOOST_CONSTEXPR Bitmask operator| (Bitmask x, Bitmask y) BOOST_NOEXCEPT \
{ return static_cast< Bitmask >(static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x) \
| static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(y)); } \
\
inline BOOST_CONSTEXPR Bitmask operator& (Bitmask x, Bitmask y) BOOST_NOEXCEPT \
{ return static_cast< Bitmask >(static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x) \
& static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(y)); } \
\
inline BOOST_CONSTEXPR Bitmask operator^ (Bitmask x, Bitmask y) BOOST_NOEXCEPT \
{ return static_cast< Bitmask >(static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x) \
^ static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(y)); } \
\
inline BOOST_CONSTEXPR Bitmask operator~ (Bitmask x) BOOST_NOEXCEPT \
{ return static_cast< Bitmask >(~static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x)); } \
\
inline BOOST_CXX14_CONSTEXPR Bitmask& operator&=(Bitmask& x, Bitmask y) BOOST_NOEXCEPT \
{ x = x & y; return x; } \
\
inline BOOST_CXX14_CONSTEXPR Bitmask& operator|=(Bitmask& x, Bitmask y) BOOST_NOEXCEPT \
{ x = x | y; return x; } \
\
inline BOOST_CXX14_CONSTEXPR Bitmask& operator^=(Bitmask& x, Bitmask y) BOOST_NOEXCEPT \
{ x = x ^ y; return x; } \
\
/* Boost extensions to [bitmask.types] */ \
\
inline BOOST_CONSTEXPR bool operator!(Bitmask x) BOOST_NOEXCEPT \
{ return !static_cast< ::boost::detail::bitmask::underlying_type_t< Bitmask > >(x); } \
\
BOOST_DEPRECATED("bitmask_set(enum) is deprecated, use !!enum or comparison operators instead") \
inline BOOST_CONSTEXPR bool bitmask_set(Bitmask x) BOOST_NOEXCEPT \
{ return !!x; }
#endif // BOOST_BITMASK_HPP

View File

@ -20,13 +20,14 @@
// to reduce coupling to other boost libraries.
#include <string> // for string
#include <new> // for bad_alloc
#include <ostream> // for ostream
#include <typeinfo> // for bad_cast, bad_typeid
#include <exception> // for exception, bad_exception
#include <stdexcept> // for std exception hierarchy
#include <boost/config.hpp>
#include <boost/cstdlib.hpp> // for exit codes
#include <ostream> // for ostream
# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x0551)
# if defined(BOOST_BORLANDC) && (__BORLANDC__ <= 0x0551)
# define BOOST_BUILT_IN_EXCEPTIONS_MISSING_WHAT
# endif

View File

@ -4,6 +4,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef INDIRECT_TRAITS_DWA2002131_HPP
# define INDIRECT_TRAITS_DWA2002131_HPP
# include <boost/type_traits/integral_constant.hpp>
# include <boost/type_traits/is_function.hpp>
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/is_pointer.hpp>
@ -17,13 +18,7 @@
# include <boost/type_traits/remove_pointer.hpp>
# include <boost/detail/workaround.hpp>
# include <boost/mpl/eval_if.hpp>
# include <boost/mpl/if.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/mpl/and.hpp>
# include <boost/mpl/not.hpp>
# include <boost/mpl/aux_/lambda_support.hpp>
# include <boost/detail/select_type.hpp>
namespace boost { namespace detail {
@ -31,24 +26,24 @@ namespace boost { namespace detail {
namespace indirect_traits {
template <class T>
struct is_reference_to_const : mpl::false_
struct is_reference_to_const : boost::false_type
{
};
template <class T>
struct is_reference_to_const<T const&> : mpl::true_
struct is_reference_to_const<T const&> : boost::true_type
{
};
# if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
template<class T>
struct is_reference_to_const<T const volatile&> : mpl::true_
struct is_reference_to_const<T const volatile&> : boost::true_type
{
};
# endif
# endif
template <class T>
struct is_reference_to_function : mpl::false_
struct is_reference_to_function : boost::false_type
{
};
@ -58,7 +53,7 @@ struct is_reference_to_function<T&> : is_function<T>
};
template <class T>
struct is_pointer_to_function : mpl::false_
struct is_pointer_to_function : boost::false_type
{
};
@ -70,7 +65,7 @@ struct is_pointer_to_function<T*> : is_function<T>
};
template <class T>
struct is_reference_to_member_function_pointer_impl : mpl::false_
struct is_reference_to_member_function_pointer_impl : boost::false_type
{
};
@ -85,18 +80,17 @@ template <class T>
struct is_reference_to_member_function_pointer
: is_reference_to_member_function_pointer_impl<T>
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T))
};
template <class T>
struct is_reference_to_function_pointer_aux
: mpl::and_<
is_reference<T>
, is_pointer_to_function<
: boost::integral_constant<bool,
is_reference<T>::value &&
is_pointer_to_function<
typename remove_cv<
typename remove_reference<T>::type
>::type
>
>::value
>
{
// There's no such thing as a pointer-to-cv-function, so we don't need specializations for those
@ -104,94 +98,91 @@ struct is_reference_to_function_pointer_aux
template <class T>
struct is_reference_to_function_pointer
: mpl::if_<
is_reference_to_function<T>
, mpl::false_
: boost::detail::if_true<
is_reference_to_function<T>::value
>::template then<
boost::false_type
, is_reference_to_function_pointer_aux<T>
>::type
>::type
{
};
template <class T>
struct is_reference_to_non_const
: mpl::and_<
is_reference<T>
, mpl::not_<
is_reference_to_const<T>
>
: boost::integral_constant<bool,
is_reference<T>::value &&
!is_reference_to_const<T>::value
>
{
};
template <class T>
struct is_reference_to_volatile : mpl::false_
struct is_reference_to_volatile : boost::false_type
{
};
template <class T>
struct is_reference_to_volatile<T volatile&> : mpl::true_
struct is_reference_to_volatile<T volatile&> : boost::true_type
{
};
# if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround
template <class T>
struct is_reference_to_volatile<T const volatile&> : mpl::true_
struct is_reference_to_volatile<T const volatile&> : boost::true_type
{
};
# endif
# endif
template <class T>
struct is_reference_to_pointer : mpl::false_
struct is_reference_to_pointer : boost::false_type
{
};
template <class T>
struct is_reference_to_pointer<T*&> : mpl::true_
struct is_reference_to_pointer<T*&> : boost::true_type
{
};
template <class T>
struct is_reference_to_pointer<T* const&> : mpl::true_
struct is_reference_to_pointer<T* const&> : boost::true_type
{
};
template <class T>
struct is_reference_to_pointer<T* volatile&> : mpl::true_
struct is_reference_to_pointer<T* volatile&> : boost::true_type
{
};
template <class T>
struct is_reference_to_pointer<T* const volatile&> : mpl::true_
struct is_reference_to_pointer<T* const volatile&> : boost::true_type
{
};
template <class T>
struct is_reference_to_class
: mpl::and_<
is_reference<T>
, is_class<
: boost::integral_constant<bool,
is_reference<T>::value &&
is_class<
typename remove_cv<
typename remove_reference<T>::type
>::type
>
>::value
>
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T))
};
template <class T>
struct is_pointer_to_class
: mpl::and_<
is_pointer<T>
, is_class<
: boost::integral_constant<bool,
is_pointer<T>::value &&
is_class<
typename remove_cv<
typename remove_pointer<T>::type
>::type
>
>::value
>
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_class,(T))
};

View File

@ -6,8 +6,6 @@
# include <boost/type_traits/integral_constant.hpp>
# include <boost/type_traits/remove_cv.hpp>
# include <boost/mpl/aux_/lambda_support.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/detail/workaround.hpp>
namespace boost { namespace detail {
@ -106,14 +104,12 @@ template<typename T>
struct is_incrementable :
public boost::integral_constant<bool, boost::detail::is_incrementable_::impl<T>::value>
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T))
};
template<typename T>
struct is_postfix_incrementable :
public boost::integral_constant<bool, boost::detail::is_incrementable_::postfix_impl<T>::value>
{
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T))
};
} // namespace detail

View File

@ -8,8 +8,7 @@
#ifndef BOOST_DETAIL_SORTED_HPP
#define BOOST_DETAIL_SORTED_HPP
#include <boost/detail/iterator.hpp>
#include <iterator>
#include <functional>
namespace boost {
@ -31,23 +30,23 @@ inline Iterator is_sorted_until (Iterator first, Iterator last, Comp c) {
template<class Iterator>
inline Iterator is_sorted_until (Iterator first, Iterator last) {
typedef typename boost::detail::iterator_traits<Iterator>::value_type
typedef typename std::iterator_traits<Iterator>::value_type
value_type;
typedef std::less<value_type> c;
typedef std::less<value_type> c;
return ::boost::detail::is_sorted_until(first, last, c());
return ::boost::detail::is_sorted_until(first, last, c());
}
template<class Iterator, class Comp>
inline bool is_sorted (Iterator first, Iterator last, Comp c) {
return ::boost::detail::is_sorted_until(first, last, c) == last;
}
}
template<class Iterator>
inline bool is_sorted (Iterator first, Iterator last) {
return ::boost::detail::is_sorted_until(first, last) == last;
}
}
} // detail
} // boost

View File

@ -5,13 +5,13 @@
# define BOOST_DETAIL_IS_XXX_DWA20051011_HPP
# include <boost/config.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/type_traits/integral_constant.hpp>
# include <boost/preprocessor/enum_params.hpp>
# define BOOST_DETAIL_IS_XXX_DEF(name, qualified_name, nargs) \
template <class T> \
struct is_##name : mpl::false_ \
struct is_##name : boost::false_type \
{ \
}; \
\
@ -19,7 +19,7 @@ template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class T) > \
struct is_##name< \
qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, T) > \
> \
: mpl::true_ \
: boost::true_type \
{ \
};

View File

@ -53,4 +53,4 @@ int cpp_main(int argc, char* argv[])
std::cout << std::endl;
return test_main(argc, argv);
}
}

View File

@ -11,9 +11,10 @@
#ifndef BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP
#define BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP
#include <boost/config.hpp>
#include <boost/type_traits/conversion_traits.hpp>
#include <boost/type_traits/composite_traits.hpp> // for is_reference
#if defined(__BORLANDC__)
#if defined(BOOST_BORLANDC)
#include <boost/type_traits/ice.hpp>
#endif
@ -57,7 +58,7 @@ namespace boost {
};
};
#if defined(__BORLANDC__)
#if defined(BOOST_BORLANDC)
template <class UseDefault>
struct choose_arg_or_default { typedef choose_arg type; };
template <>
@ -75,7 +76,7 @@ namespace boost {
template <class Arg, class DefaultGen, class Base, class Traits>
class resolve_default {
#if defined(__BORLANDC__)
#if defined(BOOST_BORLANDC)
typedef typename choose_arg_or_default<typename is_default<Arg>::type>::type Selector;
#else
// This usually works for Borland, but I'm seeing weird errors in

View File

@ -56,65 +56,39 @@
// 21 Jan 2001 - Created (David Abrahams)
#ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901
# define BOOST_NUMERIC_TRAITS_HPP_DWA20001901
#define BOOST_NUMERIC_TRAITS_HPP_DWA20001901
# include <boost/config.hpp>
# include <boost/cstdint.hpp>
# include <boost/static_assert.hpp>
# include <boost/type_traits.hpp>
# include <boost/detail/select_type.hpp>
# include <boost/limits.hpp>
#include <cstddef>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/cstdint.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/conditional.hpp>
#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_integral.hpp>
#endif
namespace boost { namespace detail {
// Template class is_signed -- determine whether a numeric type is signed
// Requires that T is constructable from the literals -1 and 0. Compile-time
// error results if that requirement is not met (and thus signedness is not
// likely to have meaning for that type).
template <class Number>
struct is_signed
{
#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS)
BOOST_STATIC_CONSTANT(bool, value = (Number(-1) < Number(0)));
#else
BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<Number>::is_signed);
#endif
};
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
// digit_traits - compute the number of digits in a built-in integer
// type. Needed for implementations on which numeric_limits is not specialized
// for intmax_t (e.g. VC6).
template <bool is_specialized> struct digit_traits_select;
// numeric_limits is specialized; just select that version of digits
template <> struct digit_traits_select<true>
// for some integer types, like __int128 in libstdc++ (gcc).
template <class T, bool IsSpecialized = std::numeric_limits<T>::is_specialized>
struct digit_traits
{
template <class T> struct traits
{
BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits<T>::digits);
};
BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits<T>::digits);
};
// numeric_limits is not specialized; compute digits from sizeof(T)
template <> struct digit_traits_select<false>
template <class T>
struct digit_traits<T, false>
{
template <class T> struct traits
{
BOOST_STATIC_CONSTANT(int, digits = (
sizeof(T) * std::numeric_limits<unsigned char>::digits
- (is_signed<T>::value ? 1 : 0))
);
};
};
// here's the "usable" template
template <class T> struct digit_traits
{
typedef digit_traits_select<
::std::numeric_limits<T>::is_specialized> selector;
typedef typename selector::template traits<T> traits;
BOOST_STATIC_CONSTANT(int, digits = traits::digits);
BOOST_STATIC_CONSTANT(int, digits = (
sizeof(T) * std::numeric_limits<unsigned char>::digits
- (boost::is_signed<T>::value ? 1 : 0))
);
};
#endif
@ -124,44 +98,48 @@ namespace boost { namespace detail {
template <class Integer>
struct integer_traits
{
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
private:
typedef Integer integer_type;
typedef std::numeric_limits<integer_type> x;
public:
typedef typename
if_true<(int(x::is_signed)
&& (!int(x::is_bounded)
// digits is the number of no-sign bits
|| (int(x::digits) + 1 >= digit_traits<boost::intmax_t>::digits)))>::template then<
typedef typename boost::conditional<
(int(x::is_signed)
&& (!int(x::is_bounded)
// digits is the number of no-sign bits
|| (int(x::digits) + 1 >= digit_traits<boost::intmax_t>::digits))),
Integer,
typename if_true<(int(x::digits) + 1 < digit_traits<signed int>::digits)>::template then<
signed int,
typename if_true<(int(x::digits) + 1 < digit_traits<signed long>::digits)>::template then<
signed long,
typename boost::conditional<
(int(x::digits) + 1 < digit_traits<signed int>::digits),
signed int,
// else
intmax_t
>::type>::type>::type difference_type;
typename boost::conditional<
(int(x::digits) + 1 < digit_traits<signed long>::digits),
signed long,
boost::intmax_t
>::type
>::type
>::type difference_type;
#else
BOOST_STATIC_ASSERT(boost::is_integral<Integer>::value);
typedef typename
if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then<
typename if_true<(is_signed<Integer>::value)>::template then<
Integer,
intmax_t
>::type,
typedef typename boost::conditional<
(sizeof(Integer) >= sizeof(intmax_t)),
typename if_true<(sizeof(Integer) < sizeof(std::ptrdiff_t))>::template then<
boost::conditional<
(boost::is_signed<Integer>::value),
Integer,
boost::intmax_t
>,
boost::conditional<
(sizeof(Integer) < sizeof(std::ptrdiff_t)),
std::ptrdiff_t,
intmax_t
>::type
>::type difference_type;
# endif
boost::intmax_t
>
>::type::type difference_type;
#endif
};
// Right now, only supports integers, but should be expanded.
@ -172,7 +150,7 @@ namespace boost { namespace detail {
};
template <class Number>
typename numeric_traits<Number>::difference_type numeric_distance(Number x, Number y)
inline BOOST_CONSTEXPR typename numeric_traits<Number>::difference_type numeric_distance(Number x, Number y)
{
typedef typename numeric_traits<Number>::difference_type difference_type;
return difference_type(y) - difference_type(x);

View File

@ -15,15 +15,15 @@
#include "boost/config.hpp"
# include "boost/mpl/bool.hpp"
# include "boost/type_traits/integral_constant.hpp"
# include "boost/type_traits/has_nothrow_copy.hpp"
#include "boost/mpl/void.hpp"
namespace boost {
namespace detail {
struct void_type {};
///////////////////////////////////////////////////////////////////////////////
// (detail) class template reference_content
//
@ -71,7 +71,7 @@ public: // queries
// Wraps with reference_content if specified type is reference.
//
template <typename T = mpl::void_> struct make_reference_content;
template <typename T = void_type> struct make_reference_content;
template <typename T>
@ -88,7 +88,7 @@ struct make_reference_content< T& >
template <>
struct make_reference_content< mpl::void_ >
struct make_reference_content< void_type >
{
template <typename T>
struct apply
@ -96,7 +96,7 @@ struct make_reference_content< mpl::void_ >
{
};
typedef mpl::void_ type;
typedef void_type type;
};
} // namespace detail
@ -110,7 +110,7 @@ template <typename T>
struct has_nothrow_copy<
::boost::detail::reference_content< T& >
>
: mpl::true_
: boost::true_type
{
};

View File

@ -14,7 +14,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// utf8_codecvt_facet.hpp
// This header defines class utf8_codecvt_facet, derived from
// This header defines class utf8_codecvt_facet, derived from
// std::codecvt<wchar_t, char>, which can be used to convert utf8 data in
// files into wchar_t strings in the application.
//
@ -23,10 +23,10 @@
// we want to avoid code duplication. It would be possible to create utf8
// library, but:
// - this requires review process first
// - in the case, when linking the a library which uses utf8
// - in the case, when linking the a library which uses utf8
// (say 'program_options'), user should also link to the utf8 library.
// This seems inconvenient, and asking a user to link to an unrevieved
// library is strange.
// This seems inconvenient, and asking a user to link to an unrevieved
// library is strange.
// Until the above points are fixed, a library which wants to use utf8 must:
// - include this header in one of it's headers or sources
// - include the corresponding boost/detail/utf8_codecvt_facet.ipp file in one
@ -39,14 +39,14 @@
// symbols.
//
// For example, program_options library might contain:
// #define BOOST_UTF8_BEGIN_NAMESPACE <backslash character>
// #define BOOST_UTF8_BEGIN_NAMESPACE <backslash character>
// namespace boost { namespace program_options {
// #define BOOST_UTF8_END_NAMESPACE }}
// #define BOOST_UTF8_DECL BOOST_PROGRAM_OPTIONS_DECL
// #include <boost/detail/utf8_codecvt_facet.ipp>
//
// Essentially, each library will have its own copy of utf8 code, in
// different namespaces.
// different namespaces.
// Note:(Robert Ramey). I have made the following alterations in the original
// code.
@ -67,7 +67,7 @@
// use two template parameters
//
// utf8_codecvt_facet
// This is an implementation of a std::codecvt facet for translating
// This is an implementation of a std::codecvt facet for translating
// from UTF-8 externally to UCS-4. Note that this is not tied to
// any specific types in order to allow customization on platforms
// where wchar_t is not big enough.
@ -110,27 +110,28 @@ BOOST_UTF8_BEGIN_NAMESPACE
#endif
struct BOOST_SYMBOL_VISIBLE utf8_codecvt_facet :
public std::codecvt<wchar_t, char, std::mbstate_t>
public std::codecvt<wchar_t, char, std::mbstate_t>
{
public:
BOOST_UTF8_DECL explicit utf8_codecvt_facet(std::size_t no_locale_manage=0);
virtual ~utf8_codecvt_facet(){}
BOOST_UTF8_DECL explicit utf8_codecvt_facet(std::size_t no_locale_manage = 0);
BOOST_UTF8_DECL virtual ~utf8_codecvt_facet();
protected:
BOOST_UTF8_DECL virtual std::codecvt_base::result do_in(
std::mbstate_t& state,
std::mbstate_t& state,
const char * from,
const char * from_end,
const char * from_end,
const char * & from_next,
wchar_t * to,
wchar_t * to_end,
wchar_t*& to_next
wchar_t * to,
wchar_t * to_end,
wchar_t * & to_next
) const;
BOOST_UTF8_DECL virtual std::codecvt_base::result do_out(
std::mbstate_t & state,
const wchar_t * from,
const wchar_t * from_end,
const wchar_t* & from_next,
const wchar_t * & from_next,
char * to,
char * to_end,
char * & to_next
@ -140,7 +141,7 @@ protected:
return (octet_1 < 0x80|| 0xbf< octet_1);
}
bool invalid_leading_octet(unsigned char octet_1) const {
bool invalid_leading_octet(unsigned char octet_1) const {
return (0x7f < octet_1 && octet_1 < 0xc0) ||
(octet_1 > 0xfd);
}
@ -154,7 +155,7 @@ protected:
// How many "continuing octets" will be needed for this word
// == total octets - 1.
BOOST_UTF8_DECL int get_cont_octet_out_count(wchar_t word) const ;
BOOST_UTF8_DECL static int get_cont_octet_out_count(wchar_t word);
virtual bool do_always_noconv() const BOOST_NOEXCEPT_OR_NOTHROW {
return false;
@ -162,7 +163,7 @@ protected:
// UTF-8 isn't really stateful since we rewind on partial conversions
virtual std::codecvt_base::result do_unshift(
std::mbstate_t&,
std::mbstate_t &,
char * from,
char * /*to*/,
char * & next
@ -179,19 +180,21 @@ protected:
// How many char objects can I process to get <= max_limit
// wchar_t objects?
BOOST_UTF8_DECL virtual int do_length(
const std::mbstate_t &,
std::mbstate_t &,
const char * from,
const char * from_end,
const char * from_end,
std::size_t max_limit
) const
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
throw()
#endif
;
// Nonstandard override
virtual int do_length(
std::mbstate_t & s,
const std::mbstate_t & s,
const char * from,
const char * from_end,
const char * from_end,
std::size_t max_limit
) const
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
@ -199,12 +202,13 @@ protected:
#endif
{
return do_length(
const_cast<const std::mbstate_t &>(s),
const_cast<std::mbstate_t &>(s),
from,
from_end,
max_limit
);
}
// Largest possible value do_length(state,from,from_end,1) could return.
virtual int do_max_length() const BOOST_NOEXCEPT_OR_NOTHROW {
return 6; // largest UTF-8 encoding of a UCS-4 character

View File

@ -2,7 +2,7 @@
// utf8_codecvt_facet.ipp
// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
// Use, modification and distribution is subject to 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)
@ -18,7 +18,7 @@
#include <boost/limits.hpp>
#include <boost/config.hpp>
// If we don't have wstring, then Unicode support
// If we don't have wstring, then Unicode support
// is not available anyway, so we don't need to even
// compiler this file. This also fixes the problem
// with mingw, which can compile this file, but will
@ -30,105 +30,117 @@ BOOST_UTF8_BEGIN_NAMESPACE
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation for wchar_t
namespace detail {
inline const wchar_t * get_octet1_modifier_table() BOOST_NOEXCEPT
{
static const wchar_t octet1_modifier_table[] = {
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
};
return octet1_modifier_table;
}
} // namespace detail
BOOST_UTF8_DECL utf8_codecvt_facet::utf8_codecvt_facet(
std::size_t no_locale_manage
) :
std::codecvt<wchar_t, char, std::mbstate_t>(no_locale_manage)
{}
BOOST_UTF8_DECL utf8_codecvt_facet::~utf8_codecvt_facet()
{}
// Translate incoming UTF-8 into UCS-4
BOOST_UTF8_DECL std::codecvt_base::result utf8_codecvt_facet::do_in(
std::mbstate_t& /*state*/,
std::mbstate_t& /*state*/,
const char * from,
const char * from_end,
const char * from_end,
const char * & from_next,
wchar_t * to,
wchar_t * to_end,
wchar_t * to,
wchar_t * to_end,
wchar_t * & to_next
) const {
// Basic algorithm: The first octet determines how many
// octets total make up the UCS-4 character. The remaining
// Basic algorithm: The first octet determines how many
// octets total make up the UCS-4 character. The remaining
// "continuing octets" all begin with "10". To convert, subtract
// the amount that specifies the number of octets from the first
// octet. Subtract 0x80 (1000 0000) from each continuing octet,
// then mash the whole lot together. Note that each continuing
// octet. Subtract 0x80 (1000 0000) from each continuing octet,
// then mash the whole lot together. Note that each continuing
// octet only uses 6 bits as unique values, so only shift by
// multiples of 6 to combine.
const wchar_t * const octet1_modifier_table = detail::get_octet1_modifier_table();
while (from != from_end && to != to_end) {
// Error checking on the first octet
if (invalid_leading_octet(*from)){
// Error checking on the first octet
if (invalid_leading_octet(*from)) {
from_next = from;
to_next = to;
return std::codecvt_base::error;
}
// The first octet is adjusted by a value dependent upon
// the number of "continuing octets" encoding the character
const int cont_octet_count = get_cont_octet_count(*from);
const wchar_t octet1_modifier_table[] = {
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
};
// The first octet is adjusted by a value dependent upon
// the number of "continuing octets" encoding the character
const int cont_octet_count = get_cont_octet_count(*from);
// The unsigned char conversion is necessary in case char is
// signed (I learned this the hard way)
wchar_t ucs_result =
// signed (I learned this the hard way)
wchar_t ucs_result =
(unsigned char)(*from++) - octet1_modifier_table[cont_octet_count];
// Invariants :
// 1) At the start of the loop, 'i' continuing characters have been
// processed
// 2) *from points to the next continuing character to be processed.
int i = 0;
while(i != cont_octet_count && from != from_end) {
// Invariants:
// 1) At the start of the loop, 'i' continuing characters have been
// processed
// 2) *from points to the next continuing character to be processed.
int i = 0;
while (i != cont_octet_count && from != from_end) {
// Error checking on continuing characters
if (invalid_continuing_octet(*from)) {
from_next = from;
to_next = to;
from_next = from;
to_next = to;
return std::codecvt_base::error;
}
ucs_result *= (1 << 6);
ucs_result *= (1 << 6);
// each continuing character has an extra (10xxxxxx)b attached to
// each continuing character has an extra (10xxxxxx)b attached to
// it that must be removed.
ucs_result += (unsigned char)(*from++) - 0x80;
++i;
}
// If the buffer ends with an incomplete unicode character...
if (from == from_end && i != cont_octet_count) {
// If the buffer ends with an incomplete unicode character...
if (from == from_end && i != cont_octet_count) {
// rewind "from" to before the current character translation
from_next = from - (i+1);
from_next = from - (i + 1);
to_next = to;
return std::codecvt_base::partial;
}
*to++ = ucs_result;
*to++ = ucs_result;
}
from_next = from;
to_next = to;
// Were we done converting or did we run out of destination space?
if(from == from_end) return std::codecvt_base::ok;
else return std::codecvt_base::partial;
if (from == from_end)
return std::codecvt_base::ok;
else
return std::codecvt_base::partial;
}
BOOST_UTF8_DECL std::codecvt_base::result utf8_codecvt_facet::do_out(
std::mbstate_t& /*state*/,
const wchar_t * from,
const wchar_t * from_end,
std::mbstate_t& /*state*/,
const wchar_t * from,
const wchar_t * from_end,
const wchar_t * & from_next,
char * to,
char * to_end,
char * to,
char * to_end,
char * & to_next
) const
{
// RG - consider merging this table with the other one
const wchar_t octet1_modifier_table[] = {
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc
};
const wchar_t * const octet1_modifier_table = detail::get_octet1_modifier_table();
wchar_t max_wchar = (std::numeric_limits<wchar_t>::max)();
while (from != from_end && to != to_end) {
@ -141,75 +153,69 @@ BOOST_UTF8_DECL std::codecvt_base::result utf8_codecvt_facet::do_out(
int cont_octet_count = get_cont_octet_out_count(*from);
// RG - comment this formula better
int shift_exponent = (cont_octet_count) * 6;
// RG - comment this formula better
int shift_exponent = cont_octet_count * 6;
// Process the first character
*to++ = static_cast<char>(octet1_modifier_table[cont_octet_count] +
(unsigned char)(*from / (1 << shift_exponent)));
// Process the continuation characters
// Invariants: At the start of the loop:
// 1) 'i' continuing octets have been generated
// 2) '*to' points to the next location to place an octet
// 3) shift_exponent is 6 more than needed for the next octet
int i = 0;
while (i != cont_octet_count && to != to_end) {
// Process the continuation characters
// Invariants: At the start of the loop:
// 1) 'i' continuing octets have been generated
// 2) '*to' points to the next location to place an octet
// 3) shift_exponent is 6 more than needed for the next octet
int i = 0;
while (i != cont_octet_count && to != to_end) {
shift_exponent -= 6;
*to++ = static_cast<char>(0x80 + ((*from / (1 << shift_exponent)) % (1 << 6)));
++i;
}
// If we filled up the out buffer before encoding the character
if(to == to_end && i != cont_octet_count) {
// If we filled up the out buffer before encoding the character
if (to == to_end && i != cont_octet_count) {
from_next = from;
to_next = to - (i+1);
to_next = to - (i + 1);
return std::codecvt_base::partial;
}
++from;
}
from_next = from;
to_next = to;
// Were we done or did we run out of destination space
if(from == from_end) return std::codecvt_base::ok;
else return std::codecvt_base::partial;
if (from == from_end)
return std::codecvt_base::ok;
else
return std::codecvt_base::partial;
}
// How many char objects can I process to get <= max_limit
// wchar_t objects?
BOOST_UTF8_DECL int utf8_codecvt_facet::do_length(
const std::mbstate_t &,
std::mbstate_t &,
const char * from,
const char * from_end,
const char * from_end,
std::size_t max_limit
) const
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
throw()
#endif
{
// RG - this code is confusing! I need a better way to express it.
// and test cases.
// Invariants:
// 1) last_octet_count has the size of the last measured character
// 2) char_count holds the number of characters shown to fit
// within the bounds so far (no greater than max_limit)
// 3) from_next points to the octet 'last_octet_count' before the
// last measured character.
int last_octet_count=0;
std::size_t char_count = 0;
const char* from_next = from;
// Use "<" because the buffer may represent incomplete characters
while (from_next+last_octet_count <= from_end && char_count <= max_limit) {
from_next += last_octet_count;
last_octet_count = (get_octet_count(*from_next));
++char_count;
{
const char * from_next = from;
for (std::size_t char_count = 0u; char_count < max_limit && from_next < from_end; ++char_count) {
unsigned int octet_count = get_octet_count(*from_next);
// The buffer may represent incomplete characters, so terminate early if one is found
if (octet_count > static_cast<std::size_t>(from_end - from_next))
break;
from_next += octet_count;
}
return static_cast<int>(from_next-from);
return static_cast<int>(from_next - from);
}
BOOST_UTF8_DECL unsigned int utf8_codecvt_facet::get_octet_count(
unsigned char lead_octet
){
unsigned char lead_octet
) {
// if the 0-bit (MSB) is 0, then 1 character
if (lead_octet <= 0x7f) return 1;
@ -226,7 +232,7 @@ BOOST_UTF8_DECL unsigned int utf8_codecvt_facet::get_octet_count(
namespace detail {
template<std::size_t s>
int get_cont_octet_out_count_impl(wchar_t word){
inline int get_cont_octet_out_count_impl(wchar_t word) {
if (word < 0x80) {
return 0;
}
@ -237,7 +243,7 @@ int get_cont_octet_out_count_impl(wchar_t word){
}
template<>
int get_cont_octet_out_count_impl<4>(wchar_t word){
inline int get_cont_octet_out_count_impl<4>(wchar_t word) {
if (word < 0x80) {
return 0;
}
@ -249,7 +255,7 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
// where wchar_t is defined as UCS2. The warnings are superfluous as the
// specialization is never instantitiated with such compilers, but this
// can cause problems if warnings are being treated as errors, so we guard
// against that. Including <boost/detail/utf8_codecvt_facet.hpp> as we do
// against that. Including <boost/detail/utf8_codecvt_facet.hpp> as we do
// should be enough to get WCHAR_MAX defined.
#if !defined(WCHAR_MAX)
# error WCHAR_MAX not defined!
@ -258,8 +264,8 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
#if defined(_MSC_VER) && _MSC_VER <= 1310 // 7.1 or earlier
return 2;
#elif WCHAR_MAX > 0x10000
if (word < 0x10000) {
if (word < 0x10000) {
return 2;
}
if (word < 0x200000) {
@ -269,7 +275,7 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
return 4;
}
return 5;
#else
return 2;
#endif
@ -281,9 +287,10 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
// == total octets - 1.
BOOST_UTF8_DECL int utf8_codecvt_facet::get_cont_octet_out_count(
wchar_t word
) const {
) {
return detail::get_cont_octet_out_count_impl<sizeof(wchar_t)>(word);
}
BOOST_UTF8_END_NAMESPACE
#endif

View File

@ -19,7 +19,6 @@
"Miscellaneous"
],
"maintainers": [
"Beman Dawes <bdawes -at- acm.org>",
"Robert Ramey <ramey -at- rrsd.com>",
"Rene Rivera <grafikrobot -at- gmail.com>",
"Andrey Semashev <andrey.semashev -at- gmail.com>"

View File

@ -5,24 +5,34 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
################################################################################
import testing ;
import config : requires ;
build-project container_fwd ;
project detail/test
project detail/test
: requirements
<library>/boost/detail//boost_detail
<library>/boost/type_traits//boost_type_traits
<c++-template-depth>300
<toolset>clang:<cxxflags>-Wno-unused
<toolset>clang:<cxxflags>-Wno-tautological-compare
<toolset>clang:<cxxflags>-ftemplate-depth-300
<toolset>gcc:<cxxflags>-ftemplate-depth-300
<toolset>gcc:<define>_STLP_DEBUG
<toolset>gcc:<define>_GLIBCXX_DEBUG
<toolset>darwin:<cxxflags>-ftemplate-depth-300
# Do not enable libstdc++ debug mode because of gcc 10.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95289
# <toolset>gcc:<define>_GLIBCXX_DEBUG
;
# import rules for testing conditional on config file variables
import ../../config/checks/config : requires ;
import-search /boost/config/checks ;
import config : requires ;
run binary_search_test.cpp ;
run is_sorted_test.cpp ;
run test_utf8_codecvt.cpp : :
: [ requires std_wstreambuf ]
;
run blank_test.cpp ;
run bitmask_test.cpp : : : [ requires cxx11_scoped_enums ] ;
run is_sorted_test.cpp /boost/array//boost_array ;
run numeric_traits_test.cpp ;
run is_xxx_test.cpp /boost/preprocessor//boost_preprocessor ;
# run test_utf8_codecvt.cpp : : : [ requires std_wstreambuf ] ;
run test_utf8_codecvt.cpp ;
run allocator_utilities_test.cpp ;
run reference_content_test.cpp ;

View File

@ -0,0 +1,46 @@
// Copyright 2018 Daniel James.
// 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/detail/allocator_utilities.hpp>
#include <boost/static_assert.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/is_same.hpp>
#include <memory>
typedef std::allocator<int> std_int_allocator;
typedef boost::detail::allocator::rebind_to<std_int_allocator, char>::type char_allocator;
typedef boost::detail::allocator::rebind_to<char_allocator, int>::type int_allocator;
typedef boost::detail::allocator::rebind_to<int_allocator, char>::type char_allocator2;
int main()
{
BOOST_STATIC_ASSERT((!boost::is_same<char_allocator, int_allocator>::value));
BOOST_STATIC_ASSERT((boost::is_same<char_allocator, char_allocator2>::value));
// Check the constructors works okay
std_int_allocator a1;
char_allocator a2(a1);
char_allocator a2a(a2);
int_allocator a3(a2);
// Check allocate works okay
{
boost::allocator_pointer<char_allocator>::type p = a2.allocate(10);
BOOST_TEST(!!p);
a2.deallocate(p, 10);
}
// Try using the standalone construct/destroy
{
boost::allocator_pointer<int_allocator>::type p2 = a3.allocate(1);
boost::detail::allocator::construct(p2, 25);
BOOST_TEST(*p2 == 25);
boost::detail::allocator::destroy(p2);
a3.deallocate(p2, 1);
}
return boost::report_errors();
}

View File

@ -3,18 +3,19 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/detail/binary_search.hpp>
#include <vector>
#include <string>
#include <memory>
#include <climits>
#include <iostream>
#include <cassert>
#include <cstddef>
#include <stdlib.h> // for rand(). Would use cstdlib but VC6.4 doesn't put it in std::
#include <list>
#include <utility>
#include <algorithm>
#include <boost/detail/binary_search.hpp>
#include <boost/detail/workaround.hpp>
#include <cstddef>
#include <boost/core/lightweight_test.hpp>
#if defined(__SGI_STL_PORT) ? defined(__SGI_STL_OWN_IOSTREAMS) : (!defined(__GNUC__) || __GNUC__ > 2)
# define USE_SSTREAM
@ -32,7 +33,7 @@ namespace {
struct mystring : std::string
{
typedef std::string base;
mystring(std::string const& x)
: base(x) {}
};
@ -180,13 +181,13 @@ template <class Sequence, class Compare>
void test_loop(Sequence& x, Compare cmp, unsigned long test_count)
{
typedef typename Sequence::const_iterator const_iterator;
for (unsigned long i = 0; i < test_count; ++i)
{
random_sorted_sequence(x);
const const_iterator start = x.begin();
const const_iterator finish = x.end();
unsigned key = random_number();
const const_iterator l = searches<Compare>::lower_bound(start, finish, key, cmp);
const const_iterator u = searches<Compare>::upper_bound(start, finish, key, cmp);
@ -204,38 +205,40 @@ void test_loop(Sequence& x, Compare cmp, unsigned long test_count)
if (p == u)
{
assert(found_l);
BOOST_TEST(found_l);
found_u = true;
}
unsigned value = to_int(*p);
assert(value >= last_value);
BOOST_TEST(value >= last_value);
last_value = value;
if (!found_l)
{
++index;
assert(to_int(*p) < key);
BOOST_TEST(to_int(*p) < key);
}
else if (!found_u)
{
++count;
assert(to_int(*p) == key);
BOOST_TEST(to_int(*p) == key);
}
else
assert(to_int(*p) > key);
{
BOOST_TEST(to_int(*p) > key);
}
}
assert(found_l || l == finish);
assert(found_u || u == finish);
BOOST_TEST(found_l || l == finish);
BOOST_TEST(found_u || u == finish);
std::pair<const_iterator, const_iterator>
range = searches<Compare>::equal_range(start, finish, key, cmp);
assert(range.first == l);
assert(range.second == u);
BOOST_TEST(range.first == l);
BOOST_TEST(range.second == u);
bool found = searches<Compare>::binary_search(start, finish, key, cmp);
(void)found;
assert(found == (u != l));
BOOST_TEST(found == (u != l));
std::cout << "found " << count << " copies of " << key << " at index " << index << "\n";
}
}
@ -256,5 +259,6 @@ int main()
std::cout << "=== testing bidirectional iterators with compare: ===\n";
test_loop(y, cmp(), 25);
std::cerr << "******TEST PASSED******\n";
return 0;
return boost::report_errors();
}

184
test/bitmask_test.cpp Normal file
View File

@ -0,0 +1,184 @@
/*
* 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)
*
* Copyright (c) 2025 Andrey Semashev
*/
#include <boost/detail/bitmask.hpp>
#include <boost/core/lightweight_test.hpp>
enum unscoped_enum
{
zero = 0,
one = 1,
two = 2,
four = 4
};
BOOST_BITMASK(unscoped_enum)
void test_unscoped_enum()
{
BOOST_TEST((one | two) == ((unscoped_enum)(1 | 2)));
BOOST_TEST((one & two) == ((unscoped_enum)(1 & 2)));
BOOST_TEST((one ^ two) == ((unscoped_enum)(1 ^ 2)));
BOOST_TEST((one | one) == ((unscoped_enum)(1 | 1)));
BOOST_TEST((one & one) == ((unscoped_enum)(1 & 1)));
BOOST_TEST((one ^ one) == ((unscoped_enum)(1 ^ 1)));
BOOST_TEST((~one) == ((unscoped_enum)(~1)));
{
unscoped_enum val = one;
val |= two;
BOOST_TEST(val == ((unscoped_enum)(1 | 2)));
}
{
unscoped_enum val = one;
val &= two;
BOOST_TEST(val == ((unscoped_enum)(1 & 2)));
}
{
unscoped_enum val = one;
val ^= two;
BOOST_TEST(val == ((unscoped_enum)(1 ^ 2)));
}
{
unscoped_enum val = one;
val |= one;
BOOST_TEST(val == ((unscoped_enum)(1 | 1)));
}
{
unscoped_enum val = one;
val &= one;
BOOST_TEST(val == ((unscoped_enum)(1 & 1)));
}
{
unscoped_enum val = one;
val ^= one;
BOOST_TEST(val == ((unscoped_enum)(1 ^ 1)));
}
BOOST_TEST(!zero);
BOOST_TEST(!!one);
}
enum class scoped_enum
{
none = 0,
x = 8,
y = 16,
z = 32
};
BOOST_BITMASK(scoped_enum)
void test_scoped_enum()
{
BOOST_TEST((scoped_enum::x | scoped_enum::y) == ((scoped_enum)(8 | 16)));
BOOST_TEST((scoped_enum::x & scoped_enum::y) == ((scoped_enum)(8 & 16)));
BOOST_TEST((scoped_enum::x ^ scoped_enum::y) == ((scoped_enum)(8 ^ 16)));
BOOST_TEST((scoped_enum::x | scoped_enum::x) == ((scoped_enum)(8 | 8)));
BOOST_TEST((scoped_enum::x & scoped_enum::x) == ((scoped_enum)(8 & 8)));
BOOST_TEST((scoped_enum::x ^ scoped_enum::x) == ((scoped_enum)(8 ^ 8)));
BOOST_TEST((~scoped_enum::x) == ((scoped_enum)(~8)));
{
scoped_enum val = scoped_enum::x;
val |= scoped_enum::y;
BOOST_TEST(val == ((scoped_enum)(8 | 16)));
}
{
scoped_enum val = scoped_enum::x;
val &= scoped_enum::y;
BOOST_TEST(val == ((scoped_enum)(8 & 16)));
}
{
scoped_enum val = scoped_enum::x;
val ^= scoped_enum::y;
BOOST_TEST(val == ((scoped_enum)(8 ^ 16)));
}
{
scoped_enum val = scoped_enum::x;
val |= scoped_enum::x;
BOOST_TEST(val == ((scoped_enum)(8 | 8)));
}
{
scoped_enum val = scoped_enum::x;
val &= scoped_enum::x;
BOOST_TEST(val == ((scoped_enum)(8 & 8)));
}
{
scoped_enum val = scoped_enum::x;
val ^= scoped_enum::x;
BOOST_TEST(val == ((scoped_enum)(8 ^ 8)));
}
BOOST_TEST(!scoped_enum::none);
BOOST_TEST(!!scoped_enum::x);
}
namespace my_namespace {
enum class namespaced_enum : unsigned int
{
empty = 0,
a = 64,
b = 128,
c = 256
};
BOOST_BITMASK(namespaced_enum)
} // namespace my_namespace
void test_namespaced_enum()
{
BOOST_TEST((my_namespace::namespaced_enum::a | my_namespace::namespaced_enum::b) == ((my_namespace::namespaced_enum)(64u | 128u)));
BOOST_TEST((my_namespace::namespaced_enum::a & my_namespace::namespaced_enum::b) == ((my_namespace::namespaced_enum)(64u & 128u)));
BOOST_TEST((my_namespace::namespaced_enum::a ^ my_namespace::namespaced_enum::b) == ((my_namespace::namespaced_enum)(64u ^ 128u)));
BOOST_TEST((my_namespace::namespaced_enum::a | my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(64u | 64u)));
BOOST_TEST((my_namespace::namespaced_enum::a & my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(64u & 64u)));
BOOST_TEST((my_namespace::namespaced_enum::a ^ my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(64u ^ 64u)));
BOOST_TEST((~my_namespace::namespaced_enum::a) == ((my_namespace::namespaced_enum)(~64u)));
{
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
val |= my_namespace::namespaced_enum::b;
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u | 128u)));
}
{
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
val &= my_namespace::namespaced_enum::b;
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u & 128u)));
}
{
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
val ^= my_namespace::namespaced_enum::b;
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u ^ 128u)));
}
{
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
val |= my_namespace::namespaced_enum::a;
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u | 64u)));
}
{
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
val &= my_namespace::namespaced_enum::a;
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u & 64u)));
}
{
my_namespace::namespaced_enum val = my_namespace::namespaced_enum::a;
val ^= my_namespace::namespaced_enum::a;
BOOST_TEST(val == ((my_namespace::namespaced_enum)(64u ^ 64u)));
}
BOOST_TEST(!my_namespace::namespaced_enum::empty);
BOOST_TEST(!!my_namespace::namespaced_enum::a);
}
int main()
{
test_unscoped_enum();
test_scoped_enum();
test_namespaced_enum();
return boost::report_errors();
}

37
test/blank_test.cpp Normal file
View File

@ -0,0 +1,37 @@
// Copyright 2018 Daniel James.
// 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/blank.hpp>
#include <boost/static_assert.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/is_pod.hpp>
#include <boost/type_traits/is_empty.hpp>
#include <boost/type_traits/is_stateless.hpp>
#if !defined(BOOST_NO_IOSTREAM)
#include <sstream>
#endif
int main()
{
BOOST_STATIC_ASSERT((boost::is_pod<boost::blank>::value));
BOOST_STATIC_ASSERT((boost::is_empty<boost::blank>::value));
BOOST_STATIC_ASSERT((boost::is_stateless<boost::blank>::value));
boost::blank b1,b2;
BOOST_TEST(b1 == b2);
BOOST_TEST(b1 <= b2);
BOOST_TEST(b1 >= b2);
BOOST_TEST(!(b1 != b2));
BOOST_TEST(!(b1 < b2));
BOOST_TEST(!(b1 > b2));
#if !defined(BOOST_NO_IOSTREAM)
std::stringstream s;
s << "(" << b1 << ")";
BOOST_TEST(s.str() == "()");
#endif
return boost::report_errors();
}

View File

@ -9,9 +9,12 @@ project detail/test/container_fwd
: requirements
<warnings>all
<toolset>intel:<warnings>on
<toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
<toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
<toolset>clang:<cxxflags>"-pedantic -Wextra -Wmismatched-tags"
<toolset>gcc:<warnings>pedantic
<toolset>gcc:<cxxflags>"-Wstrict-aliasing -fstrict-aliasing -Wsign-promo -Wunused-parameter -Wconversion"
<toolset>darwin:<warnings>pedantic
<toolset>darwin:<cxxflags>"-Wstrict-aliasing -fstrict-aliasing -Wsign-promo -Wunused-parameter -Wconversion"
<toolset>clang:<warnings>pedantic
<toolset>clang:<cxxflags>"-Wmismatched-tags"
<warnings-as-errors>on
;

View File

@ -5,11 +5,11 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/detail/is_sorted.hpp>
#include <iostream>
#include <boost/config.hpp>
#include <boost/array.hpp>
#include <boost/detail/is_sorted.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
struct tracking_less {

23
test/is_xxx_test.cpp Normal file
View File

@ -0,0 +1,23 @@
// Copyright 2018 Daniel James.
// 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/detail/is_xxx.hpp>
#include <boost/static_assert.hpp>
namespace is_xxx_test {
template <typename T> struct thing1 {};
template <typename T1, typename T2 = int> struct thing2 {};
}
BOOST_DETAIL_IS_XXX_DEF(thing1, is_xxx_test::thing1, 1);
BOOST_DETAIL_IS_XXX_DEF(thing2, is_xxx_test::thing2, 2);
BOOST_STATIC_ASSERT((is_thing1<is_xxx_test::thing1<int> >::value));
BOOST_STATIC_ASSERT((!is_thing1<is_xxx_test::thing2<int> >::value));
BOOST_STATIC_ASSERT((!is_thing2<is_xxx_test::thing1<int> >::value));
BOOST_STATIC_ASSERT((is_thing2<is_xxx_test::thing2<int> >::value));
BOOST_STATIC_ASSERT((is_thing2<is_xxx_test::thing2<int, float> >::value));
int main() {}

View File

@ -0,0 +1,422 @@
// (C) Copyright David Abrahams 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)
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 1 Apr 2001 Fixes for ICL; use BOOST_STATIC_CONSTANT
// 11 Feb 2001 Fixes for Borland (David Abrahams)
// 23 Jan 2001 Added test for wchar_t (David Abrahams)
// 23 Jan 2001 Now statically selecting a test for signed numbers to avoid
// warnings with fancy compilers. Added commentary and
// additional dumping of traits data for tested types (David
// Abrahams).
// 21 Jan 2001 Initial version (David Abrahams)
#include <boost/detail/numeric_traits.hpp>
#include <cassert>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <climits>
#include <typeinfo>
#include <iostream>
#include <sstream>
#include <string>
#ifndef BOOST_NO_LIMITS
#include <limits>
#endif
// =================================================================================
// template class complement_traits<Number> --
//
// statically computes the max and min for 1s and 2s-complement binary
// numbers. This helps on platforms without <limits> support. It also shows
// an example of a recursive template that works with MSVC!
//
template <unsigned size> struct complement; // forward
// The template complement, below, does all the real work, using "poor man's
// partial specialization". We need complement_traits_aux<> so that MSVC doesn't
// complain about undefined min/max as we're trying to recursively define them.
template <class Number, unsigned size>
struct complement_traits_aux
{
BOOST_STATIC_CONSTANT(Number, max = complement<size>::template traits<Number>::max);
BOOST_STATIC_CONSTANT(Number, min = complement<size>::template traits<Number>::min);
};
template <unsigned size>
struct complement
{
template <class Number>
struct traits
{
private:
// indirection through complement_traits_aux necessary to keep MSVC happy
typedef complement_traits_aux<Number, size - 1> prev;
public:
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
// GCC 4.0.2 ICEs on these C-style casts
BOOST_STATIC_CONSTANT(Number, max =
Number((prev::max) << CHAR_BIT)
+ Number(UCHAR_MAX));
BOOST_STATIC_CONSTANT(Number, min = Number((prev::min) << CHAR_BIT));
#else
// Avoid left shifting negative integers, use multiplication instead
BOOST_STATIC_CONSTANT(Number, shift = 1u << CHAR_BIT);
BOOST_STATIC_CONSTANT(Number, max =
Number(Number(prev::max) * shift)
+ Number(UCHAR_MAX));
BOOST_STATIC_CONSTANT(Number, min = Number(Number(prev::min) * shift));
#endif
};
};
// Template class complement_base<> -- defines values for min and max for
// complement<1>, at the deepest level of recursion. Uses "poor man's partial
// specialization" again.
template <bool is_signed> struct complement_base;
template <> struct complement_base<false>
{
template <class Number>
struct values
{
BOOST_STATIC_CONSTANT(Number, min = 0);
BOOST_STATIC_CONSTANT(Number, max = UCHAR_MAX);
};
};
template <> struct complement_base<true>
{
template <class Number>
struct values
{
BOOST_STATIC_CONSTANT(Number, min = SCHAR_MIN);
BOOST_STATIC_CONSTANT(Number, max = SCHAR_MAX);
};
};
// Base specialization of complement, puts an end to the recursion.
template <>
struct complement<1>
{
template <class Number>
struct traits
{
BOOST_STATIC_CONSTANT(bool, is_signed = boost::is_signed<Number>::value);
BOOST_STATIC_CONSTANT(Number, min =
complement_base<is_signed>::template values<Number>::min);
BOOST_STATIC_CONSTANT(Number, max =
complement_base<is_signed>::template values<Number>::max);
};
};
// Now here's the "pretty" template you're intended to actually use.
// complement_traits<Number>::min, complement_traits<Number>::max are the
// minimum and maximum values of Number if Number is a built-in integer type.
template <class Number>
struct complement_traits
{
BOOST_STATIC_CONSTANT(Number, max = (complement_traits_aux<Number, sizeof(Number)>::max));
BOOST_STATIC_CONSTANT(Number, min = (complement_traits_aux<Number, sizeof(Number)>::min));
};
// =================================================================================
// Support for streaming various numeric types in exactly the format I want. I
// needed this in addition to all the assertions so that I could see exactly
// what was going on.
//
// Numbers go through a 2-stage conversion process (by default, though, no real
// conversion).
//
template <class T> struct stream_as {
typedef T t1;
typedef T t2;
};
// char types first get converted to unsigned char, then to unsigned.
template <> struct stream_as<char> {
typedef unsigned char t1;
typedef unsigned t2;
};
template <> struct stream_as<unsigned char> {
typedef unsigned char t1; typedef unsigned t2;
};
template <> struct stream_as<signed char> {
typedef unsigned char t1; typedef unsigned t2;
};
// C++20 ostream has deleted operator<< for wchar_t
template <> struct stream_as<wchar_t> {
typedef unsigned int t1;
typedef unsigned int t2;
};
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
// With this library implementation, __int64 and __uint64 get streamed as strings
template <> struct stream_as<boost::uintmax_t> {
typedef std::string t1;
typedef std::string t2;
};
template <> struct stream_as<boost::intmax_t> {
typedef std::string t1;
typedef std::string t2;
};
#endif
// Standard promotion process for streaming
template <class T> struct promote
{
static typename stream_as<T>::t1 from(T x) {
typedef typename stream_as<T>::t1 t1;
return t1(x);
}
};
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
// On this platform, stream them as long/unsigned long if they fit.
// Otherwise, write a string.
template <> struct promote<boost::uintmax_t> {
std::string static from(const boost::uintmax_t x) {
if (x > ULONG_MAX)
return std::string("large unsigned value");
else {
std::ostringstream strm;
strm << (unsigned long)x;
return strm.str();
}
}
};
template <> struct promote<boost::intmax_t> {
std::string static from(const boost::intmax_t x) {
if (x > boost::intmax_t(ULONG_MAX))
return std::string("large positive signed value");
else if (x >= 0) {
std::ostringstream strm;
strm << (unsigned long)x;
return strm.str();
}
if (x < boost::intmax_t(LONG_MIN))
return std::string("large negative signed value");
else {
std::ostringstream strm;
strm << (long)x;
return strm.str();
}
}
};
#endif
// This is the function which converts types to the form I want to stream them in.
template <class T>
typename stream_as<T>::t2 stream_number(T x)
{
return promote<T>::from(x);
}
// =================================================================================
//
// Tests for built-in signed and unsigned types
//
// Tag types for selecting tests
struct unsigned_tag {};
struct signed_tag {};
// Tests for unsigned numbers. The extra default Number parameter works around
// an MSVC bug.
template <class Number>
void test_aux(unsigned_tag, Number*)
{
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
BOOST_STATIC_ASSERT(!boost::is_signed<Number>::value);
BOOST_STATIC_ASSERT(
(sizeof(Number) < sizeof(boost::intmax_t))
| (boost::is_same<difference_type, boost::intmax_t>::value));
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
// GCC 4.0.2 ICEs on this C-style cases
BOOST_STATIC_ASSERT((complement_traits<Number>::max) > Number(0));
BOOST_STATIC_ASSERT((complement_traits<Number>::min) == Number(0));
#else
// Force casting to Number here to work around the fact that it's an enum on MSVC
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::max) > Number(0));
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::min) == Number(0));
#endif
const Number max = complement_traits<Number>::max;
const Number min = complement_traits<Number>::min;
const Number test_max = (sizeof(Number) < sizeof(boost::intmax_t))
? max
: max / 2 - 1;
std::cout << std::hex << "(unsigned) min = " << stream_number(min) << ", max = "
<< stream_number(max) << "..." << std::flush;
std::cout << "difference_type = " << typeid(difference_type).name() << "..."
<< std::flush;
difference_type d1 = boost::detail::numeric_distance(Number(0), test_max);
difference_type d2 = boost::detail::numeric_distance(test_max, Number(0));
std::cout << "0->" << stream_number(test_max) << "==" << std::dec << stream_number(d1) << "; "
<< std::hex << stream_number(test_max) << "->0==" << std::dec << stream_number(d2) << "..." << std::flush;
assert(d1 == difference_type(test_max));
assert(d2 == -difference_type(test_max));
}
// Tests for signed numbers. The extra default Number parameter works around an
// MSVC bug.
struct out_of_range_tag {};
struct in_range_tag {};
// This test morsel gets executed for numbers whose difference will always be
// representable in intmax_t
template <class Number>
void signed_test(in_range_tag, Number*)
{
BOOST_STATIC_ASSERT(boost::is_signed<Number>::value);
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
const Number max = complement_traits<Number>::max;
const Number min = complement_traits<Number>::min;
difference_type d1 = boost::detail::numeric_distance(min, max);
difference_type d2 = boost::detail::numeric_distance(max, min);
std::cout << stream_number(min) << "->" << stream_number(max) << "==";
std::cout << std::dec << stream_number(d1) << "; ";
std::cout << std::hex << stream_number(max) << "->" << stream_number(min)
<< "==" << std::dec << stream_number(d2) << "..." << std::flush;
assert(d1 == difference_type(max) - difference_type(min));
assert(d2 == difference_type(min) - difference_type(max));
}
// This test morsel gets executed for numbers whose difference may exceed the
// capacity of intmax_t.
template <class Number>
void signed_test(out_of_range_tag, Number*)
{
BOOST_STATIC_ASSERT(boost::is_signed<Number>::value);
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
const Number max = complement_traits<Number>::max;
const Number min = complement_traits<Number>::min;
difference_type min_distance = complement_traits<difference_type>::min;
difference_type max_distance = complement_traits<difference_type>::max;
const Number n1 = Number(min + max_distance);
const Number n2 = Number(max + min_distance);
difference_type d1 = boost::detail::numeric_distance(min, n1);
difference_type d2 = boost::detail::numeric_distance(max, n2);
std::cout << stream_number(min) << "->" << stream_number(n1) << "==";
std::cout << std::dec << stream_number(d1) << "; ";
std::cout << std::hex << stream_number(max) << "->" << stream_number(n2)
<< "==" << std::dec << stream_number(d2) << "..." << std::flush;
assert(d1 == max_distance);
assert(d2 == min_distance);
}
template <class Number>
void test_aux(signed_tag, Number*)
{
typedef typename boost::detail::numeric_traits<Number>::difference_type difference_type;
BOOST_STATIC_ASSERT(boost::is_signed<Number>::value);
BOOST_STATIC_ASSERT(
(sizeof(Number) < sizeof(boost::intmax_t))
| (boost::is_same<difference_type, Number>::value));
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
// GCC 4.0.2 ICEs on this cast
BOOST_STATIC_ASSERT((complement_traits<Number>::max) > Number(0));
BOOST_STATIC_ASSERT((complement_traits<Number>::min) < Number(0));
#else
// Force casting to Number here to work around the fact that it's an enum on MSVC
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::max) > Number(0));
BOOST_STATIC_ASSERT(Number(complement_traits<Number>::min) < Number(0));
#endif
const Number max = complement_traits<Number>::max;
const Number min = complement_traits<Number>::min;
std::cout << std::hex << "min = " << stream_number(min) << ", max = "
<< stream_number(max) << "..." << std::flush;
std::cout << "difference_type = " << typeid(difference_type).name() << "..."
<< std::flush;
typedef typename boost::conditional<
(sizeof(Number) < sizeof(boost::intmax_t)),
in_range_tag,
out_of_range_tag
>::type range_tag;
signed_test<Number>(range_tag(), 0);
}
// Test for all numbers. The extra default Number parameter works around an MSVC
// bug.
template <class Number>
void test(Number* = 0)
{
std::cout << "testing " << typeid(Number).name() << ":\n"
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
<< "is_signed: " << (std::numeric_limits<Number>::is_signed ? "true\n" : "false\n")
<< "is_bounded: " << (std::numeric_limits<Number>::is_bounded ? "true\n" : "false\n")
<< "digits: " << std::numeric_limits<Number>::digits << "\n"
#endif
<< "..." << std::flush;
// factoring out difference_type for the assert below confused Borland :(
typedef boost::is_signed<
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
typename
#endif
boost::detail::numeric_traits<Number>::difference_type
> is_signed;
BOOST_STATIC_ASSERT(is_signed::value);
typedef typename boost::conditional<
boost::is_signed<Number>::value,
signed_tag,
unsigned_tag
>::type signedness;
test_aux<Number>(signedness(), 0);
std::cout << "passed" << std::endl;
}
int main()
{
test<char>();
test<unsigned char>();
test<signed char>();
test<wchar_t>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
#if defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_INTEGRAL_INT64_T)
test< ::boost::long_long_type>();
test< ::boost::ulong_long_type>();
#elif defined(BOOST_MSVC)
// The problem of not having compile-time static class constants other than
// enums prevents this from working, since values get truncated.
// test<boost::uintmax_t>();
// test<boost::intmax_t>();
#endif
return 0;
}

View File

@ -0,0 +1,16 @@
// Copyright 2018 Daniel James.
// 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/detail/reference_content.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
BOOST_STATIC_ASSERT((boost::is_same<int, boost::detail::make_reference_content<int>::type>::value));
BOOST_STATIC_ASSERT((boost::is_same<boost::detail::reference_content<int&>, boost::detail::make_reference_content<int&>::type>::value));
BOOST_STATIC_ASSERT((boost::is_same<int, boost::detail::make_reference_content<>::apply<int>::type>::value));
BOOST_STATIC_ASSERT((boost::is_same<boost::detail::reference_content<int&>, boost::detail::make_reference_content<>::apply<int&>::type>::value));
BOOST_STATIC_ASSERT((boost::has_nothrow_copy<boost::detail::make_reference_content<int&>::type>::value));
int main() {}

View File

@ -17,6 +17,11 @@
#include <cstddef> // size_t
#include <cwchar>
#include <boost/config.hpp>
#include <boost/core/no_exceptions_support.hpp>
#if !defined(BOOST_NO_EXCEPTIONS)
#include <exception>
#endif
#define BOOST_UTF8_BEGIN_NAMESPACE namespace boost { namespace detail {
#define BOOST_UTF8_END_NAMESPACE } }
@ -46,6 +51,9 @@ namespace std{
#include <boost/core/lightweight_test.hpp>
// Directory of the test executable
std::string executable_dir;
template<std::size_t s>
struct test_data
{
@ -133,7 +141,7 @@ test_main(int /* argc */, char * /* argv */[]) {
// Send our test UTF-8 data to file
{
std::ofstream ofs;
ofs.open("test.dat");
ofs.open((executable_dir + "test.dat").c_str());
std::copy(
td::utf8_encoding,
td::utf8_encoding + sizeof(td::utf8_encoding) / sizeof(unsigned char),
@ -146,7 +154,7 @@ test_main(int /* argc */, char * /* argv */[]) {
{
std::wifstream ifs;
ifs.imbue(utf8_locale);
ifs.open("test.dat");
ifs.open((executable_dir + "test.dat").c_str());
std::wint_t item = 0;
// note can't use normal vector from iterator constructor because
@ -168,7 +176,7 @@ test_main(int /* argc */, char * /* argv */[]) {
{
std::wofstream ofs;
ofs.imbue(utf8_locale);
ofs.open("test2.dat");
ofs.open((executable_dir + "test2.dat").c_str());
std::copy(
from_file.begin(),
from_file.end(),
@ -181,21 +189,21 @@ test_main(int /* argc */, char * /* argv */[]) {
typedef std::istream_iterator<utf8_t> is_iter;
is_iter end_iter;
std::ifstream ifs1("test.dat");
std::ifstream ifs1((executable_dir + "test.dat").c_str());
is_iter it1(ifs1);
std::vector<utf8_t> data1;
std::copy(it1, end_iter, std::back_inserter(data1));
std::ifstream ifs2("test2.dat");
std::ifstream ifs2((executable_dir + "test2.dat").c_str());
is_iter it2(ifs2);
std::vector<utf8_t> data2;
std::copy(it2, end_iter, std::back_inserter(data2));
BOOST_TEST(data1 == data2);
BOOST_TEST_ALL_EQ(data1.begin(), data1.end(), data2.begin(), data2.end());
}
// some libraries have trouble that only shows up with longer strings
const wchar_t * test3_data = L"\
<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<!DOCTYPE boost_serialization>\
@ -223,13 +231,13 @@ test_main(int /* argc */, char * /* argv */[]) {
</a>\
</boost_serialization>\
";
// Send the UCS4_data back out, converting to UTF-8
std::size_t l = std::wcslen(test3_data);
{
std::wofstream ofs;
ofs.imbue(utf8_locale);
ofs.open("test3.dat");
ofs.open((executable_dir + "test3.dat").c_str());
std::copy(
test3_data,
test3_data + l,
@ -241,7 +249,7 @@ test_main(int /* argc */, char * /* argv */[]) {
{
std::wifstream ifs;
ifs.imbue(utf8_locale);
ifs.open("test3.dat");
ifs.open((executable_dir + "test3.dat").c_str());
ifs >> std::noskipws;
BOOST_TEST(
std::equal(
@ -261,29 +269,48 @@ test_main(int /* argc */, char * /* argv */[]) {
BOOST_TEST_EQ(utf8_len, res);
}
// Test that length calculation detects character boundaries
{
std::codecvt<wchar_t, char, std::mbstate_t> const& fac = std::use_facet< std::codecvt<wchar_t, char, std::mbstate_t> >(utf8_locale);
std::mbstate_t mbs = std::mbstate_t();
// The first 5 bytes of utf8_encoding contain 3 complete UTF-8 characters (taking 4 bytes in total) and 1 byte of an incomplete character.
// This last byte should not be accounted by length().
const int input_len = 5;
const int utf8_len = 4;
int res = fac.length(mbs, reinterpret_cast< const char* >(td::utf8_encoding), reinterpret_cast< const char* >(td::utf8_encoding + input_len), ~static_cast< std::size_t >(0u));
BOOST_TEST_EQ(utf8_len, res);
}
return EXIT_SUCCESS;
}
int
main(int argc, char * argv[]){
main(int argc, char * argv[]) {
if (argc > 0) {
// We need to save the path to executable to create test files in the same directory.
// This allows running different configurations of the test (release/debug, different C++ versions, etc.) in parallel.
std::string exec_name = argv[0];
std::string::size_type last_dir_sep_pos = exec_name.find_last_of("/\\");
if (last_dir_sep_pos != std::string::npos)
executable_dir = exec_name.substr(0, last_dir_sep_pos + 1); // include the trailing directory separator
}
int retval = 1;
BOOST_TRY{
retval = test_main(argc, argv);
}
#ifndef BOOST_NO_EXCEPTION_STD_NAMESPACE
BOOST_CATCH(const std::exception & e){
BOOST_ERROR(e.what());
}
#endif
#ifndef BOOST_NO_EXCEPTION_STD_NAMESPACE
BOOST_CATCH(const std::exception & e){
BOOST_ERROR(e.what());
}
#endif
BOOST_CATCH(...){
BOOST_ERROR("failed with uncaught exception:");
}
BOOST_CATCH_END
int error_count = boost::report_errors();
if(error_count > 0)
if (error_count > 0)
retval = error_count;
return retval;
}