Compare commits

...

37 Commits

Author SHA1 Message Date
7a53b7ff20 Move include to target. 2025-05-02 19:21:11 +03:00
24d62635a3 Put back whitespace. 2025-05-02 19:21:11 +03:00
a8f671ea1e Attempt to fix GHA. 2025-05-02 19:21:11 +03:00
d677c9436c Update build deps. 2025-05-02 19:21:11 +03:00
a3cc7bcf95 Move inter-lib dependencies to a project variable and into the build targets. 2025-05-02 19:21:11 +03:00
70578731e7 Update copyright dates. 2025-05-02 19:21:11 +03:00
3fb22ed769 Bump B2 require to 5.2 2025-05-02 19:21:11 +03:00
32824bfa1d Add requires-b2 check to top-level build file. 2025-05-02 19:21:11 +03:00
f15a4d0586 Add missing import-search for cconfig/predef checks. 2025-05-02 19:21:11 +03:00
cd5bc51e9e Replace relative docca refs with project based. 2025-05-02 19:21:11 +03:00
77d6a43dce Switch to library requirements instead of source. As source puts extra source in install targets. 2025-05-02 19:21:11 +03:00
8f969a62f7 Make the library modular usable. 2025-05-02 19:21:11 +03:00
bff5cb65a5 Boost super-project tests target
fix #53
2024-02-20 13:53:27 -03:00
42bb99ed25 support platforms without wchar_t
closes #51
2023-10-24 14:22:30 -04:00
175f467a03 select hash implementation with macros based on word size
fixes #46
2023-05-29 11:30:18 -04:00
6275cd7fe3 disable string_view overloads when type is convertible to basic_static_string
fixes #47
2023-05-29 10:51:06 -04:00
ac84c4f40e string_view interoperability
fix #26
2023-01-19 19:57:32 -03:00
269987446e check for char8_t directly
fix #40
2023-01-18 22:10:36 -03:00
82ff4e0679 static_string<0> does not memcpy
fix #41
2023-01-18 22:09:45 -03:00
9c3d5febe7 tests include main header 2023-01-18 22:09:31 -03:00
0c914ff05b fix noexcept-type warning 2022-11-04 10:34:09 -07:00
bfce6eea90 fix unused-function warning 2022-11-03 22:48:35 -07:00
ffce33d483 fix array-bounds warning 2022-11-03 14:12:02 -07:00
c4f6491537 fix restrict warning 2022-11-02 15:46:33 -07:00
25579e482f update jamfile
fix #24
2022-11-01 14:11:31 -07:00
3e9489a7af update CMakeLists.txt
fix #4
2022-11-01 13:39:05 -07:00
7822f1b991 update CI
fix #31, fix #20
2022-10-31 16:09:33 -07:00
5d6fefdd2a Protect against MSVC min and max macros 2022-04-16 11:49:23 -04:00
f92940bfab Use Docca jam module 2021-10-25 07:37:10 -04:00
c5df271a1a Remove trailing spaces 2021-10-25 07:27:47 -04:00
6978da552e Do not include test/CMakeLists.txt 2021-06-02 06:01:04 +03:00
e6895ea26b Update CMakeLists.txt 2021-06-02 04:51:10 +03:00
d157311620 Replace sed-based customization with XSLT import
fix boostorg/docca#40
2021-02-25 12:54:48 -08:00
3a1efd2078 Implement erase_if function and related tests 2021-01-18 15:59:20 -05:00
59c4c556bb Library meta specifies minimum C++ standard 2020-12-17 13:18:57 -05:00
c59150c042 Update doc config.xsl 2020-11-19 19:09:55 -08:00
d524755ec0 Remove cv-qualifiers from character type deduced by deduction guide 2020-06-08 15:33:10 -04:00
26 changed files with 2544 additions and 1741 deletions

View File

@ -1,5 +1,6 @@
# Copyright 2016, 2017 Peter Dimov # Copyright 2016, 2017 Peter Dimov
# Copyright (C) 2017 - 2019 James E. King III # Copyright 2017 - 2019 James E. King III
# Copyright 2019 - 2021 Alexander Grund
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -21,7 +22,7 @@
version: 1.0.{build}-{branch} version: 1.0.{build}-{branch}
shallow_clone: true shallow_clone: false
branches: branches:
only: only:
@ -33,115 +34,101 @@ branches:
- /pr\/.*/ - /pr\/.*/
matrix: matrix:
fast_finish: false
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green: # Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
allow_failures: allow_failures:
- MAYFAIL: true - MAYFAIL: true
environment: environment:
global: global:
B2_CI_VERSION: 1
GIT_FETCH_JOBS: 4
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties # see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however: # to use the default for a given environment, comment it out; recommend you build debug and release however:
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most # on Windows it is important to exercise all the possibilities, especially shared vs static, however most
# libraries that care about this exercise it in their Jamfiles... # libraries that care about this exercise it in their Jamfiles...
# B2_ADDRESS_MODEL: address-model=64,32 B2_ADDRESS_MODEL: 32,64
# B2_LINK: link=shared,static B2_LINK: shared,static
# B2_THREADING: threading=multi,single # B2_THREADING: threading=multi,single
B2_VARIANT: variant=release B2_VARIANT: release
matrix: matrix:
- FLAVOR: Visual Studio 2022
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
B2_CXXFLAGS: -permissive-
B2_CXXSTD: 14,17,20
B2_TOOLSET: msvc-14.3
- FLAVOR: Visual Studio 2019 - FLAVOR: Visual Studio 2019
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
B2_ADDRESS_MODEL: address-model=64 B2_CXXFLAGS: -permissive-
B2_CXXFLAGS: cxxflags=-permissive- B2_CXXSTD: 14,17,2a
B2_CXXSTD: 17 # 2a
B2_TOOLSET: msvc-14.2 B2_TOOLSET: msvc-14.2
- FLAVOR: Visual Studio 2017 C++2a Strict - FLAVOR: Visual Studio 2017 C++2a Strict
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64 B2_CXXFLAGS: -permissive-
B2_CXXFLAGS: cxxflags=-permissive- B2_CXXSTD: 2a
B2_CXXSTD: 17 # 2a
B2_TOOLSET: msvc-14.1 B2_TOOLSET: msvc-14.1
- FLAVOR: Visual Studio 2017 C++17 - FLAVOR: Visual Studio 2017 C++14/17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64 B2_CXXSTD: 14,17
B2_CXXSTD: 17
B2_TOOLSET: msvc-14.1
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2017 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64,32
B2_TOOLSET: msvc-14.1 B2_TOOLSET: msvc-14.1
- FLAVOR: clang-cl - FLAVOR: clang-cl
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
B2_ADDRESS_MODEL: address-model=64 ADDCOMMANDS: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"'
B2_CXXSTD: 11 B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,14,17
B2_TOOLSET: clang-win B2_TOOLSET: clang-win
- FLAVOR: Visual Studio 2015 C++14 (Default) # not supported
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 # - FLAVOR: Visual Studio 2015, 2013
B2_ADDRESS_MODEL: address-model=64,32 # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-14.0 # B2_TOOLSET: msvc-12.0,msvc-14.0
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2010, 2012, 2013 # - FLAVOR: Visual Studio 2008, 2010, 2012
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0 # B2_TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
# B2_ADDRESS_MODEL: 32 # No 64bit support
- FLAVOR: cygwin (32-bit) - FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin; ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: address-model=32 B2_ADDRESS_MODEL: 32
B2_CXXSTD: 03,11 B2_CXXSTD: 11,14,1z
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc B2_TOOLSET: gcc
B2_VARIANT: variant=debug
- FLAVOR: cygwin (64-bit) - FLAVOR: cygwin (64-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin64\bin; ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: address-model=64 B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,17 B2_CXXSTD: 11,14,1z
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc B2_TOOLSET: gcc
- FLAVOR: mingw32 - FLAVOR: mingw32
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ARCH: i686 B2_ADDRESS_MODEL: 32
B2_ADDRESS_MODEL: address-model=32 ADDPATH: C:\mingw\bin;
B2_CXXSTD: 03,11 B2_CXXSTD: 11,14,17,2a
SCRIPT: ci\appveyor\mingw.bat B2_TOOLSET: gcc
B2_VARIANT: variant=debug
- FLAVOR: mingw64 - FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ARCH: x86_64 ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
B2_ADDRESS_MODEL: address-model=64 B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,17 B2_CXXSTD: 11,14,17,2a
B2_DEFINES: define=__USE_ISOC99 B2_TOOLSET: gcc
SCRIPT: ci\appveyor\mingw.bat
install: install:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_% - '%ADDCOMMANDS%'
- git clone https://github.com/boostorg/boost-ci.git C:\boost-ci - git clone --depth 1 https://github.com/boostorg/boost-ci.git C:\boost-ci-cloned
- xcopy /s /e /q /i C:\boost-ci\ci .\ci # Copy ci folder if not testing Boost.CI
- if NOT "%APPVEYOR_PROJECT_NAME%" == "boost-ci" xcopy /s /e /q /i /y C:\boost-ci-cloned\ci .\ci
- rmdir /s /q C:\boost-ci-cloned
- ci\appveyor\install.bat - ci\appveyor\install.bat
build: off build: off
test_script: test_script: ci\build.bat
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- PATH=%ADDPATH%%PATH%
# The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
- IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
# Echo the complete build command to the build log
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
# Now go build...
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)

View File

@ -1,276 +0,0 @@
# Copyright 2015-2019 Rene Rivera.
# Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
# 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)
#
# Generic Azure Pipelines build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci/
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have more than include/, src/, test/, example/, examples/,
# benchmark/ or tools/ directories, set the environment variable DEPINST.
# For example if your build uses code in "bench/" and "fog/" directories:
# - DEPINST: --include bench --include fog
# 3. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the script will do everything else for you.
trigger:
branches:
include:
- develop
- master
- bugfix/*
- feature/*
- fix/*
- pr/*
pr:
branches:
include:
- develop
variables:
- name: B2_VARIANT
value: variant=release,debug
stages:
- stage: Test
jobs:
- job: 'Linux'
pool:
vmImage: 'ubuntu-16.04'
strategy:
matrix:
GCC 8:
B2_TOOLSET: gcc
B2_CXXSTD: 14,17
CXX: g++-8
PACKAGES: g++-8
GCC 7:
B2_TOOLSET: gcc
B2_CXXSTD: 11,14,17
CXX: g++-7
PACKAGES: g++-7
GCC 6:
B2_TOOLSET: gcc
B2_CXXSTD: 11,14
CXX: g++-6
PACKAGES: g++-6
GCC 5:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-5
PACKAGES: g++-5
GCC 4.9:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-4.9
PACKAGES: g++-4.9
GCC 4.8:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-4.8
PACKAGES: g++-4.8
Clang 8:
B2_TOOLSET: clang
B2_CXXSTD: 14,17
CXX: clang++-8
PACKAGES: clang-8
LLVM_REPO: llvm-toolchain-xenial-8
Clang 7:
B2_TOOLSET: clang
B2_CXXSTD: 14,17
CXX: clang++-7
PACKAGES: clang-7
LLVM_REPO: llvm-toolchain-xenial-7
Clang 6:
B2_TOOLSET: clang
B2_CXXSTD: 14,17
CXX: clang++-6.0
PACKAGES: clang-6.0
LLVM_REPO: llvm-toolchain-xenial-6.0
Clang 5:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
PACKAGES: clang-5.0
CXX: clang++-5.0
LLVM_REPO: llvm-toolchain-xenial-5.0
Clang 4:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
CXX: clang++-4.0
PACKAGES: clang-4.0
LLVM_REPO: llvm-toolchain-xenial-4.0
Clang 3.9:
B2_TOOLSET: clang
B2_CXXSTD: 11,14
CXX: clang++-3.9
PACKAGES: clang-3.9
Clang 3.8:
B2_TOOLSET: clang
CXX: clang++-3.8
B2_CXXSTD: 11,14
PACKAGES: clang-3.8
Clang 3.7:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.7
PACKAGES: clang-3.7
Clang 3.6:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.6
PACKAGES: clang-3.6
Clang 3.5:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.5
PACKAGES: clang-3.5
steps:
- bash: |
set -e
uname -a
sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
if test -n "${LLVM_REPO}" ; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo -E apt-add-repository "deb http://apt.llvm.org/xenial/ ${LLVM_REPO} main"
fi
sudo -E apt-get update
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install ${PACKAGES}
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
rm -rf boost-ci
source ci/azure-pipelines/install.sh
# AzP requires to run special task in order to export
# SELF and BOOST_ROOT as job-scoped variable from a script.
# NOTE: Disable set -x is necessary, see the troubleshooting guide
# on "Variables having ' (single quote) appended":
# https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting
set +x
echo "##vso[task.setvariable variable=SELF]"$SELF
echo "##vso[task.setvariable variable=BOOST_ROOT]"$BOOST_ROOT
set -x
displayName: 'Install'
- bash: |
set -e
echo "SELF=$SELF"
echo "BOOST_ROOT=$BOOST_ROOT"
cd $BOOST_ROOT/libs/$SELF
ci/azure-pipelines/build.sh --debug-configuration
displayName: 'Build'
- job: 'Windows'
strategy:
matrix:
VS 2019 C++17 Strict:
B2_TOOLSET: msvc-14.2
B2_CXXSTD: 17
B2_CXXFLAGS: cxxflags=-permissive-
B2_ADDRESS_MODEL: address-model=64
VM_IMAGE: 'windows-2019'
VS 2017 C++17 Strict:
B2_TOOLSET: msvc-14.1
B2_CXXSTD: 17
B2_CXXFLAGS: cxxflags=-permissive-
B2_ADDRESS_MODEL: address-model=64
VM_IMAGE: 'vs2017-win2016'
VS 2017 C++17:
B2_TOOLSET: msvc-14.1
B2_CXXSTD: 17
B2_ADDRESS_MODEL: address-model=64,32
VM_IMAGE: 'vs2017-win2016'
VS 2017 C++14:
B2_TOOLSET: msvc-14.1
#B2_CXXSTD: 14 # default
B2_ADDRESS_MODEL: address-model=64,32
VM_IMAGE: 'vs2017-win2016'
pool:
vmImage: $(VM_IMAGE)
steps:
- script: |
set SELF=%BUILD_REPOSITORY_NAME:-=_%
for /f "tokens=2 delims=/" %%a in ("%SELF%") do set SELF=%%a
set BOOST_ROOT=%BUILD_SOURCESDIRECTORY%\boost-root
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
xcopy /s /e /q /i boost-ci\ci .\ci
cmd /k ci\azure-pipelines\install.bat
echo ##vso[task.setvariable variable=SELF]%SELF%
echo ##vso[task.setvariable variable=BOOST_ROOT]%BOOST_ROOT%
displayName: 'Install'
- script: |
PATH=%ADDPATH%%PATH%
REM The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
cd %BOOST_ROOT%
ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
displayName: 'Build'
- job: 'macOS'
pool:
vmImage: 'macOS-10.14'
strategy:
matrix:
Xcode_11_3_1:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.3.1.app
Xcode_11_2_1:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.2.1.app
Xcode_11_2:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.2.app
Xcode_11_1:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.1.app
Xcode_10_3:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.3.app
Xcode_10_2_1:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.2.1.app
Xcode_10_2:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.2.app
Xcode_10_1:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.1.app
Xcode_10_0:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.app
steps:
- bash: |
set -e
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci-cloned
cp -prf boost-ci-cloned/ci .
rm -rf boost-ci-cloned
source ci/azure-pipelines/install.sh
displayName: Install
- bash: |
set -e
echo "SELF=$SELF"
echo "BOOST_ROOT=$BOOST_ROOT"
cd $BOOST_ROOT/libs/$SELF
ci/azure-pipelines/build.sh
displayName: 'Build'

25
.codecov.yml Normal file
View File

@ -0,0 +1,25 @@
# Copyright 2019 - 2021 Alexander Grund
# 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)
#
# Sample codecov configuration file. Edit as required
codecov:
max_report_age: off
require_ci_to_pass: yes
notify:
# Increase this if you have multiple coverage collection jobs
after_n_builds: 1
wait_for_ci: yes
# Change how pull request comments look
comment:
layout: "reach,diff,flags,files,footer"
# Ignore specific files or folders. Glob patterns are supported.
# See https://docs.codecov.com/docs/ignoring-paths
ignore:
- extra/*
- extra/**/*
- test/*
- test/**/*

117
.drone.star Normal file
View File

@ -0,0 +1,117 @@
# Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE.txt)
#
# Copyright Rene Rivera 2020.
# Copyright Alan de Freitas 2022.
# For Drone CI we use the Starlark scripting language to reduce duplication.
# As the yaml syntax for Drone CI is rather limited.
#
#
globalenv={'B2_CI_VERSION': '1', 'B2_VARIANT': 'release'}
linuxglobalimage="cppalliance/droneubuntu1804:1"
windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):
return [
# Priorities: (no 2a, no betas)
#
# coverage
# latest gcc: 17,20
# latest clang: 17,20
# oldest gcc: 11
# oldest clang: 11
# asan
# tsan
# ubsan
# valgrind
# arm64
# s390x
# docs
# cmake superproject
# cmake install
# (...the rest)
# Coverage
linux_cxx("Coverage", "g++-8", packages="g++-8", buildscript="drone", buildtype="codecov", image=linuxglobalimage, environment={'COMMENT': 'codecov.io', 'LCOV_BRANCH_COVERAGE': '0', 'B2_CXXSTD': '11', 'B2_TOOLSET': 'gcc-8', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', "CODECOV_TOKEN": {"from_secret": "codecov_token"}, "COVERALLS_REPO_TOKEN": {"from_secret": "coveralls_repo_token"}}, globalenv=globalenv),
# Latest gcc
linux_cxx("GCC 12: C++17,20", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'gcc-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("GCC 12: C++17,20 Standalone", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'gcc-12', 'B2_CXXFLAGS': '-Werror', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# Latest clang
linux_cxx("Clang 15: C++17,20", "clang++-15", packages="clang-15 libstdc++-10-dev", llvm_os="jammy", llvm_ver="15", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-15', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("Clang 15: C++17,20 Standalone", "clang++-15", packages="clang-15 libstdc++-10-dev", llvm_os="jammy", llvm_ver="15", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-15', 'B2_CXXFLAGS': '-Werror', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# Oldest compilers
linux_cxx("GCC 4.8: C++11", "g++-4.8", packages="g++-4.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_TOOLSET': 'gcc-4.8', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("GCC 4.8: C++11 Standalone", "g++-4.8", packages="g++-4.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_TOOLSET': 'gcc-4.8', 'B2_CXXFLAGS': '-Werror', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("Clang 3.8: C++11", "clang++-3.8", packages="clang-3.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_VARIANT': 'debug', 'B2_CXXFLAGS': '-Werror', 'B2_TOOLSET': 'clang-3.8', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("Clang 3.8: C++11 Standalone", "clang++-3.8", packages="clang-3.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_VARIANT': 'debug', 'B2_CXXFLAGS': '-Werror', 'B2_TOOLSET': 'clang-3.8', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '11'}, globalenv=globalenv),
# Sanitizers + Valgrind
linux_cxx("ASan", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'asan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-12', 'B2_CXXSTD': '11,14,17', 'B2_ASAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'DRONE_EXTRA_PRIVILEGED': 'True'}, globalenv=globalenv, privileged=True),
linux_cxx("TSan", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'tsan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-12', 'B2_CXXSTD': '11,14,17', 'B2_TSAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1'}, globalenv=globalenv),
linux_cxx("UBSan", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'ubsan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-12', 'B2_CXXSTD': '11,14,17', 'B2_UBSAN': '1', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'B2_LINKFLAGS': '-fuse-ld=gold'}, globalenv=globalenv),
linux_cxx("Valgrind", "clang++-14", packages="clang-14 libc6-dbg libc++-dev libstdc++-9-dev", llvm_os="jammy", llvm_ver="14", buildscript="drone", buildtype="valgrind", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'valgrind', 'B2_TOOLSET': 'clang-14', 'B2_CXXSTD': '11,14,17', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'B2_VARIANT': 'debug', 'B2_TESTFLAGS': 'testing.launcher=valgrind', 'VALGRIND_OPTS': '--error-exitcode=1'}, globalenv=globalenv),
# arm64 (unsigned char)
linux_cxx("ARM64: GCC 11", "g++-11", packages="g++-11", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, arch="arm64", globalenv=globalenv),
# s390x
linux_cxx("S390x: Clang 12", "clang++-12", packages="clang-12 libstdc++-9-dev", llvm_os="focal", llvm_ver="12", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'clang-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, arch="s390x", globalenv=globalenv),
# Documentation
# linux_cxx("Docs", "g++", packages="docbook docbook-xml docbook-xsl xsltproc libsaxonhe-java default-jre-headless flex libfl-dev bison unzip rsync", buildtype="docs", buildscript="drone", image="cppalliance/droneubuntu1804:1", environment={'COMMENT': 'docs'}, globalenv=globalenv),
# CMake tests (https://github.com/boostorg/boost-ci)
## Compiling as part of the boost superproject
linux_cxx("CMake Superproject", "g++", packages="", buildscript="drone", buildtype="cmake-superproject", image="cppalliance/droneubuntu1804:1", globalenv=globalenv),
## Installing
# linux_cxx("CMake Install", "g++", packages="", buildscript="drone", buildtype="cmake1", image="cppalliance/droneubuntu1804:1", environment={'CMAKE_INSTALL_TEST': '1'}, globalenv=globalenv),
# ------------------------------------------------------------------
# OSX
osx_cxx("OSX: Clang", "g++", packages="", buildscript="drone", buildtype="boost", xcode_version="13.4.1", environment={'B2_TOOLSET': 'clang', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,17'}, globalenv=globalenv),
# GCC (All other versions)
linux_cxx("GCC 4.9: C++11", "g++-4.9", packages="g++-4.9", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_TOOLSET': 'gcc-4.9', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("GCC 5: C++11", "g++-5", packages="g++-5", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-5', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("GCC 6: C++11,14", "g++-6", packages="g++-6", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-6', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,14'}, globalenv=globalenv),
linux_cxx("GCC 7: C++14,17", "g++-7", packages="g++-7", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-7', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("GCC 8: C++17", "g++-8", packages="g++-8", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-8', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("GCC 9: C++17", "g++-9", packages="g++-9", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-9', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("GCC 10: C++17", "g++-10", packages="g++-10", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-10', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("GCC 11: C++17,20", "g++-11", packages="g++-11", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# Clang (All other versions)
linux_cxx("Clang 4.0: C++11,14", "clang++-4.0", packages="clang-4.0 libstdc++-6-dev", llvm_os="xenial", llvm_ver="4.0", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'B2_TOOLSET': 'clang-4.0', 'B2_CXXFLAGS': '', 'B2_CXXSTD': '11,14'}, globalenv=globalenv),
linux_cxx("Clang 5.0: C++11,14", "clang++-5.0", packages="clang-5.0 libstdc++-7-dev", llvm_os="bionic", llvm_ver="5.0", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-5.0', 'B2_CXXFLAGS': '', 'B2_CXXSTD': '11,14'}, globalenv=globalenv),
linux_cxx("Clang 6.0: C++11,14", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libc++abi-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="6.0", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,14', 'B2_STDLIB': 'libc++'}, globalenv=globalenv),
linux_cxx("Clang 6.0: C++14,17", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libc++abi-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="6.0", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 7: C++17", "clang++-7", packages="clang-7 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="7", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-7', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("Clang 8: C++17", "clang++-8", packages="clang-8 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="8", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-8', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("Clang 9: C++14,17", "clang++-9", packages="clang-9 libstdc++-9-dev", llvm_os="bionic", llvm_ver="9", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-9', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 10: C++14,17", "clang++-10", packages="clang-10 libstdc++-9-dev", llvm_os="focal", llvm_ver="10", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:1", environment={'B2_TOOLSET': 'clang-10', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 11: C++14,17", "clang++-11", packages="clang-11 libstdc++-9-dev", llvm_os="focal", llvm_ver="11", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:1", environment={'B2_TOOLSET': 'clang-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 12: C++17,20", "clang++-12", packages="clang-12 libstdc++-9-dev", llvm_os="focal", llvm_ver="12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:1", environment={'B2_TOOLSET': 'clang-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("Clang 13: C++17,20", "clang++-13", packages="clang-13 libstdc++-10-dev", llvm_os="jammy", llvm_ver="13", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-13', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("Clang 14: C++17,20", "clang++-14", packages="clang-14 libstdc++-10-dev", llvm_os="jammy", llvm_ver="14", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-14', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# arm64 (unsigned char)
linux_cxx("ARM64: Clang 12", "clang++-12", packages="clang-12 libstdc++-9-dev", llvm_os="focal", llvm_ver="12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'clang-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,14,17,20'}, arch="arm64", globalenv=globalenv),
# s390x
linux_cxx("S390x: GCC 11", "g++-11", packages="g++-11", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, arch="s390x", globalenv=globalenv),
# MSVC
windows_cxx("MSVC 14.1", "", image="cppalliance/dronevs2017", buildtype="boost", buildscript="drone", environment={"B2_TOOLSET": "msvc-14.1", 'B2_CXXFLAGS': '/WX', "B2_CXXSTD": "11,14,17"},globalenv=globalenv),
windows_cxx("MSVC 14.2: C++14,17,latest", "", image="cppalliance/dronevs2019", buildtype="boost", buildscript="drone", environment={"B2_TOOLSET": "msvc-14.2", 'B2_CXXFLAGS': '/WX', "B2_CXXSTD": "14,17,latest"},globalenv=globalenv),
windows_cxx("MSVC 14.3: C++17,20", "", image="cppalliance/dronevs2022", buildtype="boost", buildscript="drone", environment={"B2_TOOLSET": "msvc-14.3", 'B2_CXXFLAGS': '/WX', "B2_CXXSTD": "17,20"},globalenv=globalenv),
]
# from https://github.com/boostorg/boost-ci
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")

31
.drone/drone.bat Normal file
View File

@ -0,0 +1,31 @@
@ECHO ON
setlocal enabledelayedexpansion
if "%DRONE_JOB_BUILDTYPE%" == "boost" (
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1
cp -prf boost-ci-cloned/ci .
rm -rf boost-ci-cloned
REM source ci/travis/install.sh
REM The contents of install.sh below:
for /F %%i in ("%DRONE_REPO%") do @set SELF=%%~nxi
SET BOOST_CI_TARGET_BRANCH=%DRONE_COMMIT_BRANCH%
SET BOOST_CI_SRC_FOLDER=%cd%
call ci\common_install.bat
echo '==================================> COMPILE'
REM set B2_TARGETS=libs/!SELF!/test libs/!SELF!/example
set B2_TARGETS=libs/!SELF!/test
call !BOOST_ROOT!\libs\!SELF!\ci\build.bat
) else if "%DRONE_JOB_BUILDTYPE%" == "standalone-windows" (
REM not used
)

236
.drone/drone.sh Executable file
View File

@ -0,0 +1,236 @@
#!/bin/bash
# Copyright 2020 Rene Rivera, Sam Darwin
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
set -xe
export TRAVIS_BUILD_DIR=$(pwd)
export DRONE_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=$DRONE_BRANCH
export TRAVIS_EVENT_TYPE=$DRONE_BUILD_EVENT
export VCS_COMMIT_ID=$DRONE_COMMIT
export GIT_COMMIT=$DRONE_COMMIT
export REPO_NAME=$DRONE_REPO
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
common_install() {
git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1
cp -prf boost-ci-cloned/ci .
rm -rf boost-ci-cloned
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=$(basename $REPO_NAME)
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
}
if [ "$DRONE_JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
export B2_TARGETS=${B2_TARGETS:-"libs/$SELF/test"}
$BOOST_ROOT/libs/$SELF/ci/travis/build.sh
elif [ "$DRONE_JOB_BUILDTYPE" == "docs" ]; then
echo '==================================> INSTALL'
export SELF=$(basename $REPO_NAME)
pwd
cd ..
mkdir -p $HOME/cache && cd $HOME/cache
if [ ! -d doxygen ]; then git clone -b 'Release_1_8_15' --depth 1 https://github.com/doxygen/doxygen.git && echo "not-cached"; else echo "cached"; fi
cd doxygen
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
cd build
sudo make install
cd ../..
if [ ! -f saxonhe.zip ]; then wget -O saxonhe.zip https://sourceforge.net/projects/saxon/files/Saxon-HE/9.9/SaxonHE9-9-1-4J.zip/download && echo "not-cached"; else echo "cached"; fi
unzip -o saxonhe.zip
sudo rm /usr/share/java/Saxon-HE.jar
sudo cp saxon9he.jar /usr/share/java/Saxon-HE.jar
cd ..
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root --depth 1
cd boost-root
export BOOST_ROOT=$(pwd)
git submodule update --init libs/context
git submodule update --init tools/boostbook
git submodule update --init tools/boostdep
git submodule update --init tools/docca
git submodule update --init tools/quickbook
rsync -av $TRAVIS_BUILD_DIR/ libs/$SELF
python tools/boostdep/depinst/depinst.py ../tools/quickbook
./bootstrap.sh
./b2 headers
echo '==================================> SCRIPT'
echo "using doxygen ; using boostbook ; using saxonhe ;" >tools/build/src/user-config.jam
./b2 -j3 libs/$SELF/doc//boostrelease
elif [ "$DRONE_JOB_BUILDTYPE" == "codecov" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
set +e
cd $BOOST_ROOT/libs/$SELF
ci/travis/codecov.sh
# coveralls
# uses multiple lcov steps from boost-ci codecov.sh script
if [ -n "${COVERALLS_REPO_TOKEN}" ]; then
echo "processing coveralls"
pip3 install --user cpp-coveralls
cd $BOOST_CI_SRC_FOLDER
export PATH=/tmp/lcov/bin:$PATH
command -v lcov
lcov --version
lcov --remove coverage.info -o coverage_filtered.info '*/test/*' '*/extra/*'
cpp-coveralls --verbose -l coverage_filtered.info
fi
elif [ "$DRONE_JOB_BUILDTYPE" == "valgrind" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/valgrind.sh
elif [ "$DRONE_JOB_BUILDTYPE" == "standalone" ]; then
echo '==================================> INSTALL'
# Installing cmake with apt-get, so not required here:
# pip install --user cmake
echo '==================================> SCRIPT'
export CXXFLAGS="-Wall -Wextra -Werror -std=c++17"
mkdir __build_17
cd __build_17
cmake -DBOOST_JSON_STANDALONE=1 ..
cmake --build .
ctest -V .
export CXXFLAGS="-Wall -Wextra -Werror -std=c++2a"
mkdir ../__build_2a
cd ../__build_2a
cmake -DBOOST_JSON_STANDALONE=1 ..
cmake --build .
ctest -V .
elif [ "$DRONE_JOB_BUILDTYPE" == "coverity" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
if [ -n "${COVERITY_SCAN_NOTIFICATION_EMAIL}" -a \( "$TRAVIS_BRANCH" = "develop" -o "$TRAVIS_BRANCH" = "master" \) -a \( "$DRONE_BUILD_EVENT" = "push" -o "$DRONE_BUILD_EVENT" = "cron" \) ]; then
cd $BOOST_ROOT/libs/$SELF
ci/travis/coverity.sh
fi
elif [ "$DRONE_JOB_BUILDTYPE" == "cmake-superproject" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> COMPILE'
# May want to re-enable -Werror
# export CXXFLAGS="-Wall -Wextra -Werror"
export CXXFLAGS="-Wall -Wextra"
mkdir __build_static
cd __build_static
cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 \
-DBOOST_INCLUDE_LIBRARIES=$SELF ..
cmake --build .
ctest --output-on-failure -R boost_$SELF
cd ..
mkdir __build_shared
cd __build_shared
cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 \
-DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=ON ..
cmake --build .
ctest --output-on-failure -R boost_$SELF
elif [ "$DRONE_JOB_BUILDTYPE" == "cmake1" ]; then
echo '==================================> INSTALL'
# https://github.com/opencv/opencv-python#frequently-asked-questions
pip install --upgrade pip
pip install --user cmake
echo '==================================> SCRIPT'
export SELF=$(basename $REPO_NAME)
BOOST_BRANCH=develop && [ "$DRONE_BRANCH" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
# mkdir -p libs/$SELF
# cp -r $DRONE_BUILD_DIR/* libs/$SELF
# git submodule update --init tools/boostdep
git submodule update --init --recursive
mkdir -p libs/$SELF
cp -r $DRONE_BUILD_DIR/* libs/$SELF
# CMake tests
cd libs/$SELF
mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build . --target install
ctest --output-on-failure
# CMake subdir tests
cd ../test/cmake_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
cmake --build . --target check
ctest --output-on-failure
# Install Library
cd ../../../../.. && mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
cmake -DBOOST_INCLUDE_LIBRARIES=$SELF -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBoost_DEBUG=ON ..
cmake --build . --target install
# CMake install tests
cd ../libs/$SELF/test/cmake_test && mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
cmake -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_PREFIX_PATH=~/.local ..
cmake --build .
ctest --output-on-failure
fi

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

@ -0,0 +1,516 @@
# Copyright 2020-2021 Peter Dimov
# Copyright 2021 Andrey Semashev
# Copyright 2022 Alan de Freitas
#
# 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.8
cxxstd: "11"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "11"
os: ubuntu-22.04
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "17"
os: ubuntu-22.04
install:
- g++-9
- toolset: gcc-10
cxxstd: "17"
os: ubuntu-22.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "17,20"
os: ubuntu-22.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
- name: UBSAN
toolset: gcc-11
cxxstd: "17,20"
ubsan: 1
os: ubuntu-22.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
# Linux, clang
- toolset: clang
compiler: clang++-3.8
cxxstd: "11"
os: ubuntu-22.04
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-8
- g++-7
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "14,17"
os: ubuntu-20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "14,17"
os: ubuntu-20.04
install:
- clang-11
# clang 12 tested on drone
# - toolset: clang
# compiler: clang++-12
# cxxstd: "17,20"
# os: ubuntu-22.04
# install:
# - clang-12
# - toolset: clang
# compiler: clang++-12
# cxxstd: "17,20"
# cxxflags: -stdlib=libc++
# linkflags: -stdlib=libc++
# os: ubuntu-20.04
# install:
# - clang-12
# - libc++-12-dev
# - libc++abi-12-dev
# - name: UBSAN
# toolset: clang
# compiler: clang++-12
# cxxstd: "17,20"
# cxxflags: -stdlib=libc++
# linkflags: -stdlib=libc++
# ubsan: 1
# os: ubuntu-20.04
# install:
# - clang-12
# - libc++-12-dev
# - libc++abi-12-dev
- toolset: clang
cxxstd: "11,14,17"
os: macos-11
- name: CMake tests
cmake_tests: 1
os: ubuntu-22.04
timeout-minutes: 120
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
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https make apt-file unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python ruby cpio gcc-multilib g++-multilib pkgconf python3 ccache libpython-dev
# install pip:
python_version=$(python3 -c 'import sys; print("{0.major}.{0.minor}".format(sys.version_info))')
if [[ ${python_version} =~ ^3\.[0-5]$ ]]; then
true
else
apt-get install -y python3-distutils
fi
wget https://bootstrap.pypa.io/pip/$python_version/get-pip.py
python3 get-pip.py
# install git:
# apt-get install -y git
apt-add-repository ppa:git-core/ppa
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update && apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y git
# install cmake:
# apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y cmake
sudo pip3 install cmake
fi
fi
git config --global pack.threads 0
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: |
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
SOURCES=(${{join(matrix.sources, ' ')}})
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
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_HAS_SOURCE_ARGS=0
SOFTWARE_PROPERTIES_VERSION="$(dpkg-query --showformat='${Version}' --show software-properties-common)"
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.96.24.20"
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.98.10"
then
APT_ADD_REPO_HAS_SOURCE_ARGS=1
fi
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")
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 //')"
if $(dpkg --compare-versions "$GIT_VERSION" ge 2.8.0)
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
fi
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
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[@]}"
# - name: Run CMake tests
# if: matrix.cmake_tests != ''
# run: |
# cd ../boost-root
# git submodule update --init --recursive
# cd libs/$LIBRARY
# mkdir __build__ && cd __build__
# cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
# cmake --build . --target install
windows:
strategy:
fail-fast: false
matrix:
include:
#- toolset: msvc-14.1
# cxxstd: "14,17,latest"
# addrmd: 32,64
# os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "17,20"
addrmd: 32,64
os: windows-2022
# - toolset: gcc
# cxxstd: "11,14,17"
# addrmd: 64
# os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
CMake:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-22.04, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' }
- { os: ubuntu-22.04, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' }
- { os: windows-2019, build_shared: ON, build_type: Debug, generator: 'Visual Studio 16 2019' }
- { os: windows-2019, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 16 2019' }
timeout-minutes: 120
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Fetch Boost.CI
uses: actions/checkout@v2
with:
repository: boostorg/boost-ci
ref: master
path: boost-ci-cloned
- name: Get CI scripts folder
run: |
# Copy ci folder if not testing Boost.CI
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
rm -rf boost-ci-cloned
- name: Setup Boost
env: {B2_DONT_BOOTSTRAP: 1}
run: source ci/github/install.sh
# - name: Run CMake tests
# run: |
# cd "$BOOST_ROOT"
# mkdir __build_cmake_test__ && cd __build_cmake_test__
# cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ..
# cmake --build . --target tests boost_url_tests boost_url_limits boost_url_extra --config ${{matrix.build_type}}
# ctest --output-on-failure --build-config ${{matrix.build_type}}
# - name: Run CMake subdir tests
# run: |
# cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
# [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_subdir_test"
# cd "$cmake_test_folder"
# mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__
# cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=OFF -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} ..
# cmake --build . --config ${{matrix.build_type}}
# ctest --output-on-failure --build-config ${{matrix.build_type}}
# - name: Install Library
# run: |
# cd "$BOOST_ROOT"
# mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
# cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBoost_DEBUG=ON ..
# cmake --build . --target install --config ${{matrix.build_type}}
# - name: Run CMake install tests
# run: |
# cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
# [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_install_test"
# cd "$cmake_test_folder"
# mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
# cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_PREFIX_PATH=~/.local ..
# cmake --build . --config ${{matrix.build_type}}
# ctest --output-on-failure --build-config ${{matrix.build_type}}

View File

@ -1,275 +0,0 @@
# Copyright 2016 Peter Dimov
# Copyright 2017 - 2019 James E. King III
# Copyright 2020 Krystian Stasiowski
# 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)
#
# Generic Travis CI build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want in the 'jobs'.
# 2. If you have more than include/, src/, test/, example/, examples/, or
# tools/ directories, modify your Travis CI project and add the environment
# variable DEPINST. For example if your build uses code in "bench/" and
# "fog/" directories, then set DEPINST to the following:
# --include bench --include fog
# 3. If you want to enable Coverity Scan, you need to provide the environment
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
# your github settings.
# 4. If you want to enable a big-endian build, you need to uncomment the
# big-endian build job.
# 5. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the scripts will do everything else for you.
dist: xenial
language: cpp
env:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# - B2_ADDRESS_MODEL=address-model=64,32
# - B2_LINK=link=shared,static
# - B2_THREADING=threading=multi,single
- B2_VARIANT=variant=release
install:
- git clone https://github.com/boostorg/boost-ci.git boost-ci
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
- source ci/travis/install.sh
addons:
apt:
packages:
- binutils-gold
- gdb
- libc6-dbg
- qemu-user-static
services:
- docker
branches:
only:
- master
- develop
- /bugfix\/.*/
- /feature\/.*/
- /fix\/.*/
- /pr\/.*/
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/build.sh
#
# Default toolsets in Ubuntu
#
# trusty xenial bionic
# 14.04 16.04 18.04
# ------ ------ ------
# clang 3.4 3.8 6.0
# gcc 4.8.2 5.3.1 7.3.0
#
anchors:
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-3.8",
"ubuntu-toolchain-r-test" ] } }
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-4.0",
"ubuntu-toolchain-r-test" ] } }
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-xenial-5.0",
"ubuntu-toolchain-r-test" ] } }
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-6.0",
"ubuntu-toolchain-r-test" ] } }
clang-7: &clang-7 { apt: { packages: [ "clang-7",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-7",
"ubuntu-toolchain-r-test" ] } }
clang-8: &clang-8 { apt: { packages: [ "clang-8",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8",
"ubuntu-toolchain-r-test" ] } }
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } }
gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } }
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-9: &gcc-9 { apt: { packages: [ "g++-9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
jobs:
allow_failures:
- env:
- COPY="all the environment settings from your job"
include:
# coverage
- os: linux
env:
- COMMENT=codecov.io
- B2_CXXSTD=11
- B2_TOOLSET=gcc-8
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
script:
- cd $BOOST_ROOT/libs/$SELF
- tools/codecov.sh
- os: linux
env:
- COMMENT=asan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="address-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=tsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="thread-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=ubsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="undefined-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
- B2_LINKFLAGS="linkflags=-fuse-ld=gold"
- UBSAN_OPTIONS=print_stacktrace=1
addons: *gcc-8
- os: linux
env:
- COMMENT=valgrind
- B2_TOOLSET=clang-6.0
- B2_CXXSTD=11,14
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
- B2_VARIANT=variant=debug
- B2_TESTFLAGS=testing.launcher=valgrind
- VALGRIND_OPTS=--error-exitcode=1
addons: *clang-6
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/valgrind.sh
# libstdc++
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.8", "B2_CXXSTD=11" ], addons: *gcc-48 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.9", "B2_CXXSTD=11" ], addons: *gcc-49 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-5", "B2_CXXSTD=11,14" ], addons: *gcc-5 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-6", "B2_CXXSTD=11,14" ], addons: *gcc-6 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-7", "B2_CXXSTD=14,17" ], addons: *gcc-7 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-8", "B2_CXXSTD=17" ], addons: *gcc-8 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-9", "B2_CXXSTD=17" ], addons: *gcc-9 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=clang-3.8", "B2_CXXSTD=11" ], addons: *clang-38 }
- { os: "linux", env: [ "B2_TOOLSET=clang-4.0", "B2_CXXSTD=11,14" ], addons: *clang-4 }
- { os: "linux", env: [ "B2_TOOLSET=clang-5.0", "B2_CXXSTD=11,14" ], addons: *clang-5 }
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 }
- { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17" ], addons: *clang-7 }
- { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17" ], addons: *clang-8 }
- os: "linux"
env: ["B2_TOOLSET=clang-9", "B2_CXXSTD=11,14,17"]
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages:
- clang-9
- libc6-dbg
- libc++-dev
- libstdc++-8-dev
# libc++
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=11,14",
"B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
- { os: "osx" , env: [ "B2_TOOLSET=clang", "B2_CXXSTD=11,17" ] }
# to enable Intel ICC define INTEL_ICC_SERIAL_NUMBER and the following (under development):
# - { os: "linux", env: [ "B2_TOOLSET=intel-linux", "B2_CXXSTD=11,14,17" ], addons: *gcc-7,
# script: cd $BOOST_ROOT/libs/$SELF && ci/travis/intelicc.sh }
# uncomment to enable a big-endian build job, just note that it is 5-10 times slower
# than a regular build and travis has a 50 minute time limit per job
# - os: linux
# env:
# - COMMENT=big-endian
# - B2_CXXSTD=03
# - B2_TOOLSET=gcc
# - B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
# - BDDE_OS=red
# - BDDE_ARCH=ppc64
# script:
# - cd $BOOST_ROOT/libs/$SELF
# - ci/travis/bdde.sh
# - os: linux
# env:
# - COMMENT=cppcheck
# script:
# - cd $BOOST_ROOT/libs/$SELF
# - ci/travis/cppcheck.sh
#################### Jobs to run on pushes to master, develop ###################
# Coverity Scan
- os: linux
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
env:
- COMMENT="Coverity Scan"
- B2_TOOLSET=clang
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/coverity.sh
# Standalone tests for StaticString
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-7", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-7 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-8", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-8 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-9", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-9 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang-6.0", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *clang-6 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang-7", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *clang-7 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang-8", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *clang-8 }
- os: "linux"
env: ["COMMENT=STANDALONE", "B2_TOOLSET=clang-9", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17"]
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages:
- clang-9
- libc6-dbg
- libc++-dev
- libstdc++-8-dev
- { os: "osx" , env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ] }
notifications:
email:
false

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -7,146 +7,112 @@
# Official repository: https://github.com/boostorg/static_string # Official repository: https://github.com/boostorg/static_string
# #
cmake_minimum_required (VERSION 3.5.1) cmake_minimum_required(VERSION 3.5...3.16)
if (POLICY CMP0074) project(boost_static_string VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
cmake_policy (SET CMP0074 NEW)
endif()
#------------------------------------------------------------------------------- set(BOOST_STATIC_STRING_IS_ROOT OFF)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(BOOST_STATIC_STRING_IS_ROOT ON)
endif ()
function (DoGroupSources curdir rootdir folder) if (BOOST_STATIC_STRING_IS_ROOT)
file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*) include(CTest)
foreach (child ${children}) endif ()
if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
DoGroupSources (${curdir}/${child} ${rootdir} ${folder})
elseif (${child} STREQUAL "CMakeLists.txt")
source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
else()
string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir})
string (REPLACE "/" "\\" groupname ${groupname})
source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endfunction()
function (GroupSources curdir folder) # Options
DoGroupSources (${curdir} ${curdir} ${folder}) if (NOT BOOST_SUPERPROJECT_VERSION)
endfunction() option(BOOST_STATIC_STRING_INSTALL "Install boost::static_string files" ${BOOST_STATIC_STRING_IS_ROOT})
option(BOOST_STATIC_STRING_BUILD_TESTS "Build boost::static_string tests" OFF)
else ()
set(BOOST_STATIC_STRING_BUILD_TESTS ${BUILD_TESTING})
endif ()
#------------------------------------------------------------------------------- # Find boost
# if (BOOST_SUPERPROJECT_VERSION)
# StaticString set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST OFF)
# elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt" AND
#------------------------------------------------------------------------------- EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Jamroot" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../boost-build.jam" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../bootstrap.sh" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../libs")
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST OFF)
else ()
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST ON)
endif ()
project (StaticString VERSION 1) if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
find_package(Boost 1.78.0 REQUIRED COMPONENTS container)
elseif (BOOST_STATIC_STRING_IS_ROOT)
set(BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES core)
set(BOOST_INCLUDE_LIBRARIES static_string assert container_hash static_assert throw_exception utility ${BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES})
set(BOOST_EXCLUDE_LIBRARIES static_string)
set(CMAKE_FOLDER Dependencies)
add_subdirectory(../.. Dependencies/boost EXCLUDE_FROM_ALL)
unset(CMAKE_FOLDER)
endif ()
set_property (GLOBAL PROPERTY USE_FOLDERS ON) # Sources
include(GNUInstallDirs)
if (MSVC) file(GLOB_RECURSE BOOST_STATIC_STRING_HEADERS CONFIGURE_DEPENDS
set (CMAKE_VERBOSE_MAKEFILE FALSE) include/boost/*.hpp
include/boost/*.ipp
add_definitions ( include/boost/*.natvis
-D_WIN32_WINNT=0x0601
)
add_compile_options(
/permissive- # strict C++
/W4 # enable all warnings
/MP # Multi-processor compilation
) )
set (Boost_USE_STATIC_LIBS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set (Boost_USE_STATIC_RUNTIME ON) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/boost PREFIX "" FILES ${BOOST_STATIC_STRING_HEADERS})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "" FILES ${BOOST_STATIC_STRING_SOURCES})
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") # Target
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT") add_library(boost_static_string INTERFACE)
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT") add_library(Boost::static_string ALIAS boost_static_string)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") target_compile_features(boost_static_string INTERFACE cxx_constexpr)
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") if (BOOST_SUPERPROJECT_VERSION)
target_include_directories(boost_static_string INTERFACE "${PROJECT_SOURCE_DIR}/include")
else ()
target_include_directories(boost_static_string
INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
endif ()
# for RelWithDebInfo builds, disable incremental linking if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
# since CMake sets it ON by default for that build type and it target_link_libraries(boost_static_string
# causes warnings INTERFACE
# Boost::headers
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags )
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}) else ()
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags}) target_link_libraries(boost_static_string
INTERFACE
Boost::assert
Boost::container_hash
Boost::core
Boost::static_assert
Boost::throw_exception
Boost::utility
)
endif ()
else() if (BOOST_STATIC_STRING_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
set (THREADS_PREFER_PTHREAD_FLAG ON) install(TARGETS boost_static_string
find_package (Threads) RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
set( CMAKE_CXX_FLAGS install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/boost
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter") DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.ipp"
)
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrange-loop-analysis")
endif ()
endif()
# Must come before Boost includes, otherwise the if (BUILD_TESTING OR BOOST_STATIC_STRING_BUILD_TESTS)
# IDE sees the wrong file due to boost/ symlinks. add_subdirectory(test)
include_directories (include) endif ()
#-------------------------------------------------------------------------------
#
# Boost
#
#-------------------------------------------------------------------------------
get_filename_component (BOOST_ROOT ../../ ABSOLUTE)
# VFALCO I want static but "b2 stage" builds a minimal set which excludes static
add_definitions (-DBOOST_ALL_STATIC_LINK=1)
include_directories (${BOOST_ROOT})
link_directories(${BOOST_ROOT}/stage/lib)
#-------------------------------------------------------------------------------
if ("${VARIANT}" STREQUAL "coverage")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE DEBUG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 --coverage")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
elseif ("${VARIANT}" STREQUAL "ubasan")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
set (CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tools/blacklist.supp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-sanitize-recover=address,undefined")
endif()
elseif ("${VARIANT}" STREQUAL "debug")
set (CMAKE_BUILD_TYPE DEBUG)
elseif ("${VARIANT}" STREQUAL "release")
set (CMAKE_BUILD_TYPE RELEASE)
endif()
#-------------------------------------------------------------------------------
#GroupSources (test "/")
#-------------------------------------------------------------------------------
#
# Tests and examples
#
#include_directories (.)
file (GLOB_RECURSE PROJECT_FILES
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.hpp
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.ipp
)
add_subdirectory (test)

10
Jamfile
View File

@ -1,10 +0,0 @@
#
# Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com)
#
# 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)
#
# Official repository: https://github.com/boostorg/static_string
#
build-project test ;

28
build.jam Normal file
View File

@ -0,0 +1,28 @@
# 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/assert//boost_assert
/boost/config//boost_config
/boost/container_hash//boost_container_hash
/boost/core//boost_core
/boost/static_assert//boost_static_assert
/boost/throw_exception//boost_throw_exception
/boost/utility//boost_utility ;
project /boost/static_string
;
explicit
[ alias boost_static_string : : :
: <include>include <library>$(boost_dependencies) ]
[ alias all : boost_static_string test ]
;
call-if : boost-library static_string
;

View File

@ -1,6 +1,7 @@
# #
# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
# Copyright (c) 2020 Krystian Stasiowski (sdkrystian at gmail dot com) # Copyright (c) 2020 Krystian Stasiowski (sdkrystian at gmail dot com)
# Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -8,252 +9,53 @@
project static_string/doc ; project static_string/doc ;
import os ;
import path ;
import boostbook ; import boostbook ;
import quickbook ; import type ;
import xsltproc ; import os ;
import doxygen ; import-search /boost/docca ;
import modules ; import docca ;
import saxonhe ;
import common ;
#------------------------------------------------------------------------------- docca.reference reference.qbk
#
# Build the list of header files that Doxygen will scan. We need
# this list to inform the build system of the dependencies so the
# docs can be rebuild if any of the header files change.
#
local sources = [ path.glob-tree ../include/boost/static_string : *.hpp *.ipp : detail impl ] ;
# Get the configured paths to doxygen and xsltproc
.doxygen = [ doxygen.name ] ;
.doxygen ?= doxygen ;
#ECHO Using doxygen from "$(.doxygen)" ;
.xsltproc = [ xsltproc.name ] ;
.xsltproc ?= xsltproc ;
#ECHO Using xsltproc from "$(.xsltproc)" ;
#-------------------------------------------------------------------------------
#
# Invoke Doxygen to process the header files and produce the XML
# containing the description of the C++ declarations and extracted
# Javadoc comments.
#
make index.xml
: :
./source.dox xsl/custom-overrides.xsl
[ glob-tree-ex ../include/boost/static_string : *.hpp *.ipp : detail impl ]
: :
@make_doxygen_xml <doxygen:param>PROJECT_NAME=StaticString
: <doxygen:param>PROJECT_BRIEF="Static String Library"
<dependency>$(sources) <doxygen:param>ALIASES="esafe=\"@par Exception Safety\""
<doxygen:param>FILE_PATTERNS=
<doxygen:param>EXAMPLE_PATTERNS=
<doxygen:param>DISTRIBUTE_GROUP_DOC=YES
<doxygen:param>MACRO_EXPANSION=YES
<doxygen:param>EXPAND_ONLY_PREDEF=YES
<doxygen:param>PREDEFINED="\\
BOOST_STATIC_STRING_DOCS \\
\"BOOST_STATIC_STRING_CPP11_CONSTEXPR=constexpr\" \\
\"BOOST_STATIC_STRING_CPP14_CONSTEXPR=constexpr\" \\
\"BOOST_STATIC_STRING_CPP17_CONSTEXPR=constexpr\" \\
\"BOOST_STATIC_STRING_CPP20_CONSTEXPR=constexpr\""
<doxygen:param>ABBREVIATE_BRIEF=
<doxygen:param>INLINE_INHERITED_MEMB=YES
<doxygen:param>JAVADOC_AUTOBRIEF=YES
<doxygen:param>AUTOLINK_SUPPORT=NO
<doxygen:param>EXTRACT_ALL=YES
<doxygen:param>EXTRACT_PRIVATE=YES
<doxygen:param>EXTRACT_LOCAL_CLASSES=NO
<doxygen:param>SHOW_INCLUDE_FILES=NO
<doxygen:param>INLINE_INFO=NO
<doxygen:param>SORT_MEMBER_DOCS=NO
<doxygen:param>SORT_MEMBERS_CTORS_1ST=YES
<doxygen:param>SHOW_USED_FILES=NO
<doxygen:param>SHOW_FILES=NO
<doxygen:param>SHOW_NAMESPACES=NO
<doxygen:param>CLASS_DIAGRAMS=NO
# <doxygen:param>ALLOW_UNICODE_NAMES=NO
# <doxygen:param>GROUP_NESTED_COMPOUNDS=NO
# <doxygen:param>HIDE_COMPOUND_REFERENCE=NO
# <doxygen:param>WARN_AS_ERROR=NO
; ;
rule make_doxygen_xml ( targets * : sources * : properties * )
{
LIB_DIR on $(targets) =
[ path.native [ path.parent [ path.root
[ on $(sources[1]) return $(SEARCH) ] [ path.pwd ] ] ] ] ;
}
if [ os.name ] = NT
{
actions make_doxygen_xml
{
SET LIB_DIR=$(LIB_DIR)
SET XML_OUTPUT=$(1:D)
"$(.doxygen)" $(2)
}
}
else
{
actions make_doxygen_xml
{
export LIB_DIR=$(LIB_DIR)
export XML_OUTPUT=$(1:D)
"$(.doxygen)" $(2)
}
}
#-------------------------------------------------------------------------------
#
# Copy all the XSLT modules to the target directory.
#
# FIXME: Change this so we can just specify a directory,
# rather than every file individually.
#
# Also, somehow force dependencies in a general way
# such that the XSLT has to be executed again
# if any of the modules change. For example,
# if base-extract-xml-pages.xml changes, then
# an invocation of extract-xml-pages.xsl (which
# imports the former) must be run again.
#
path-constant docca : ../../../tools/docca ;
make extract-xml-pages.xsl : $(docca)/include/docca/extract-xml-pages.xsl : @copy_script ;
make base-extract-xml-pages.xsl : $(docca)/include/docca/base-extract-xml-pages.xsl : @copy_script ;
make common.xsl : $(docca)/include/docca/common.xsl : @copy_script ;
make stage1.xsl : $(docca)/include/docca/stage1.xsl : @copy_script ;
make base-stage1.xsl : $(docca)/include/docca/base-stage1.xsl : @copy_script ;
make stage2.xsl : $(docca)/include/docca/stage2.xsl : @copy_script ;
make assemble-quickbook.xsl : $(docca)/include/docca/assemble-quickbook.xsl : @copy_script ;
make emphasized-types.xsl : $(docca)/include/docca/emphasized-types.xsl : @copy_script ;
make config.xsl
:
$(docca)/include/docca/config.xsl
xsl/config.xsl
xsl/class_detail.xsl
xsl/includes.xsl
:
@make_config
;
actions make_config
{
cp $(2[1]) $(1)
sed -i -e "/<!-- CONFIG_TEMPLATE -->/{r $(2[2])" -e "d}" $(1)
sed -i -e "/<!-- CLASS_DETAIL_TEMPLATE -->/{r $(2[3])" -e "d}" $(1)
sed -i -e "/<!-- INCLUDES_TEMPLATE -->/{r $(2[4])" -e "d}" $(1)
}
# Make a copy of the given file.
#
actions copy_script
{
cp $(2[1]) $(1)
}
# This is to initially create the directory as a side effect; I'm sure there's a better way...
make xml-pages/directory/placeholder : index.xml : @null_action ;
#-------------------------------------------------------------------------------
#
# Run index.xml through the first transformation stage
# (assembling and splitting the XML into page-specific files).
#
make xml-pages.xml
:
index.xml
extract-xml-pages.xsl
# Make bjam aware of additional dependencies
base-extract-xml-pages.xsl
config.xsl
common.xsl
:
saxonhe.saxonhe
;
# This is just to make the directory eligible as a source
make xml-pages : index.xml : @null_action ;
# Not ready for prime time until I figure out how to get the xslt-visualizer code in place
#make stage1/code-trace-enabled/stage1.xsl
# :
# stage1.xsl
# xslt-visualizer/xsl/trace-enable.xsl
# :
# saxonhe.saxonhe
# ;
# This is to initially create the directory as a side effect; I'm sure there's a better way...
make stage1/results/directory/placeholder : xml-pages.xml : @null_action ;
make stage2/results/directory/placeholder : xml-pages.xml : @null_action ;
# TODO: figure out why this (and the following stage) get built every time
make stage1/results
:
xml-pages
stage1.xsl
# additional dependencies
xml-pages.xml
base-stage1.xsl
config.xsl
common.xsl
:
saxonhe.saxonhe_dir
;
make stage2/results
:
stage1/results
stage2.xsl
# additional dependencies
emphasized-types.xsl
:
saxonhe.saxonhe_dir
;
make reference.qbk
:
xml-pages.xml
assemble-quickbook.xsl
# TODO: make this input to the XSLT somehow
# rather than relying on it being hard-coded
# in the XSLT (which it is!)
stage2/results
:
saxonhe.saxonhe
;
actions make_dir
{
mkdir $(1)
}
make combine.xslt : index.xml : @null_action ;
actions touch_file
{
touch $(1) ;
}
actions null_action
{
touch -c $(1) ;
}
make reference.xml
:
combine.xslt
index.xml
:
@call-xsltproc
;
actions call-xsltproc
{
"$(.xsltproc)" $(2) > $(1)
}
#-------------------------------------------------------------------------------
#
# Produce the reference.qbk file by running
# the reference xml through the transform.
#
#make reference.qbk
# :
# reference.xml
# transform.xsl
# :
# saxonhe.saxonhe
# ;
# We have to make a copy of reference.qbk and put it
# in a place where the static .qbk files can find it
#
install qbk : reference.qbk ;
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
# Produce the Boost.Book XML from the QuickBook # Produce the Boost.Book XML from the QuickBook
@ -272,7 +74,7 @@ xml static_string_doc
qbk/main.qbk qbk/main.qbk
: :
<dependency>images <dependency>images
<dependency>qbk <dependency>reference.qbk
; ;
explicit static_string_doc ; explicit static_string_doc ;
@ -291,7 +93,7 @@ boostbook static_string
<xsl:param>chapter.autolabel=0 <xsl:param>chapter.autolabel=0
<xsl:param>chunk.section.depth=8 # Depth to which sections should be chunked <xsl:param>chunk.section.depth=8 # Depth to which sections should be chunked
<xsl:param>chunk.first.sections=1 # Chunk the first top-level section? <xsl:param>chunk.first.sections=1 # Chunk the first top-level section?
<xsl:param>generate.toc="" <xsl:param>generate.toc="chapter toc,title section nop reference nop"
<include>../../../tools/boostbook/dtd <include>../../../tools/boostbook/dtd
: :
<dependency>images <dependency>images

View File

@ -32,6 +32,7 @@
[template include_file[path][^<'''<ulink url="../../../../'''[path]'''">'''[path]'''</ulink>'''>]] [template include_file[path][^<'''<ulink url="../../../../'''[path]'''">'''[path]'''</ulink>'''>]]
[def __InputIterator__ [@https://en.cppreference.com/w/cpp/named_req/InputIterator ['InputIterator]]] [def __InputIterator__ [@https://en.cppreference.com/w/cpp/named_req/InputIterator ['InputIterator]]]
[def __UnaryPredicate__ [@https://en.cppreference.com/w/cpp/named_req/Predicate ['Predicate]]]
[/-----------------------------------------------------------------------------] [/-----------------------------------------------------------------------------]

View File

@ -1,252 +0,0 @@
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = \
$(LIB_DIR)/include/boost/static_string
ALIASES += esafe="@par Exception Safety"
INPUT_ENCODING = UTF-8
FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH = ../
INCLUDE_FILE_PATTERNS =
PREDEFINED = \
BOOST_STATIC_STRING_DOCS \
"BOOST_STATIC_STRING_CPP11_CONSTEXPR=constexpr" \
"BOOST_STATIC_STRING_CPP14_CONSTEXPR=constexpr" \
"BOOST_STATIC_STRING_CPP17_CONSTEXPR=constexpr" \
"BOOST_STATIC_STRING_CPP20_CONSTEXPR=constexpr"
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "StaticString"
PROJECT_NUMBER =
PROJECT_BRIEF = String Library
PROJECT_LOGO =
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
#####ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = YES
FULL_PATH_NAMES = YES
#STRIP_FROM_PATH = $(LIB_DIR)/include # Requires doxygen 1.8.7+
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 4
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES
AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = YES
#####GROUP_NESTED_COMPOUNDS = NO
SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO
INLINE_SIMPLE_STRUCTS = NO
TYPEDEF_HIDES_STRUCT = NO
LOOKUP_CACHE_SIZE = 0
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_PACKAGE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
#####HIDE_COMPOUND_REFERENCE= NO
SHOW_INCLUDE_FILES = NO
SHOW_GROUPED_MEMB_INC = NO
FORCE_LOCAL_INCLUDES = NO
INLINE_INFO = NO
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_MEMBERS_CTORS_1ST = YES
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = NO
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = NO
SHOW_FILES = NO
SHOW_NAMESPACES = NO
FILE_VERSION_FILTER =
LAYOUT_FILE =
CITE_BIB_FILES =
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
#####WARN_AS_ERROR = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = YES
SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
CLANG_ASSISTED_PARSING = NO
CLANG_OPTIONS =
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = NO
HTML_OUTPUT = dhtm
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = NO
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 100
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
DOCSET_PUBLISHER_NAME = Publisher
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = NO
GENERATE_QHP = NO
QCH_FILE =
QHP_NAMESPACE = org.doxygen.Project
QHP_VIRTUAL_FOLDER = doc
QHP_CUST_FILTER_NAME =
QHP_CUST_FILTER_ATTRS =
QHP_SECT_FILTER_ATTRS =
QHG_LOCATION =
GENERATE_ECLIPSEHELP = NO
ECLIPSE_DOC_ID = org.doxygen.Project
DISABLE_INDEX = NO
GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
USE_MATHJAX = NO
MATHJAX_FORMAT = HTML-CSS
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
MATHJAX_EXTENSIONS =
MATHJAX_CODEFILE =
SEARCHENGINE = YES
SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO
SEARCHENGINE_URL =
SEARCHDATA_FILE = searchdata.xml
EXTERNAL_SEARCH_ID =
EXTRA_SEARCH_MAPPINGS =
GENERATE_LATEX = NO
GENERATE_RTF = NO
GENERATE_MAN = NO
GENERATE_DOCBOOK = NO
GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO
CLASS_DIAGRAMS = NO
HAVE_DOT = NO
#---------------------------------------------------------------------------
# Configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = YES
XML_OUTPUT = $(XML_OUTPUT)
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# Configuration options related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
PERL_PATH = /usr/bin/perl

View File

@ -1,3 +0,0 @@
<!-- CLASS_DETAIL_TEMPLATE BEGIN -->
<xsl:when test="$normal-tparam = 'InputIterator'"><xsl:text>__InputIterator__</xsl:text></xsl:when>
<!-- CLASS_DETAIL_TEMPLATE END -->

View File

@ -1,6 +0,0 @@
<!-- Variables (Edit for your project) -->
<xsl:variable name="doc-ref" select="'static_string.ref'"/>
<xsl:variable name="doc-ns" select="'boost::static_strings'"/>
<xsl:variable name="debug" select="0"/>
<xsl:variable name="private" select="0"/>
<!-- End Variables -->

View File

@ -0,0 +1,11 @@
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
expand-text="yes">
<xsl:variable name="doc-ref" select="'static_string.ref'"/>
<xsl:variable name="doc-ns" select="'boost::static_strings'"/>
<xsl:variable name="include-private-members" select="false()"/>
</xsl:stylesheet>

View File

@ -1,5 +0,0 @@
<!-- INCLUDES_TEMPLATE BEGIN -->
<xsl:text>Defined in header [include_file </xsl:text>
<xsl:value-of select="substring-after($file,'include/')"/>
<xsl:text>]&#xd;&#xd;</xsl:text>
<!-- INCLUDES_TEMPLATE END -->

View File

@ -1,7 +0,0 @@
<!-- INCLUDES_FOOT_TEMPLATE BEGIN -->
<xsl:choose>
<xsl:when test="contains($file, 'supercalifragilisticexpialidocious')">
<xsl:text>&#xd;&#xd;Easter Egg&#xd;</xsl:text>
</xsl:when>
</xsl:choose>
<!-- INCLUDES_FOOT_TEMPLATE END -->

View File

@ -14,13 +14,24 @@
// Are we dependent on Boost? // Are we dependent on Boost?
// #define BOOST_STATIC_STRING_STANDALONE // #define BOOST_STATIC_STRING_STANDALONE
#include <cstdint>
// detect 32/64 bit
#if UINTPTR_MAX == UINT64_MAX
#define BOOST_STATIC_STRING_ARCH 64
#elif UINTPTR_MAX == UINT32_MAX
#define BOOST_STATIC_STRING_ARCH 32
#else
#error Unknown or unsupported architecture, please open an issue
#endif
// Can we have deduction guides? // Can we have deduction guides?
#if __cpp_deduction_guides >= 201703L #if __cpp_deduction_guides >= 201703L
#define BOOST_STATIC_STRING_USE_DEDUCT #define BOOST_STATIC_STRING_USE_DEDUCT
#endif #endif
// Include <version> if we can // Include <version> if we can
#ifdef __has_include #ifdef __has_include
#if __has_include(<version>) #if __has_include(<version>)
#include <version> #include <version>
#endif #endif
@ -45,7 +56,7 @@
#define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_cpp_attribute(x) #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_cpp_attribute(x)
#elif defined(__has_attribute) #elif defined(__has_attribute)
#define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_attribute(x) #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_attribute(x)
#else #else
#define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) 0 #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) 0
#endif #endif
@ -147,15 +158,51 @@
#endif #endif
#ifndef BOOST_STATIC_STRING_STANDALONE #ifndef BOOST_STATIC_STRING_STANDALONE
#include <boost/config.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/container_hash/hash.hpp> #include <boost/container_hash/hash.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/utility/string_view.hpp> #include <boost/utility/string_view.hpp>
#include <boost/core/detail/string_view.hpp>
#include <boost/throw_exception.hpp> #include <boost/throw_exception.hpp>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) || \
defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW)
#include <string_view>
#define BOOST_STATIC_STRING_HAS_STD_STRING_VIEW
#endif
#else #else
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>
/*
* Replicate the logic from Boost.Config
*/
// GNU libstdc++3:
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
#if (BOOST_LIBSTDCXX_VERSION < 70100) || (__cplusplus <= 201402L)
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#endif
// libc++:
#elif defined(_LIBCPP_VERSION)
#if (_LIBCPP_VERSION < 4000) || (__cplusplus <= 201402L)
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#endif
// MSVC uses logic from catch all for BOOST_NO_CXX17_HDR_STRING_VIEW
// catch all:
#elif !defined(_YVALS) && !defined(_CPPLIB_VER)
#if (!defined(__has_include) || (__cplusplus < 201700))
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#elif !__has_include(<string_view>)
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#endif
#endif
#if !defined(BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW) || \
defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW)
#include <string_view> #include <string_view>
#define BOOST_STATIC_STRING_HAS_STD_STRING_VIEW
#endif
#endif #endif
// Compiler bug prevents constexpr from working with clang 4.x and 5.x // Compiler bug prevents constexpr from working with clang 4.x and 5.x
@ -192,6 +239,30 @@ defined(BOOST_STATIC_STRING_CPP14)
#define BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR #define BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR
#endif #endif
#ifndef BOOST_STATIC_STRING_STANDALONE
#if ! defined(BOOST_NO_CWCHAR) && ! defined(BOOST_NO_SWPRINTF)
#define BOOST_STATIC_STRING_HAS_WCHAR
#endif
#else
#ifndef __has_include
// If we don't have __has_include in standalone,
// we will assume that <cwchar> exists.
#define BOOST_STATIC_STRING_HAS_WCHAR
#elif __has_include(<cwchar>)
#define BOOST_STATIC_STRING_HAS_WCHAR
#endif
#endif
#ifdef BOOST_STATIC_STRING_HAS_WCHAR
#include <cwchar>
#endif
// Define the basic string_view type used by the library
// Conversions to and from other available string_view types
// are still defined.
#if !defined(BOOST_STATIC_STRING_STANDALONE) || \
defined(BOOST_STATIC_STRING_HAS_STD_STRING_VIEW)
#define BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
namespace boost { namespace boost {
namespace static_strings { namespace static_strings {
@ -205,4 +276,6 @@ using basic_string_view =
#endif #endif
} // static_strings } // static_strings
} // boost } // boost
#endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,9 @@
"String" "String"
], ],
"maintainers": [ "maintainers": [
"Krystian Stasiowski <sdkrystian@gmail.com>" "Krystian Stasiowski <sdkrystian@gmail.com>",
] "Alan de Freitas <alandefreitas@gmail.com>",
"Vinnie Falco <vinnie.falco@gmail.com>"
],
"cxxstd": "11"
} }

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -7,16 +7,26 @@
# Official repository: https://github.com/boostorg/static_string # Official repository: https://github.com/boostorg/static_string
# #
GroupSources (include/boost/static_string static_string) # Custom target used by the boost super-project
GroupSources (test "/") if(NOT TARGET tests)
add_custom_target(tests)
set_property(TARGET tests PROPERTY FOLDER _deps)
endif()
add_executable (tests set(BOOST_STATIC_STRING_TESTS_FILES
${PROJECT_FILES} CMakeLists.txt
Jamfile Jamfile
static_string.cpp constexpr_tests.hpp
) compile_fail.hpp
static_string.cpp
)
target_link_libraries(tests source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${BOOST_STATIC_STRING_TESTS_FILES})
) add_executable(boost_static_string_tests ${BOOST_STATIC_STRING_TESTS_FILES})
set_property(TARGET tests PROPERTY FOLDER "tests") # The include dependencies are found in the CMakeLists.txt
# of the root project directory.
# See: BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES
target_link_libraries(boost_static_string_tests PRIVATE Boost::static_string)
add_test(NAME boost_static_string_tests COMMAND boost_static_string_tests)
add_dependencies(tests boost_static_string_tests)

View File

@ -8,7 +8,8 @@
# #
import testing ; import testing ;
import ../../config/checks/config : requires ; import-search /boost/config/checks ;
import config : requires ;
local defines = local defines =
[ requires [ requires
@ -20,6 +21,7 @@ local defines =
] ]
; ;
project : requirements $(defines) ; project : requirements $(defines)
<library>/boost/static_string//boost_static_string ;
run static_string.cpp ; run static_string.cpp ;

View File

@ -41,14 +41,14 @@ struct cxper_char_traits
*(dest++) = *(src++); *(dest++) = *(src++);
return temp; return temp;
} }
static constexpr char_type* copy(char_type* dest, const char_type* src, std::size_t n) static constexpr char_type* copy(char_type* dest, const char_type* src, std::size_t n)
{ {
const auto temp = dest; const auto temp = dest;
while (n--) while (n--)
*(dest++) = *(src++); *(dest++) = *(src++);
return temp; return temp;
} }
static constexpr char_type* assign(char_type* dest, std::size_t n, char_type ch) static constexpr char_type* assign(char_type* dest, std::size_t n, char_type ch)
{ {
const auto temp = dest; const auto temp = dest;
while (n--) while (n--)
@ -62,8 +62,8 @@ using cxper_char_traits = std::char_traits<char>;
using cstatic_string = basic_static_string<50, char, cxper_char_traits>; using cstatic_string = basic_static_string<50, char, cxper_char_traits>;
inline inline
constexpr constexpr
bool bool
testConstantEvaluation() testConstantEvaluation()
{ {
#ifdef BOOST_STATIC_STRING_CPP20 #ifdef BOOST_STATIC_STRING_CPP20
@ -357,8 +357,10 @@ testConstantEvaluation()
a.substr(0); a.substr(0);
#endif #endif
#ifdef BOOST_STATIC_STRING_HAS_STRING_VIEW
// subview // subview
a.subview(0); a.subview(0);
#endif
// copy // copy
char k[20]{}; char k[20]{};
@ -421,7 +423,7 @@ testConstantEvaluation()
// ends_with // ends_with
a.ends_with('a'); a.ends_with('a');
a.ends_with("a"); a.ends_with("a");
return true; return true;
#elif defined(BOOST_STATIC_STRING_CPP14) #elif defined(BOOST_STATIC_STRING_CPP14)
// c++14 constexpr tests // c++14 constexpr tests
@ -521,17 +523,17 @@ testConstantEvaluation()
a.compare("a"); a.compare("a");
a.compare(0, 1, "a"); a.compare(0, 1, "a");
a.compare(0, 1, "a", 1); a.compare(0, 1, "a", 1);
// substr // substr
// in gcc 5, a constexpr non-static member function returning the class // in gcc 5, a constexpr non-static member function returning the class
// is a member of causes an ICE // is a member of causes an ICE
#ifndef BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR #ifndef BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR
a.substr(0, 1); a.substr(0, 1);
#endif #endif
// subview // subview
a.subview(0); a.subview(0);
// copy // copy
char k[20]{}; char k[20]{};
a.copy(k, 1, 0); a.copy(k, 1, 0);
@ -596,9 +598,9 @@ testConstantEvaluation()
return true; return true;
#elif defined(BOOST_STATIC_STRING_CPP11) #elif defined(BOOST_STATIC_STRING_CPP11)
// c++11 constexpr tests // c++11 constexpr tests
return (cstatic_string().size() + return (cstatic_string().size() +
cstatic_string().length() + cstatic_string().length() +
cstatic_string().max_size() + cstatic_string().max_size() +
cstatic_string().capacity()) != 0 && cstatic_string().capacity()) != 0 &&
cstatic_string().empty(); cstatic_string().empty();
#endif #endif

View File

@ -9,13 +9,15 @@
// //
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/static_string/static_string.hpp> #include <boost/static_string.hpp>
#include "constexpr_tests.hpp" #include "constexpr_tests.hpp"
#include "compile_fail.hpp" #include "compile_fail.hpp"
#include <boost/core/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <boost/core/ignore_unused.hpp>
#include <cstdlib> #include <cstdlib>
#include <cwchar> #include <cwchar>
#include <cctype>
#include <sstream> #include <sstream>
#include <string> #include <string>
@ -23,8 +25,16 @@ namespace boost {
namespace static_strings { namespace static_strings {
template class basic_static_string<420, char>; template class basic_static_string<420, char>;
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
using string_view = basic_string_view<char, std::char_traits<char>>; using string_view = basic_string_view<char, std::char_traits<char>>;
#endif
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
using string_like = basic_string_view<char, std::char_traits<char>>;
#else
using string_like = std::string;
#endif
template <class S> template <class S>
bool bool
@ -49,13 +59,21 @@ testSV(const S& s, typename S::size_type pos, typename S::size_type n)
{ {
if (pos <= s.size()) if (pos <= s.size())
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
typename S::string_view_type str = s.subview(pos, n); typename S::string_view_type str = s.subview(pos, n);
#else
auto str = s.substr(pos, n);
#endif
typename S::size_type rlen = (std::min)(n, s.size() - pos); typename S::size_type rlen = (std::min)(n, s.size() - pos);
return (S::traits_type::compare(s.data() + pos, str.data(), rlen) == 0); return (S::traits_type::compare(s.data() + pos, str.data(), rlen) == 0);
} }
else else
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
BOOST_TEST_THROWS((s.subview(pos, n)), std::out_of_range); BOOST_TEST_THROWS((s.subview(pos, n)), std::out_of_range);
#else
BOOST_TEST_THROWS((s.substr(pos, n)), std::out_of_range);
#endif
return true; return true;
} }
} }
@ -109,7 +127,7 @@ testA(S s, const typename S::value_type* str, typename S::size_type n, S expecte
return s.append(str, n) == expected; return s.append(str, n) == expected;
} }
int int
sign(int x) sign(int x)
{ {
if (x == 0) if (x == 0)
@ -215,7 +233,7 @@ testR(S s, typename S::size_type pos, typename S::size_type n1, const typename S
// this is a precondition violation for the const_iterator overload // this is a precondition violation for the const_iterator overload
return s.replace(pos, n1, str, n2) == expected; return s.replace(pos, n1, str, n2) == expected;
else else
return s.replace(pos, n1, str, n2) == expected && return s.replace(pos, n1, str, n2) == expected &&
s0.replace(s0.begin() + pos, s0.begin() + pos + n1, str, str + n2) == expected; s0.replace(s0.begin() + pos, s0.begin() + pos + n1, str, str + n2) == expected;
} }
else else
@ -227,29 +245,52 @@ testR(S s, typename S::size_type pos, typename S::size_type n1, const typename S
template<typename Arithmetic> template<typename Arithmetic>
bool bool
testTS(Arithmetic value, const char* str_expected = "", const wchar_t* wstr_expected = L"", bool test_expected = false) testTS(Arithmetic value, const char* str_expected = "", bool test_expected = false)
{ {
const auto str = to_static_string(value); const auto str = to_static_string(value);
const auto wstr = to_static_wstring(value);
if (std::is_floating_point<Arithmetic>::value) if (std::is_floating_point<Arithmetic>::value)
{ {
const auto std_res = std::to_string(value); const auto std_res = std::to_string(value);
const auto wstd_res = std::to_wstring(value); return str == std_res.data();
return str == std_res.data() && wstr == wstd_res.data();
} }
else else
{ {
if (std::is_signed<Arithmetic>::value) if (std::is_signed<Arithmetic>::value)
{ {
return Arithmetic(std::strtoll(str.begin(), nullptr, 10)) == value && return
Arithmetic(std::wcstoll(wstr.begin(), nullptr, 10)) == value && Arithmetic(std::strtoll(str.begin(), nullptr, 10)) == value &&
(test_expected ? str == str_expected && wstr == wstr_expected : true); (! test_expected || str == str_expected);
} }
else else
{ {
return Arithmetic(std::strtoull(str.begin(), nullptr, 10)) == value && return Arithmetic(std::strtoull(str.begin(), nullptr, 10)) == value &&
Arithmetic(std::wcstoull(wstr.begin(), nullptr, 10)) == value && (! test_expected || str == str_expected);
(test_expected ? str == str_expected && wstr == wstr_expected : true); }
}
}
template<typename Arithmetic>
bool
testTWS(Arithmetic value, const wchar_t* wstr_expected = L"", bool test_expected = false)
{
const auto wstr = to_static_wstring(value);
if (std::is_floating_point<Arithmetic>::value)
{
const auto wstd_res = std::to_wstring(value);
return wstr == wstd_res.data();
}
else
{
if (std::is_signed<Arithmetic>::value)
{
return
Arithmetic(std::wcstoll(wstr.begin(), nullptr, 10)) == value &&
(! test_expected || wstr == wstr_expected);
}
else
{
return Arithmetic(std::wcstoull(wstr.begin(), nullptr, 10)) == value &&
(! test_expected || wstr == wstr_expected);
} }
} }
} }
@ -340,11 +381,11 @@ testConstruct()
} }
{ {
static_string<3> s1( static_string<3> s1(
string_view("123")); string_like("123"));
BOOST_TEST(s1 == "123"); BOOST_TEST(s1 == "123");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(static_string<2>(string_view("123"))), (static_string<2>(string_like("123"))),
std::length_error); std::length_error);
} }
{ {
@ -398,7 +439,7 @@ testAssignment()
BOOST_TEST(static_string<3>{}.assign("abc", 3) == "abc"); BOOST_TEST(static_string<3>{}.assign("abc", 3) == "abc");
BOOST_TEST(static_string<3>{"*"}.assign("abc", 3) == "abc"); BOOST_TEST(static_string<3>{"*"}.assign("abc", 3) == "abc");
BOOST_TEST_THROWS(static_string<1>{}.assign("abc", 3), std::length_error); BOOST_TEST_THROWS(static_string<1>{}.assign("abc", 3), std::length_error);
// assign(CharT const* s) // assign(CharT const* s)
BOOST_TEST(static_string<3>{}.assign("abc") == "abc"); BOOST_TEST(static_string<3>{}.assign("abc") == "abc");
BOOST_TEST(static_string<3>{"*"}.assign("abc") == "abc"); BOOST_TEST(static_string<3>{"*"}.assign("abc") == "abc");
@ -411,8 +452,9 @@ testAssignment()
BOOST_TEST(static_string<4>{}.assign(cs.begin(), cs.end()) == "abcd"); BOOST_TEST(static_string<4>{}.assign(cs.begin(), cs.end()) == "abcd");
BOOST_TEST(static_string<4>{"*"}.assign(cs.begin(), cs.end()) == "abcd"); BOOST_TEST(static_string<4>{"*"}.assign(cs.begin(), cs.end()) == "abcd");
BOOST_TEST_THROWS(static_string<2>{"*"}.assign(cs.begin(), cs.end()), std::length_error); BOOST_TEST_THROWS(static_string<2>{"*"}.assign(cs.begin(), cs.end()), std::length_error);
ignore_unused(s);
} }
// assign(std::initializer_list<CharT> ilist) // assign(std::initializer_list<CharT> ilist)
BOOST_TEST(static_string<3>{}.assign({'a', 'b', 'c'}) == "abc"); BOOST_TEST(static_string<3>{}.assign({'a', 'b', 'c'}) == "abc");
BOOST_TEST(static_string<3>{"*"}.assign({'a', 'b', 'c'}) == "abc"); BOOST_TEST(static_string<3>{"*"}.assign({'a', 'b', 'c'}) == "abc");
@ -421,6 +463,7 @@ testAssignment()
// assign(T const& t) // assign(T const& t)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -428,6 +471,21 @@ testAssignment()
return "abc"; return "abc";
} }
}; };
#else
struct T
{
char const* data() const noexcept
{
static char p[] = "abc";
return p;
}
std::size_t size() const noexcept
{
return 3;
}
};
#endif
BOOST_TEST(static_string<3>{}.assign(T{}) == "abc"); BOOST_TEST(static_string<3>{}.assign(T{}) == "abc");
BOOST_TEST(static_string<3>{"*"}.assign(T{}) == "abc"); BOOST_TEST(static_string<3>{"*"}.assign(T{}) == "abc");
BOOST_TEST(static_string<3>{"***"}.assign(T{}) == "abc"); BOOST_TEST(static_string<3>{"***"}.assign(T{}) == "abc");
@ -436,6 +494,7 @@ testAssignment()
// assign(T const& t, size_type pos, size_type count = npos) // assign(T const& t, size_type pos, size_type count = npos)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -443,6 +502,23 @@ testAssignment()
return "abcde"; return "abcde";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
static char p[] = "abcde";
return p;
}
std::size_t
size() const
{
return 5;
}
};
#endif
BOOST_TEST(static_string<5>{}.assign(T{}, 0) == "abcde"); BOOST_TEST(static_string<5>{}.assign(T{}, 0) == "abcde");
BOOST_TEST(static_string<5>{}.assign(T{}, 0, 5) == "abcde"); BOOST_TEST(static_string<5>{}.assign(T{}, 0, 5) == "abcde");
BOOST_TEST(static_string<5>{}.assign(T{}, 1, 3) == "bcd"); BOOST_TEST(static_string<5>{}.assign(T{}, 1, 3) == "bcd");
@ -450,7 +526,7 @@ testAssignment()
BOOST_TEST_THROWS(static_string<2>{"**"}.assign(T{}, 6, 3), std::out_of_range); BOOST_TEST_THROWS(static_string<2>{"**"}.assign(T{}, 6, 3), std::out_of_range);
BOOST_TEST_THROWS(static_string<2>{"**"}.assign(T{}, 1, 3), std::length_error); BOOST_TEST_THROWS(static_string<2>{"**"}.assign(T{}, 1, 3), std::length_error);
} }
//--- //---
{ {
@ -471,7 +547,7 @@ testAssignment()
s3 = s1, s3 = s1,
std::length_error); std::length_error);
} }
{ {
static_string<3> s1; static_string<3> s1;
s1 = "123"; s1 = "123";
@ -504,15 +580,14 @@ testAssignment()
} }
{ {
static_string<3> s1; static_string<3> s1;
s1 = string_view("123"); s1 = string_like("123");
BOOST_TEST(s1 == "123"); BOOST_TEST(s1 == "123");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
static_string<1> s2; static_string<1> s2;
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
s2 = string_view("123"), s2 = string_like("123"),
std::length_error); std::length_error);
} }
{ {
static_string<4> s1; static_string<4> s1;
s1.assign(3, 'x'); s1.assign(3, 'x');
@ -600,14 +675,14 @@ testAssignment()
} }
{ {
static_string<5> s1; static_string<5> s1;
s1.assign(string_view("123")); s1.assign(string_like("123"));
BOOST_TEST(s1 == "123"); BOOST_TEST(s1 == "123");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
s1.assign(string_view("12345")); s1.assign(string_like("12345"));
BOOST_TEST(s1 == "12345"); BOOST_TEST(s1 == "12345");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
s1.assign(string_view("1234567")), s1.assign(string_like("1234567")),
std::length_error); std::length_error);
} }
{ {
@ -671,6 +746,13 @@ testAssignment()
s_long.assign(s_long.data() + 2, 8); s_long.assign(s_long.data() + 2, 8);
BOOST_TEST(s_long == "rem ipsu"); BOOST_TEST(s_long == "rem ipsu");
// issue #41
{
boost::static_strings::static_string<0> a;
auto b = a;
BOOST_TEST(b == "");
}
} }
// done // done
@ -685,7 +767,7 @@ testElements()
BOOST_TEST(static_string<3>{"abc"}.at(2) == 'c'); BOOST_TEST(static_string<3>{"abc"}.at(2) == 'c');
BOOST_TEST_THROWS(static_string<3>{""}.at(0), std::out_of_range); BOOST_TEST_THROWS(static_string<3>{""}.at(0), std::out_of_range);
BOOST_TEST_THROWS(static_string<3>{"abc"}.at(4), std::out_of_range); BOOST_TEST_THROWS(static_string<3>{"abc"}.at(4), std::out_of_range);
// at(size_type pos) const // at(size_type pos) const
BOOST_TEST(cfs3{"abc"}.at(0) == 'a'); BOOST_TEST(cfs3{"abc"}.at(0) == 'a');
BOOST_TEST(cfs3{"abc"}.at(2) == 'c'); BOOST_TEST(cfs3{"abc"}.at(2) == 'c');
@ -716,7 +798,7 @@ testElements()
BOOST_TEST(static_string<3>{"a"}.back() == 'a'); BOOST_TEST(static_string<3>{"a"}.back() == 'a');
BOOST_TEST(static_string<3>{"abc"}.back() == 'c'); BOOST_TEST(static_string<3>{"abc"}.back() == 'c');
// back() const // back() const
BOOST_TEST(cfs3{"a"}.back() == 'a'); BOOST_TEST(cfs3{"a"}.back() == 'a');
BOOST_TEST(cfs3{"abc"}.back() == 'c'); BOOST_TEST(cfs3{"abc"}.back() == 'c');
@ -785,11 +867,20 @@ testElements()
BOOST_TEST(std::memcmp( BOOST_TEST(std::memcmp(
s.c_str(), "123\0", 4) == 0); s.c_str(), "123\0", 4) == 0);
} }
#ifdef BOOST_STATIC_ASSERT_HAS_STRING_VIEW
{ {
static_string<3> s("123"); static_string<3> s("123");
string_view sv = s; string_view sv = s;
BOOST_TEST(static_string<5>(sv) == "123"); BOOST_TEST(static_string<5>(sv) == "123");
} }
#endif
#ifdef BOOST_STATIC_ASSERT_HAS_STD_STRING_VIEW
{
static_string<3> s("123");
std::string_view sv = s;
BOOST_TEST(static_string<5>(sv) == "123");
}
#endif
} }
// done // done
@ -896,12 +987,17 @@ testClear()
BOOST_TEST(*s.end() == 0); BOOST_TEST(*s.end() == 0);
} }
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic push // false positives
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
// done // done
static static
void void
testInsert() testInsert()
{ {
using sv = string_view; using sv = string_like;
using S = static_string<100>; using S = static_string<100>;
// insert(size_type index, size_type count, CharT ch) // insert(size_type index, size_type count, CharT ch)
@ -923,7 +1019,7 @@ testInsert()
BOOST_TEST(static_string<4>{"ad"}.insert(1, "bcd", 2) == "abcd"); BOOST_TEST(static_string<4>{"ad"}.insert(1, "bcd", 2) == "abcd");
BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, "*"), std::out_of_range); BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, "*"), std::out_of_range);
BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, "*"), std::length_error); BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, "*"), std::length_error);
// insert(size_type index, string_view_type sv) // insert(size_type index, string_view_type sv)
BOOST_TEST(static_string<3>{"ac"}.insert(1, sv{"b"}) == "abc"); BOOST_TEST(static_string<3>{"ac"}.insert(1, sv{"b"}) == "abc");
BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, sv{"*"}), std::out_of_range); BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, sv{"*"}), std::out_of_range);
@ -982,6 +1078,7 @@ testInsert()
// insert(size_type index, T const& t) // insert(size_type index, T const& t)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -989,6 +1086,23 @@ testInsert()
return "b"; return "b";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
static char p[] = "b";
return p;
}
std::size_t
size() const
{
return 1;
}
};
#endif
BOOST_TEST(static_string<3>{"ac"}.insert(1, T{}) == "abc"); BOOST_TEST(static_string<3>{"ac"}.insert(1, T{}) == "abc");
BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, T{}), std::out_of_range); BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, T{}), std::out_of_range);
BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, T{}), std::length_error); BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, T{}), std::length_error);
@ -996,6 +1110,7 @@ testInsert()
// insert(size_type index, T const& t, size_type index_str, size_type count = npos) // insert(size_type index, T const& t, size_type index_str, size_type count = npos)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -1003,6 +1118,23 @@ testInsert()
return "abcd"; return "abcd";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
static char p[] = "abcd";
return p;
}
std::size_t
size() const noexcept
{
return 4;
}
};
#endif
BOOST_TEST(static_string<6>{"ae"}.insert(1, T{}, 1) == "abcde"); BOOST_TEST(static_string<6>{"ae"}.insert(1, T{}, 1) == "abcde");
BOOST_TEST(static_string<6>{"abe"}.insert(2, T{}, 2) == "abcde"); BOOST_TEST(static_string<6>{"abe"}.insert(2, T{}, 2) == "abcde");
BOOST_TEST(static_string<4>{"ac"}.insert(1, T{}, 1, 1) == "abc"); BOOST_TEST(static_string<4>{"ac"}.insert(1, T{}, 1, 1) == "abc");
@ -1049,6 +1181,7 @@ testInsert()
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(s2.insert(6, "__")), (s2.insert(6, "__")),
std::out_of_range); std::out_of_range);
ignore_unused(s3);
} }
{ {
static_string<7> s1("12345"); static_string<7> s1("12345");
@ -1129,16 +1262,16 @@ testInsert()
} }
{ {
static_string<5> s1("123"); static_string<5> s1("123");
s1.insert(1, string_view("UV")); s1.insert(1, string_like("UV"));
BOOST_TEST(s1 == "1UV23"); BOOST_TEST(s1 == "1UV23");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
static_string<4> s2("123"); static_string<4> s2("123");
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(s2.insert(1, string_view("UV"))), (s2.insert(1, string_like("UV"))),
std::length_error); std::length_error);
static_string<5> s3("123"); static_string<5> s3("123");
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(s3.insert(5, string_view("UV"))), (s3.insert(5, string_like("UV"))),
std::out_of_range); std::out_of_range);
} }
{ {
@ -1638,7 +1771,11 @@ testInsert()
BOOST_TEST(testI(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"))); BOOST_TEST(testI(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen")));
} }
// done #if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
// done
static static
void void
testErase() testErase()
@ -1848,6 +1985,51 @@ testErase()
BOOST_TEST(testE(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"))); BOOST_TEST(testE(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen")));
} }
// done
static
void
testEraseIf()
{
// erase_if(static_string& str, UnaryPredicate pred)
{
static_string<3> s{""};
BOOST_TEST(erase_if(s, [](char c) { return c == 'a'; }) == 0);
BOOST_TEST(s == "");
BOOST_TEST(*s.end() == 0);
}
{
static_string<3> s{"aaa"};
BOOST_TEST(erase_if(s, [](char c) { return c == 'a'; }) == 3);
BOOST_TEST(s == "");
BOOST_TEST(*s.end() == 0);
}
{
static_string<3> s{"abc"};
BOOST_TEST(erase_if(s, [](char c) { return c == 'a'; }) == 1);
BOOST_TEST(s == "bc");
BOOST_TEST(*s.end() == 0);
}
{
static_string<3> s{"abc"};
BOOST_TEST(erase_if(s, [](char c) { return c == 'b'; }) == 1);
BOOST_TEST(s == "ac");
BOOST_TEST(*s.end() == 0);
}
{
static_string<3> s{"abc"};
BOOST_TEST(erase_if(s, [](char c) { return c == 'c'; }) == 1);
BOOST_TEST(s == "ab");
BOOST_TEST(*s.end() == 0);
}
{
static_string<3> s{"abc"};
BOOST_TEST(erase_if(s, [](char c) { return c == 'd'; }) == 0);
BOOST_TEST(s == "abc");
BOOST_TEST(*s.end() == 0);
}
}
// done // done
static static
void void
@ -1921,7 +2103,7 @@ void
testAppend() testAppend()
{ {
using S = static_string<400>; using S = static_string<400>;
using sv = string_view; using sv = string_like;
// append(size_type count, CharT ch) // append(size_type count, CharT ch)
BOOST_TEST(static_string<1>{}.append(1, 'a') == "a"); BOOST_TEST(static_string<1>{}.append(1, 'a') == "a");
@ -1957,6 +2139,7 @@ testAppend()
cs.begin() + 2, cs.begin() + 4) == "abcd"); cs.begin() + 2, cs.begin() + 4) == "abcd");
BOOST_TEST_THROWS(static_string<2>{"ab"}.append( BOOST_TEST_THROWS(static_string<2>{"ab"}.append(
cs.begin() + 2, cs.begin() + 4), std::length_error); cs.begin() + 2, cs.begin() + 4), std::length_error);
ignore_unused(s);
} }
// append(std::initializer_list<CharT> ilist) // append(std::initializer_list<CharT> ilist)
@ -1965,6 +2148,7 @@ testAppend()
// append(T const& t) // append(T const& t)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -1972,12 +2156,29 @@ testAppend()
return "c"; return "c";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
return "c";
}
std::size_t
size() const noexcept
{
return 1;
}
};
#endif
BOOST_TEST(static_string<3>{"ab"}.append(T{}) == "abc"); BOOST_TEST(static_string<3>{"ab"}.append(T{}) == "abc");
BOOST_TEST_THROWS(static_string<3>{"abc"}.append(T{}), std::length_error); BOOST_TEST_THROWS(static_string<3>{"abc"}.append(T{}), std::length_error);
} }
// append(T const& t, size_type pos, size_type count = npos) // append(T const& t, size_type pos, size_type count = npos)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -1985,6 +2186,22 @@ testAppend()
return "abcd"; return "abcd";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
return "abcd";
}
std::size_t
size() const noexcept
{
return 4;
}
};
#endif
BOOST_TEST(static_string<4>{"ab"}.append(T{}, 2) == "abcd"); BOOST_TEST(static_string<4>{"ab"}.append(T{}, 2) == "abcd");
BOOST_TEST(static_string<3>{"a"}.append(T{}, 1, 2) == "abc"); BOOST_TEST(static_string<3>{"a"}.append(T{}, 1, 2) == "abc");
BOOST_TEST_THROWS(static_string<4>{"abc"}.append(T{}, 5), std::out_of_range); BOOST_TEST_THROWS(static_string<4>{"abc"}.append(T{}, 5), std::out_of_range);
@ -2075,7 +2292,7 @@ testAppend()
std::length_error); std::length_error);
} }
{ {
string_view s1("XYZ"); string_like s1("XYZ");
static_string<5> s2("12"); static_string<5> s2("12");
s2.append(s1); s2.append(s1);
BOOST_TEST(s2 == "12XYZ"); BOOST_TEST(s2 == "12XYZ");
@ -2130,7 +2347,7 @@ static
void void
testPlusEquals() testPlusEquals()
{ {
using sv = string_view; using sv = string_like;
// operator+=(CharT ch) // operator+=(CharT ch)
BOOST_TEST((static_string<3>{"ab"} += 'c') == "abc"); BOOST_TEST((static_string<3>{"ab"} += 'c') == "abc");
@ -2186,7 +2403,7 @@ testPlusEquals()
std::length_error); std::length_error);
} }
{ {
string_view s1("34"); string_like s1("34");
static_string<4> s2("12"); static_string<4> s2("12");
s2 += s1; s2 += s1;
BOOST_TEST(s2 == "1234"); BOOST_TEST(s2 == "1234");
@ -2222,6 +2439,7 @@ testCompare()
BOOST_TEST(s1.compare(0, 2, s2.data()) < 0); BOOST_TEST(s1.compare(0, 2, s2.data()) < 0);
BOOST_TEST(s2.compare(0, 1, s1.data()) > 0); BOOST_TEST(s2.compare(0, 1, s1.data()) > 0);
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
BOOST_TEST(s1.compare(s2.subview()) < 0); BOOST_TEST(s1.compare(s2.subview()) < 0);
BOOST_TEST(s2.compare(s1.subview()) > 0); BOOST_TEST(s2.compare(s1.subview()) > 0);
@ -2230,6 +2448,7 @@ testCompare()
BOOST_TEST(s1.compare(0, 2, s2.subview(), 0, 1) < 0); BOOST_TEST(s1.compare(0, 2, s2.subview(), 0, 1) < 0);
BOOST_TEST(s2.compare(0, 1, s1.subview(), 0, 2) > 0); BOOST_TEST(s2.compare(0, 1, s1.subview(), 0, 2) > 0);
#endif
BOOST_TEST(s1 < "10"); BOOST_TEST(s1 < "10");
BOOST_TEST(s2 > "1"); BOOST_TEST(s2 > "1");
@ -2238,6 +2457,14 @@ testCompare()
BOOST_TEST(s1 < "20"); BOOST_TEST(s1 < "20");
BOOST_TEST(s2 > "1"); BOOST_TEST(s2 > "1");
BOOST_TEST(s2 > "2"); BOOST_TEST(s2 > "2");
BOOST_TEST(s1 < string_like("10"));
BOOST_TEST(s2 > string_like("1"));
BOOST_TEST(string_like("10") > s1);
BOOST_TEST(string_like("1") < s2);
BOOST_TEST(s1 < string_like("20"));
BOOST_TEST(s2 > string_like("1"));
BOOST_TEST(s2 > string_like("2"));
} }
{ {
str2 s1("x"); str2 s1("x");
@ -2273,6 +2500,19 @@ testCompare()
BOOST_TEST(! ("x" < s)); BOOST_TEST(! ("x" < s));
BOOST_TEST(! ("x" > s)); BOOST_TEST(! ("x" > s));
BOOST_TEST(! ("x" != s)); BOOST_TEST(! ("x" != s));
BOOST_TEST(s == string_like("x"));
BOOST_TEST(s <= string_like("x"));
BOOST_TEST(s >= string_like("x"));
BOOST_TEST(! (s < string_like("x")));
BOOST_TEST(! (s > string_like("x")));
BOOST_TEST(! (s != string_like("x")));
BOOST_TEST(string_like("x") == s);
BOOST_TEST(string_like("x") <= s);
BOOST_TEST(string_like("x") >= s);
BOOST_TEST(! (string_like("x") < s));
BOOST_TEST(! (string_like("x") > s));
BOOST_TEST(! (string_like("x") != s));
} }
{ {
str2 s("x"); str2 s("x");
@ -2288,6 +2528,19 @@ testCompare()
BOOST_TEST(! ("y" == s)); BOOST_TEST(! ("y" == s));
BOOST_TEST(! ("y" <= s)); BOOST_TEST(! ("y" <= s));
BOOST_TEST(! ("y" < s)); BOOST_TEST(! ("y" < s));
BOOST_TEST(s <= string_like("y"));
BOOST_TEST(s < string_like("y"));
BOOST_TEST(s != string_like("y"));
BOOST_TEST(! (s == string_like("y")));
BOOST_TEST(! (s >= string_like("y")));
BOOST_TEST(! (s > "x"));
BOOST_TEST(string_like("y") >= s);
BOOST_TEST(string_like("y") > s);
BOOST_TEST(string_like("y") != s);
BOOST_TEST(! (string_like("y") == s));
BOOST_TEST(! (string_like("y") <= s));
BOOST_TEST(! (string_like("y") < s));
} }
{ {
str1 s1("x"); str1 s1("x");
@ -3683,16 +3936,16 @@ testGeneral()
void void
testToStaticString() testToStaticString()
{ {
BOOST_TEST(testTS(0, "0", L"0", true)); BOOST_TEST(testTS(0, "0", true));
BOOST_TEST(testTS(0u, "0", L"0", true)); BOOST_TEST(testTS(0u, "0", true));
BOOST_TEST(testTS(0xffff, "65535", L"65535", true)); BOOST_TEST(testTS(0xffff, "65535", true));
BOOST_TEST(testTS(0x10000, "65536", L"65536", true)); BOOST_TEST(testTS(0x10000, "65536", true));
BOOST_TEST(testTS(0xffffffff, "4294967295", L"4294967295", true)); BOOST_TEST(testTS(0xffffffff, "4294967295", true));
BOOST_TEST(testTS(-65535, "-65535", L"-65535", true)); BOOST_TEST(testTS(-65535, "-65535", true));
BOOST_TEST(testTS(-65536, "-65536", L"-65536", true)); BOOST_TEST(testTS(-65536, "-65536", true));
BOOST_TEST(testTS(-4294967295ll, "-4294967295", L"-4294967295", true)); BOOST_TEST(testTS(-4294967295ll, "-4294967295", true));
BOOST_TEST(testTS(1, "1", L"1", true)); BOOST_TEST(testTS(1, "1", true));
BOOST_TEST(testTS(-1, "-1", L"-1", true)); BOOST_TEST(testTS(-1, "-1", true));
BOOST_TEST(testTS(0.1)); BOOST_TEST(testTS(0.1));
BOOST_TEST(testTS(0.0000001)); BOOST_TEST(testTS(0.0000001));
BOOST_TEST(testTS(-0.0000001)); BOOST_TEST(testTS(-0.0000001));
@ -3708,7 +3961,7 @@ testToStaticString()
BOOST_TEST(testTS(std::numeric_limits<unsigned long long>::max())); BOOST_TEST(testTS(std::numeric_limits<unsigned long long>::max()));
BOOST_TEST(testTS(std::numeric_limits<long double>::min())); BOOST_TEST(testTS(std::numeric_limits<long double>::min()));
BOOST_TEST(testTS(std::numeric_limits<float>::min())); BOOST_TEST(testTS(std::numeric_limits<float>::min()));
// these tests technically are not portable, but they will work // these tests technically are not portable, but they will work
// 99% of the time. // 99% of the time.
{ {
@ -3726,6 +3979,35 @@ testToStaticString()
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == "infinity" || str == "inf"); static_string<0>::npos || str == "infinity" || str == "inf");
} }
#ifdef BOOST_STATIC_STRING_HAS_WCHAR
BOOST_TEST(testTWS(0, L"0", true));
BOOST_TEST(testTWS(0u, L"0", true));
BOOST_TEST(testTWS(0xffff, L"65535", true));
BOOST_TEST(testTWS(0x10000, L"65536", true));
BOOST_TEST(testTWS(0xffffffff, L"4294967295", true));
BOOST_TEST(testTWS(-65535, L"-65535", true));
BOOST_TEST(testTWS(-65536, L"-65536", true));
BOOST_TEST(testTWS(-4294967295ll, L"-4294967295", true));
BOOST_TEST(testTWS(1, L"1", true));
BOOST_TEST(testTWS(-1, L"-1", true));
BOOST_TEST(testTWS(0.1));
BOOST_TEST(testTWS(0.0000001));
BOOST_TEST(testTWS(-0.0000001));
BOOST_TEST(testTWS(-0.1));
BOOST_TEST(testTWS(1234567890.0001));
BOOST_TEST(testTWS(1.123456789012345));
BOOST_TEST(testTWS(-1234567890.1234));
BOOST_TEST(testTWS(-1.123456789012345));
BOOST_TEST(testTWS(std::numeric_limits<long long>::max()));
BOOST_TEST(testTWS(std::numeric_limits<long long>::min()));
BOOST_TEST(testTWS(std::numeric_limits<unsigned long long>::max()));
BOOST_TEST(testTWS(std::numeric_limits<unsigned long long>::max()));
BOOST_TEST(testTWS(std::numeric_limits<long double>::min()));
BOOST_TEST(testTWS(std::numeric_limits<float>::min()));
{ {
auto str = to_static_wstring(std::numeric_limits<float>::max()); auto str = to_static_wstring(std::numeric_limits<float>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
@ -3741,6 +4023,7 @@ testToStaticString()
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == L"infinity" || str == L"inf"); static_string<0>::npos || str == L"infinity" || str == L"inf");
} }
#endif
} }
// done // done
@ -3749,8 +4032,8 @@ testFind()
{ {
const char* cs1 = "12345"; const char* cs1 = "12345";
const char* cs2 = "2345"; const char* cs2 = "2345";
string_view v1 = cs1; string_like v1 = cs1;
string_view v2 = cs2; string_like v2 = cs2;
static_string<5> fs1 = cs1; static_string<5> fs1 = cs1;
static_string<4> fs2 = cs2; static_string<4> fs2 = cs2;
using S = static_string<400>; using S = static_string<400>;
@ -4090,7 +4373,7 @@ testFind()
BOOST_TEST(fs1.rfind(cs1, 0) == 0); BOOST_TEST(fs1.rfind(cs1, 0) == 0);
BOOST_TEST(fs1.rfind(cs2, 0) == S::npos); BOOST_TEST(fs1.rfind(cs2, 0) == S::npos);
BOOST_TEST(fs1.rfind(cs2, 0, 2) == S::npos); BOOST_TEST(fs1.rfind(cs2, 0, 2) == S::npos);
BOOST_TEST(fs1.rfind(cs1, 4) == 0); BOOST_TEST(fs1.rfind(cs1, 4) == 0);
@ -5068,13 +5351,13 @@ testFind()
// find_first_not_of // find_first_not_of
const char* cs3 = "12456"; const char* cs3 = "12456";
const char* cs4 = "2356"; const char* cs4 = "2356";
string_view v3 = cs3; string_like v3 = cs3;
string_view v4 = cs4; string_like v4 = cs4;
static_string<5> fs3 = cs3; static_string<5> fs3 = cs3;
static_string<4> fs4 = cs4; static_string<4> fs4 = cs4;
@ -5768,11 +6051,16 @@ testFind()
#include <iostream> #include <iostream>
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic push // false positives
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
// done // done
void void
testReplace() testReplace()
{ {
// replace(size_type pos1, size_type n1, const charT* s, size_type n2); // replace(size_type pos1, size_type n1, const charT* s, size_type n2);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(5, 2, fs1.data() + 1, 8) == "helloelloworlrld"); BOOST_TEST(fs1.replace(5, 2, fs1.data() + 1, 8) == "helloelloworlrld");
@ -5854,12 +6142,12 @@ testReplace()
// replace(size_type pos1, size_type n1, const T& t); // replace(size_type pos1, size_type n1, const T& t);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(0, fs1.size(), string_view(fs1)) == "helloworld"); BOOST_TEST(fs1.replace(0, fs1.size(), string_like(fs1.data(), fs1.size())) == "helloworld");
} }
// replace(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2 = npos); // replace(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2 = npos);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(0, fs1.size(), string_view(fs1), 0, fs1.size()) == "helloworld"); BOOST_TEST(fs1.replace(0, fs1.size(), string_like(fs1.data(), fs1.size()), 0, fs1.size()) == "helloworld");
} }
// replace(size_type pos, size_type n, const charT * s); // replace(size_type pos, size_type n, const charT * s);
{ {
@ -5885,7 +6173,7 @@ testReplace()
// replace(const_iterator i1, const_iterator i2, const T& t); // replace(const_iterator i1, const_iterator i2, const T& t);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(fs1.begin(), fs1.end(), string_view(fs1)) == "helloworld"); BOOST_TEST(fs1.replace(fs1.begin(), fs1.end(), string_like(fs1.data(), fs1.size())) == "helloworld");
} }
// replace(const_iterator i1, const_iterator i2, const charT* s, size_type n); // replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
{ {
@ -5917,7 +6205,7 @@ testReplace()
std::stringstream a("defghi"); std::stringstream a("defghi");
static_string<30> b = "abcabcdefjklmnop"; static_string<30> b = "abcabcdefjklmnop";
BOOST_TEST(b.replace(b.begin() + 3, b.begin() + 9, BOOST_TEST(b.replace(b.begin() + 3, b.begin() + 9,
std::istream_iterator<char>(a), std::istream_iterator<char>(a),
std::istream_iterator<char>()) == std::istream_iterator<char>()) ==
"abcdefghijklmnop"); "abcdefghijklmnop");
} }
@ -6130,7 +6418,7 @@ testReplace()
BOOST_TEST(testR(S("abcde"), 5, 1, 5, '2', S("abcde22222"))); BOOST_TEST(testR(S("abcde"), 5, 1, 5, '2', S("abcde22222")));
BOOST_TEST(testR(S("abcde"), 5, 1, 10, '2', S("abcde2222222222"))); BOOST_TEST(testR(S("abcde"), 5, 1, 10, '2', S("abcde2222222222")));
BOOST_TEST(testR(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222"))); BOOST_TEST(testR(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222")));
BOOST_TEST(testR(S("abcde"), 0, 4, "12345", 4, S("1234e"))); BOOST_TEST(testR(S("abcde"), 0, 4, "12345", 4, S("1234e")));
BOOST_TEST(testR(S("abcde"), 0, 4, "12345", 5, S("12345e"))); BOOST_TEST(testR(S("abcde"), 0, 4, "12345", 5, S("12345e")));
BOOST_TEST(testR(S("abcde"), 0, 4, "1234567890", 0, S("e"))); BOOST_TEST(testR(S("abcde"), 0, 4, "1234567890", 0, S("e")));
@ -6772,6 +7060,10 @@ testReplace()
BOOST_TEST_THROWS(T("aaaaa").replace(0, 1, S("bbbbbbbbbbbbb")), std::length_error); BOOST_TEST_THROWS(T("aaaaa").replace(0, 1, S("bbbbbbbbbbbbb")), std::length_error);
} }
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
// done // done
void void
testSubstr() testSubstr()
@ -7028,21 +7320,21 @@ testStartsEnds()
BOOST_TEST(S("1234567890").starts_with("1234567890")); BOOST_TEST(S("1234567890").starts_with("1234567890"));
BOOST_TEST(!S("1234567890").starts_with("234")); BOOST_TEST(!S("1234567890").starts_with("234"));
BOOST_TEST(!S("1234567890").starts_with("12345678900")); BOOST_TEST(!S("1234567890").starts_with("12345678900"));
BOOST_TEST(S("1234567890").starts_with(string_view("1234567890"))); BOOST_TEST(S("1234567890").starts_with(string_like("1234567890")));
BOOST_TEST(S("1234567890").ends_with('0')); BOOST_TEST(S("1234567890").ends_with('0'));
BOOST_TEST(S("1234567890").ends_with("890")); BOOST_TEST(S("1234567890").ends_with("890"));
BOOST_TEST(S("1234567890").ends_with("1234567890")); BOOST_TEST(S("1234567890").ends_with("1234567890"));
BOOST_TEST(!S("1234567890").ends_with("234")); BOOST_TEST(!S("1234567890").ends_with("234"));
BOOST_TEST(!S("1234567890").ends_with("12345678900")); BOOST_TEST(!S("1234567890").ends_with("12345678900"));
BOOST_TEST(S("1234567890").ends_with(string_view("1234567890"))); BOOST_TEST(S("1234567890").ends_with(string_like("1234567890")));
BOOST_TEST(!S().starts_with('0')); BOOST_TEST(!S().starts_with('0'));
BOOST_TEST(!S().starts_with("0")); BOOST_TEST(!S().starts_with("0"));
BOOST_TEST(!S().starts_with(string_view("0"))); BOOST_TEST(!S().starts_with(string_like("0")));
BOOST_TEST(!S().ends_with('0')); BOOST_TEST(!S().ends_with('0'));
BOOST_TEST(!S().ends_with("0")); BOOST_TEST(!S().ends_with("0"));
BOOST_TEST(!S().ends_with(string_view("0"))); BOOST_TEST(!S().ends_with(string_like("0")));
} }
void void
@ -7083,7 +7375,9 @@ testStream()
static_string<10> b = "abcdefghij"; static_string<10> b = "abcdefghij";
a << b; a << b;
static_string<10> c(std::istream_iterator<char>{a}, std::istream_iterator<char>{}); static_string<10> c(std::istream_iterator<char>{a}, std::istream_iterator<char>{});
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
BOOST_TEST(a.str() == b.subview()); BOOST_TEST(a.str() == b.subview());
#endif
BOOST_TEST(b == c); BOOST_TEST(b == c);
} }
@ -7152,6 +7446,15 @@ testOperatorPlus()
} }
} }
// issue 47
struct issue_47 : static_string<32>
{
bool compare(const issue_47& other) const
{
return *this < other;
}
};
int int
runTests() runTests()
{ {
@ -7159,18 +7462,19 @@ runTests()
static_cast<void>(cxper); static_cast<void>(cxper);
testConstruct(); testConstruct();
testAssignment(); testAssignment();
testElements(); testElements();
testIterators(); testIterators();
testCapacity(); testCapacity();
testClear(); testClear();
testInsert(); testInsert();
testErase(); testErase();
testEraseIf();
testPushBack(); testPushBack();
testPopBack(); testPopBack();
testAppend(); testAppend();
@ -7202,4 +7506,5 @@ int
main() main()
{ {
return boost::static_strings::runTests(); return boost::static_strings::runTests();
} }