mirror of
https://github.com/boostorg/static_string.git
synced 2026-01-19 16:52:11 +00:00
Compare commits
62 Commits
boost-1.82
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9313dc331 | ||
|
|
0c5e5b8e58 | ||
|
|
6f0c00b268 | ||
|
|
2175496c55 | ||
|
|
aee3c62957 | ||
|
|
0e28b358dc | ||
|
|
4dcfb39494 | ||
|
|
4bf6461ca1 | ||
|
|
67efdf6a9b | ||
|
|
3a410b8472 | ||
|
|
bf988466f8 | ||
|
|
a526ebd1f6 | ||
|
|
2f8c7a69ea | ||
|
|
c915934529 | ||
|
|
10b5491104 | ||
|
|
a58319dbdd | ||
|
|
4c84b61975 | ||
|
|
fbd6051165 | ||
|
|
db1ea76a17 | ||
|
|
ee172b86fd | ||
|
|
bd3dd01259 | ||
|
|
a841869405 | ||
|
|
3613e9578d | ||
|
|
6f17b60377 | ||
|
|
815678e1e7 | ||
|
|
2cc22bf5a8 | ||
|
|
d6f976a7df | ||
|
|
7b564d8d26 | ||
|
|
3c37deed99 | ||
|
|
34ef5c45be | ||
|
|
0f34644488 | ||
|
|
4c27826548 | ||
|
|
9c5d69475d | ||
|
|
300781d954 | ||
|
|
cd1a1a41c3 | ||
|
|
0d255f7438 | ||
|
|
17d77ef5bb | ||
|
|
20afd07676 | ||
|
|
7f903ef7ce | ||
|
|
5dfbb1f2b1 | ||
|
|
37a557d937 | ||
|
|
cd546285c4 | ||
|
|
645bf0a27d | ||
|
|
5067dfce5f | ||
|
|
d37197d773 | ||
|
|
a421cf742c | ||
|
|
7a53b7ff20 | ||
|
|
24d62635a3 | ||
|
|
a8f671ea1e | ||
|
|
d677c9436c | ||
|
|
a3cc7bcf95 | ||
|
|
70578731e7 | ||
|
|
3fb22ed769 | ||
|
|
32824bfa1d | ||
|
|
f15a4d0586 | ||
|
|
cd5bc51e9e | ||
|
|
77d6a43dce | ||
|
|
8f969a62f7 | ||
|
|
bff5cb65a5 | ||
|
|
42bb99ed25 | ||
|
|
175f467a03 | ||
|
|
6275cd7fe3 |
@@ -107,10 +107,10 @@ environment:
|
||||
B2_CXXSTD: 11,14,1z
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: mingw32
|
||||
- FLAVOR: mingw64 (32-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
ADDPATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;
|
||||
B2_ADDRESS_MODEL: 32
|
||||
ADDPATH: C:\mingw\bin;
|
||||
B2_CXXSTD: 11,14,17,2a
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
|
||||
202
.drone.star
202
.drone.star
@@ -2,116 +2,116 @@
|
||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE.txt)
|
||||
#
|
||||
# Copyright Rene Rivera 2020.
|
||||
# Copyright Alan de Freitas 2022.
|
||||
|
||||
# Copyright (c) 2020 Rene Rivera
|
||||
# Copyright (c) 2022 Alan de Freitas
|
||||
# Copyright (c) 2022-2025 Alexander Grund
|
||||
|
||||
# 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"
|
||||
|
||||
# Base environment for all jobs
|
||||
globalenv={'B2_VARIANT': 'release'}
|
||||
|
||||
# Wrapper function to apply the globalenv to all jobs
|
||||
def job(
|
||||
# job specific environment options
|
||||
env={},
|
||||
**kwargs):
|
||||
real_env = dict(globalenv)
|
||||
real_env.update(env)
|
||||
return job_impl(env=real_env, **kwargs)
|
||||
|
||||
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)
|
||||
job(compiler='clang-3.8', cxxstd='11,14', os='ubuntu-16.04'),
|
||||
job(compiler='clang-3.9', cxxstd='11,14', os='ubuntu-18.04'),
|
||||
job(compiler='clang-4.0', cxxstd='11,14', os='ubuntu-18.04'),
|
||||
job(compiler='clang-5.0', cxxstd='11,14,1z', os='ubuntu-18.04'),
|
||||
job(compiler='clang-6.0', cxxstd='11,14,17', os='ubuntu-18.04'),
|
||||
job(compiler='clang-7', cxxstd='11,14,17', os='ubuntu-18.04'),
|
||||
job(compiler='clang-8', cxxstd='11,14,17,2a', os='ubuntu-18.04'),
|
||||
job(compiler='clang-9', cxxstd='11,14,17,2a', os='ubuntu-18.04'),
|
||||
job(compiler='clang-10', cxxstd='11,14,17,2a', os='ubuntu-18.04'),
|
||||
job(compiler='clang-11', cxxstd='11,14,17,2a', os='ubuntu-22.04'),
|
||||
job(compiler='clang-12', cxxstd='11,14,17,20', os='ubuntu-22.04'),
|
||||
job(compiler='clang-13', cxxstd='11,14,17,20,2b', os='ubuntu-22.04'),
|
||||
job(compiler='clang-14', cxxstd='11,14,17,20,2b', os='ubuntu-22.04'),
|
||||
job(compiler='clang-15', cxxstd='11,14,17,20,2b', os='ubuntu-22.04', add_llvm=True,
|
||||
env={'B2_CXXFLAGS': '-Werror'}),
|
||||
job(name='Clang 15 standalone', compiler='clang-15', cxxstd='17,20,2b', os='ubuntu-22.04', add_llvm=True,
|
||||
env={'B2_CXXFLAGS': '-Werror', 'B2_DEFINES': 'BOOST_STATIC_STRING_STANDALONE'}),
|
||||
|
||||
# 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),
|
||||
job(compiler='gcc-4.8', cxxstd='11', os='ubuntu-16.04'),
|
||||
job(compiler='gcc-4.9', cxxstd='11', os='ubuntu-16.04'),
|
||||
job(compiler='gcc-5', cxxstd='11,14,1z', os='ubuntu-18.04'),
|
||||
job(compiler='gcc-6', cxxstd='11,14,1z', os='ubuntu-18.04'),
|
||||
job(compiler='gcc-7', cxxstd='11,14,1z', os='ubuntu-18.04'),
|
||||
job(compiler='gcc-8', cxxstd='11,14,17,2a', os='ubuntu-18.04'),
|
||||
job(compiler='gcc-9', cxxstd='11,14,17,2a', os='ubuntu-18.04'),
|
||||
job(compiler='gcc-10', cxxstd='11,14,17,20', os='ubuntu-22.04'),
|
||||
job(compiler='gcc-11', cxxstd='11,14,17,20,2b', os='ubuntu-22.04'),
|
||||
job(compiler='gcc-12', cxxstd='11,14,17,20,2b', os='ubuntu-22.04'),
|
||||
|
||||
# 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),
|
||||
job(name='Coverage', buildtype='codecov', buildscript='codecov_coveralls', env={'LCOV_BRANCH_COVERAGE': 1, "COVERALLS_REPO_TOKEN": {"from_secret": "coveralls_repo_token"}},
|
||||
compiler='gcc-8', cxxstd='11,14,17,2a', os='ubuntu-18.04'),
|
||||
# Sanitizers
|
||||
job(name='ASAN', asan=True,
|
||||
compiler='gcc-12', cxxstd='11,14,17,20', os='ubuntu-22.04'),
|
||||
job(name='UBSAN', ubsan=True,
|
||||
compiler='gcc-12', cxxstd='11,14,17,20', os='ubuntu-22.04'),
|
||||
job(name='TSAN', tsan=True,
|
||||
compiler='gcc-12', cxxstd='11,14,17,20', os='ubuntu-22.04'),
|
||||
job(name='Clang 14 w/ sanitizers', asan=True, ubsan=True,
|
||||
compiler='clang-14', cxxstd='11,14,17,20', os='ubuntu-22.04'),
|
||||
job(name='Clang 11 libc++ w/ sanitizers', asan=True, ubsan=True, # libc++-11 is the latest working with ASAN: https://github.com/llvm/llvm-project/issues/59432
|
||||
compiler='clang-11', cxxstd='11,14,17,20', os='ubuntu-20.04', stdlib='libc++', install='libc++-11-dev libc++abi-11-dev'),
|
||||
job(name='Valgrind', valgrind=True,
|
||||
compiler='clang-6.0', cxxstd='11,14,1z', os='ubuntu-18.04', install='libc6-dbg libc++-dev libstdc++-8-dev'),
|
||||
|
||||
# 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),
|
||||
# libc++
|
||||
job(compiler='clang-6.0', cxxstd='11,14,17,2a', os='ubuntu-18.04', stdlib='libc++', install='libc++-dev libc++abi-dev'),
|
||||
job(compiler='clang-7', cxxstd='11,14,17,2a', os='ubuntu-20.04', stdlib='libc++', install='libc++-7-dev libc++abi-7-dev'),
|
||||
job(compiler='clang-8', cxxstd='11,14,17,2a', os='ubuntu-20.04', stdlib='libc++', install='libc++-8-dev libc++abi-8-dev'),
|
||||
job(compiler='clang-9', cxxstd='11,14,17,2a', os='ubuntu-20.04', stdlib='libc++', install='libc++-9-dev libc++abi-9-dev'),
|
||||
job(compiler='clang-10', cxxstd='11,14,17,20', os='ubuntu-20.04', stdlib='libc++', install='libc++-10-dev libc++abi-10-dev'),
|
||||
job(compiler='clang-11', cxxstd='11,14,17,20', os='ubuntu-20.04', stdlib='libc++', install='libc++-11-dev libc++abi-11-dev'),
|
||||
job(compiler='clang-12', cxxstd='11,14,17,20', os='ubuntu-22.04', stdlib='libc++', install='libc++-12-dev libc++abi-12-dev libunwind-12-dev'),
|
||||
job(compiler='clang-13', cxxstd='11,14,17,20', os='ubuntu-22.04', stdlib='libc++', install='libc++-13-dev libc++abi-13-dev'),
|
||||
job(compiler='clang-14', cxxstd='11,14,17,20', os='ubuntu-22.04', stdlib='libc++', install='libc++-14-dev libc++abi-14-dev'),
|
||||
job(compiler='clang-15', cxxstd='11,14,17,20', os='ubuntu-22.04', stdlib='libc++', install='libc++-15-dev libc++abi-15-dev', add_llvm=True),
|
||||
|
||||
# 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),
|
||||
]
|
||||
# FreeBSD
|
||||
job(compiler='clang-10', cxxstd='11,14,17,20', os='freebsd-13.1'),
|
||||
job(compiler='clang-15', cxxstd='11,14,17,20', os='freebsd-13.1'),
|
||||
job(compiler='gcc-11', cxxstd='11,14,17,20', os='freebsd-13.1', linkflags='-Wl,-rpath=/usr/local/lib/gcc11'),
|
||||
# OSX
|
||||
job(compiler='clang', cxxstd='11,14,17,2a', os='osx-xcode-10.1'),
|
||||
job(compiler='clang', cxxstd='11,14,17,2a', os='osx-xcode-10.3'),
|
||||
job(compiler='clang', cxxstd='11,14,17,2a', os='osx-xcode-11.1'),
|
||||
job(compiler='clang', cxxstd='11,14,17,2a', os='osx-xcode-11.7'),
|
||||
job(compiler='clang', cxxstd='11,14,17,2a', os='osx-xcode-12'),
|
||||
job(compiler='clang', cxxstd='11,14,17,20', os='osx-xcode-12.5.1'),
|
||||
job(compiler='clang', cxxstd='11,14,17,20', os='osx-xcode-13.0'),
|
||||
job(compiler='clang', cxxstd='11,14,17,20', os='osx-xcode-13.4.1'),
|
||||
job(compiler='clang', cxxstd='11,14,17,20,2b', os='osx-xcode-14.0'),
|
||||
job(compiler='clang', cxxstd='11,14,17,20,2b', os='osx-xcode-14.3.1'),
|
||||
job(compiler='clang', cxxstd='11,14,17,20,2b', os='osx-xcode-15.0.1'),
|
||||
# ARM64
|
||||
job(compiler='clang-12', cxxstd='11,14,17,20', os='ubuntu-20.04', arch='arm64', add_llvm=True),
|
||||
job(compiler='gcc-11', cxxstd='11,14,17,20', os='ubuntu-20.04', arch='arm64'),
|
||||
# S390x
|
||||
job(compiler='clang-12', cxxstd='11,14,17,20', os='ubuntu-20.04', arch='s390x', add_llvm=True),
|
||||
job(compiler='gcc-11', cxxstd='11,14,17,20', os='ubuntu-20.04', arch='s390x'),
|
||||
# Windows
|
||||
job(compiler='msvc-14.0', cxxstd=None, os='windows', env={'B2_DONT_EMBED_MANIFEST': 1}),
|
||||
job(compiler='msvc-14.1', cxxstd=None, os='windows'),
|
||||
job(compiler='msvc-14.2', cxxstd=None, os='windows'),
|
||||
job(compiler='msvc-14.3', cxxstd=None, os='windows'),
|
||||
job(compiler='msvc-14.0', cxxstd='14,17,20', os='windows', env={'B2_DONT_EMBED_MANIFEST': 1}),
|
||||
job(compiler='msvc-14.1', cxxstd='14,17,20', os='windows'),
|
||||
job(compiler='msvc-14.2', cxxstd='14,17,20', os='windows'),
|
||||
job(compiler='msvc-14.3', cxxstd='14,17,20,latest', os='windows'),
|
||||
]
|
||||
|
||||
# from https://github.com/boostorg/boost-ci
|
||||
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")
|
||||
load("@boost_ci//ci/drone/:functions.star", "linux_cxx", "windows_cxx", "osx_cxx", "freebsd_cxx", "job_impl")
|
||||
|
||||
28
.drone/codecov_coveralls.sh
Normal file
28
.drone/codecov_coveralls.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2020 Rene Rivera, Sam Darwin
|
||||
# Copyright 2025 Alexander Grund
|
||||
# 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
|
||||
|
||||
# Run the regular Boost CI script which does the test & upload to codecov.io
|
||||
wget https://github.com/boostorg/boost-ci/raw/refs/heads/master/.drone/drone.sh
|
||||
. drone.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
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
@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
236
.drone/drone.sh
@@ -1,236 +0,0 @@
|
||||
#!/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
|
||||
540
.github/workflows/ci.yml
vendored
540
.github/workflows/ci.yml
vendored
@@ -1,10 +1,19 @@
|
||||
#
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021 Andrey Semashev
|
||||
# Copyright 2022 Alan de Freitas
|
||||
# Copyright 2021-2025 Alexander Grund
|
||||
# Copyright 2022-2025 James E. King III
|
||||
#
|
||||
# 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)
|
||||
|
||||
#
|
||||
# This workflow uses the Boost.CI reusable workflow which builds a variety of
|
||||
# configurations of your project, runs tests, and generates code coverage reports.
|
||||
#
|
||||
# To use it, copy this file into your repository as `.github/workflows/ci.yml` and
|
||||
# customize it appropriately.
|
||||
#
|
||||
---
|
||||
name: CI
|
||||
|
||||
on:
|
||||
@@ -13,510 +22,29 @@ on:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- bugfix/**
|
||||
- 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
|
||||
- fix/**
|
||||
- github/**
|
||||
- pr/**
|
||||
paths-ignore:
|
||||
- LICENSE
|
||||
- meta/**
|
||||
- README.md
|
||||
|
||||
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
|
||||
# mkdir -p libs/$LIBRARY
|
||||
# cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
# git submodule update --init tools/boostdep
|
||||
git submodule update --init --recursive
|
||||
mkdir -p libs/$SELF
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$SELF
|
||||
|
||||
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}}
|
||||
call-boost-ci:
|
||||
name: Run Boost.CI
|
||||
uses: boostorg/boost-ci/.github/workflows/reusable.yml@master
|
||||
with:
|
||||
exclude_cxxstd: '98,03,0x'
|
||||
enable_pr_coverage: false
|
||||
enable_multiarch: false
|
||||
# Example of customization:
|
||||
# with:
|
||||
# enable_reflection: true
|
||||
# enable_windows: false
|
||||
# secrets:
|
||||
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
# COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
|
||||
# COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
|
||||
156
.github/workflows/example.yml
vendored
Normal file
156
.github/workflows/example.yml
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
#
|
||||
# Copyright (c) 2025 Gennaro Prota (gennaro dot prota at gmail dot com)
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/static_string
|
||||
#
|
||||
|
||||
name: Example (basic_static_cstring)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- bugfix/**
|
||||
- feature/**
|
||||
- fix/**
|
||||
- github/**
|
||||
- pr/**
|
||||
paths-ignore:
|
||||
- LICENSE
|
||||
- meta/**
|
||||
- README.md
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { toolset: gcc-13, cxxstd: '20,23' }
|
||||
- { toolset: gcc-14, cxxstd: '20,23,26' }
|
||||
- { toolset: clang-17, cxxstd: '20,23' }
|
||||
- { toolset: clang-18, cxxstd: '20,23,26' }
|
||||
|
||||
steps:
|
||||
- name: Checkout Boost super-project
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: boostorg/boost
|
||||
ref: develop
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout this library
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: libs/static_string
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Initialize Boost submodules
|
||||
run: |
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args '--jobs 4' static_string
|
||||
|
||||
- name: Bootstrap b2
|
||||
run: ./bootstrap.sh
|
||||
|
||||
- name: Generate Boost headers
|
||||
run: ./b2 headers
|
||||
|
||||
- name: Build and run example tests
|
||||
run: |
|
||||
./b2 libs/static_string/example/static_cstring \
|
||||
toolset=${{ matrix.toolset }} \
|
||||
cxxstd=${{ matrix.cxxstd }} \
|
||||
variant=debug,release \
|
||||
-j$(nproc)
|
||||
|
||||
macos:
|
||||
runs-on: macos-14
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { toolset: clang, cxxstd: '20,23' }
|
||||
|
||||
steps:
|
||||
- name: Checkout Boost super-project
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: boostorg/boost
|
||||
ref: develop
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout this library
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: libs/static_string
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Initialize Boost submodules
|
||||
run: |
|
||||
git submodule update --init tools/boostdep
|
||||
python3 tools/boostdep/depinst/depinst.py --git_args '--jobs 4' static_string
|
||||
|
||||
- name: Bootstrap b2
|
||||
run: ./bootstrap.sh
|
||||
|
||||
- name: Generate Boost headers
|
||||
run: ./b2 headers
|
||||
|
||||
- name: Build and run example tests
|
||||
run: |
|
||||
./b2 libs/static_string/example/static_cstring \
|
||||
toolset=${{ matrix.toolset }} \
|
||||
cxxstd=${{ matrix.cxxstd }} \
|
||||
variant=debug,release \
|
||||
-j$(sysctl -n hw.ncpu)
|
||||
|
||||
windows:
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { toolset: msvc-14.3, cxxstd: '20,latest' }
|
||||
|
||||
steps:
|
||||
- name: Checkout Boost super-project
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: boostorg/boost
|
||||
ref: develop
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout this library
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: libs/static_string
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Initialize Boost submodules
|
||||
run: |
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args '--jobs 4' static_string
|
||||
|
||||
- name: Bootstrap b2
|
||||
run: .\bootstrap.bat
|
||||
shell: cmd
|
||||
|
||||
- name: Generate Boost headers
|
||||
run: .\b2 headers
|
||||
shell: cmd
|
||||
|
||||
- name: Build and run example tests
|
||||
run: |
|
||||
.\b2 libs/static_string/example/static_cstring ^
|
||||
toolset=${{ matrix.toolset }} ^
|
||||
cxxstd=${{ matrix.cxxstd }} ^
|
||||
variant=debug,release ^
|
||||
address-model=64
|
||||
shell: cmd
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,8 +1,15 @@
|
||||
bin/
|
||||
bin64/
|
||||
build/
|
||||
|
||||
# Because of CMake and VS2017
|
||||
Win32/
|
||||
x64/
|
||||
.vs/
|
||||
out/
|
||||
out/
|
||||
|
||||
# VS CMake settings
|
||||
/CMakeSettings.json
|
||||
# CMake presets
|
||||
/CMakePresets.json
|
||||
/CMakeUserPresets.json
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# Official repository: https://github.com/boostorg/static_string
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
cmake_minimum_required(VERSION 3.8...3.16)
|
||||
|
||||
project(boost_static_string VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
@@ -23,7 +23,7 @@ endif ()
|
||||
# Options
|
||||
if (NOT BOOST_SUPERPROJECT_VERSION)
|
||||
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" ${BUILD_TESTING})
|
||||
option(BOOST_STATIC_STRING_BUILD_TESTS "Build boost::static_string tests" OFF)
|
||||
else ()
|
||||
set(BOOST_STATIC_STRING_BUILD_TESTS ${BUILD_TESTING})
|
||||
endif ()
|
||||
@@ -45,7 +45,7 @@ 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_INCLUDE_LIBRARIES static_string assert container_hash 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)
|
||||
@@ -90,7 +90,6 @@ else ()
|
||||
Boost::assert
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
Boost::utility
|
||||
)
|
||||
@@ -112,7 +111,7 @@ if (BOOST_STATIC_STRING_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
|
||||
endif ()
|
||||
|
||||
|
||||
if (BOOST_STATIC_STRING_BUILD_TESTS)
|
||||
if (BUILD_TESTING OR BOOST_STATIC_STRING_BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif ()
|
||||
|
||||
|
||||
10
Jamfile
10
Jamfile
@@ -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 ;
|
||||
@@ -1,9 +1,9 @@
|
||||
# Boost.StaticString
|
||||
|
||||
Branch | Travis | Appveyor | Azure Pipelines | codecov.io | Docs | Matrix |
|
||||
Branch | GHA CI | Appveyor | Azure Pipelines | codecov.io | Docs | Matrix |
|
||||
:-------------: | ------ | -------- | --------------- | ---------- | ---- | ------ |
|
||||
[`master`](https://github.com/boostorg/static_string/tree/master) | [](https://travis-ci.org/boostorg/static_string) | [](https://ci.appveyor.com/project/sdkrystian/static-string/branch/master) | [](https://krystiands.visualstudio.com/static_string/_build/latest?definitionId=3&branchName=master) | [](https://codecov.io/gh/boostorg/static_string/branch/master) | [](http://www.boost.org/doc/libs/release/libs/static_string) | [](http://www.boost.org/development/tests/master/developer/static_string.html)
|
||||
[`develop`](https://github.com/boostorg/static_string/tree/develop) | [](https://travis-ci.org/boostorg/static_string) | [](https://ci.appveyor.com/project/sdkrystian/static-string/branch/develop) | [](https://krystiands.visualstudio.com/static_string/_build/latest?definitionId=3&branchName=develop) | [](https://codecov.io/gh/boostorg/static_string/branch/develop) | [](http://www.boost.org/doc/libs/develop/libs/static_string) | [](http://www.boost.org/development/tests/develop/developer/static_string.html)
|
||||
[`master`](https://github.com/boostorg/static_string/tree/master) | [](https://github.com/boostorg/static_string/actions?query=branch:master) | [](https://ci.appveyor.com/project/sdkrystian/static-string/branch/master) | [](https://krystiands.visualstudio.com/static_string/_build/latest?definitionId=3&branchName=master) | [](https://codecov.io/gh/boostorg/static_string/branch/master) | [](http://www.boost.org/doc/libs/release/libs/static_string) | [](https://regression.boost.org/master/developer/static_string.html)
|
||||
[`develop`](https://github.com/boostorg/static_string/tree/develop) | [](https://github.com/boostorg/static_string/actions?query=branch:develop) | [](https://ci.appveyor.com/project/sdkrystian/static-string/branch/develop) | [](https://krystiands.visualstudio.com/static_string/_build/latest?definitionId=3&branchName=develop) | [](https://codecov.io/gh/boostorg/static_string/branch/develop) | [](http://www.boost.org/doc/libs/develop/libs/static_string) | [](https://regression.boost.org/develop/developer/static_string.html)
|
||||
|
||||
## Introduction
|
||||
|
||||
|
||||
27
build.jam
Normal file
27
build.jam
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/assert//boost_assert
|
||||
/boost/config//boost_config
|
||||
/boost/container_hash//boost_container_hash
|
||||
/boost/core//boost_core
|
||||
/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
|
||||
;
|
||||
|
||||
28
doc/Jamfile
28
doc/Jamfile
@@ -9,21 +9,21 @@
|
||||
|
||||
project static_string/doc ;
|
||||
|
||||
import boostbook ;
|
||||
import type ;
|
||||
import os ;
|
||||
import ../../../tools/docca/docca.jam ;
|
||||
import-search /boost/docca ;
|
||||
|
||||
docca.reference reference.qbk
|
||||
import docca ;
|
||||
import path ;
|
||||
import os ;
|
||||
|
||||
local include-prefix = [ path.root $(__file__:D) [ path.pwd ] ] ;
|
||||
include-prefix = [ path.native $(include-prefix:D)/include ] ;
|
||||
|
||||
docca.pyreference reference.qbk
|
||||
:
|
||||
xsl/custom-overrides.xsl
|
||||
[ glob-tree-ex ../include/boost/static_string : *.hpp *.ipp : detail impl ]
|
||||
externals.hpp
|
||||
:
|
||||
<doxygen:param>PROJECT_NAME=StaticString
|
||||
<doxygen:param>PROJECT_BRIEF="Static String Library"
|
||||
<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
|
||||
@@ -40,19 +40,17 @@ docca.reference reference.qbk
|
||||
<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>STRIP_FROM_PATH=$(include-prefix)
|
||||
|
||||
# <doxygen:param>ALLOW_UNICODE_NAMES=NO
|
||||
# <doxygen:param>GROUP_NESTED_COMPOUNDS=NO
|
||||
# <doxygen:param>HIDE_COMPOUND_REFERENCE=NO
|
||||
# <doxygen:param>WARN_AS_ERROR=NO
|
||||
|
||||
<docca:config>config.json
|
||||
;
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
12
doc/config.json
Normal file
12
doc/config.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"include_private": false,
|
||||
"legacy_behavior": false,
|
||||
"external_marker": "!EXTERNAL!",
|
||||
"link_prefix": "static_string.ref.",
|
||||
"default_namespace": "boost::static_strings",
|
||||
"allowed_prefixes": ["boost::static_strings::", "std::"],
|
||||
"convenience_header": "boost/static_string.hpp",
|
||||
"replace_strings": {
|
||||
"__see_below__": "``['see-below]``"
|
||||
}
|
||||
}
|
||||
64
doc/externals.hpp
Normal file
64
doc/externals.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
namespace boost {
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://www.boost.org/doc/libs/release/libs/utility/doc/html/utility/utilities/string_view.html
|
||||
template <class T, class Traits>
|
||||
struct basic_string_view {};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
namespace std {
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/iterator/reverse_iterator
|
||||
template <class T>
|
||||
struct reverse_iterator {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/types/size_t
|
||||
struct size_t {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/types/integer
|
||||
struct uint64_t {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/types/integer
|
||||
struct int64_t {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/types/nullptr_t
|
||||
struct nullptr_t {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/types/ptrdiff_t
|
||||
struct ptrdiff_t {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/utility/initializer_list
|
||||
template <class T>
|
||||
struct initializer_list {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/io/basic_ostream
|
||||
template <class T, class Traits>
|
||||
struct basic_ostream {};
|
||||
|
||||
/// !EXTERNAL!
|
||||
///
|
||||
/// @see https://en.cppreference.com/w/cpp/types/numeric_limits
|
||||
template <class T>
|
||||
struct numeric_limits {};
|
||||
|
||||
} // namespace std
|
||||
@@ -1,11 +0,0 @@
|
||||
<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>
|
||||
19
example/static_cstring/Jamfile
Normal file
19
example/static_cstring/Jamfile
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (c) 2025 Gennaro Prota (gennaro dot prota at gmail dot com)
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/static_string
|
||||
#
|
||||
|
||||
import testing ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<include>../../include
|
||||
<warnings>extra
|
||||
<cxxstd>20
|
||||
;
|
||||
|
||||
run static_cstring_test.cpp ;
|
||||
13
example/static_cstring/README.md
Normal file
13
example/static_cstring/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
This directory contains an experimental implementation of `basic_static_cstring`, which differs from `basic_static_string` in the following ways:
|
||||
|
||||
| | `basic_static_cstring` | `basic_static_string` |
|
||||
|---------------------|------------------------|-----------------------|
|
||||
| Layout | `sizeof == N + 1` | Has size member |
|
||||
| Embedded NULs | Not supported | Supported |
|
||||
| Trivially copyable | Yes | No |
|
||||
|
||||
Additionally, when `N <= UCHAR_MAX`, `basic_static_cstring` employs an optimization that avoids calling `std::strlen()` to compute the size.
|
||||
|
||||
This work stems from [boostorg/static_string#23](https://github.com/boostorg/static_string/issues/23).
|
||||
|
||||
If you believe `basic_static_cstring` should become part of the public API, please share your feedback on the Boost mailing list.
|
||||
441
example/static_cstring/static_cstring.hpp
Normal file
441
example/static_cstring/static_cstring.hpp
Normal file
@@ -0,0 +1,441 @@
|
||||
//
|
||||
// Copyright (c) 2025 Gennaro Prota (gennaro dot prota at gmail dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/static_string
|
||||
//
|
||||
|
||||
#ifndef BOOST_STATIC_STRING_STATIC_CSTRING_HPP
|
||||
#define BOOST_STATIC_STRING_STATIC_CSTRING_HPP
|
||||
|
||||
#include <boost/static_string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace static_strings {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Primary template: No remaining-capacity trick; uses traits::length() for length.
|
||||
template<std::size_t N, typename CharT, typename Traits, bool UseRemaining>
|
||||
class static_cstring_base
|
||||
{
|
||||
public:
|
||||
using traits_type = Traits;
|
||||
using value_type = CharT;
|
||||
using size_type = std::size_t;
|
||||
|
||||
value_type data_[N + 1]{};
|
||||
|
||||
constexpr size_type get_size() const noexcept
|
||||
{
|
||||
return traits_type::length(data_);
|
||||
}
|
||||
|
||||
constexpr void set_size(size_type sz) noexcept
|
||||
{
|
||||
data_[sz] = value_type{};
|
||||
}
|
||||
|
||||
// Defaulted comparisons for structural type support.
|
||||
constexpr bool operator==(const static_cstring_base&) const noexcept = default;
|
||||
constexpr auto operator<=>(const static_cstring_base&) const noexcept = default;
|
||||
};
|
||||
|
||||
// Specialization for N <= UCHAR_MAX: Uses remaining-capacity trick.
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
class static_cstring_base<N, CharT, Traits, true>
|
||||
{
|
||||
public:
|
||||
using traits_type = Traits;
|
||||
using value_type = CharT;
|
||||
using size_type = std::size_t;
|
||||
|
||||
value_type data_[N + 1]{};
|
||||
|
||||
constexpr size_type get_size() const noexcept
|
||||
{
|
||||
return N - static_cast<unsigned char>(data_[N]);
|
||||
}
|
||||
|
||||
constexpr void set_size(size_type sz) noexcept
|
||||
{
|
||||
data_[sz] = value_type{};
|
||||
data_[N] = static_cast<value_type>(N - sz);
|
||||
}
|
||||
|
||||
// Defaulted comparisons for structural type support.
|
||||
constexpr bool operator==(const static_cstring_base&) const noexcept = default;
|
||||
constexpr auto operator<=>(const static_cstring_base&) const noexcept = default;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<std::size_t N, typename CharT = char, typename Traits = std::char_traits<CharT>>
|
||||
class basic_static_cstring
|
||||
: public detail::static_cstring_base<N, CharT, Traits, (N <= UCHAR_MAX)>
|
||||
{
|
||||
public:
|
||||
using base = detail::static_cstring_base<N, CharT, Traits, (N <= UCHAR_MAX)>;
|
||||
using base::data_;
|
||||
using base::get_size;
|
||||
using base::set_size;
|
||||
|
||||
// Member types
|
||||
using traits_type = Traits;
|
||||
using value_type = CharT;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using iterator = pointer;
|
||||
using const_iterator = const_pointer;
|
||||
|
||||
static constexpr size_type npos = static_cast<size_type>(-1);
|
||||
static constexpr size_type static_capacity = N;
|
||||
|
||||
// Constructors.
|
||||
constexpr basic_static_cstring() noexcept
|
||||
{
|
||||
set_size(0);
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring(const CharT* s)
|
||||
{
|
||||
assign(s);
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring(const CharT* s, size_type count)
|
||||
{
|
||||
assign(s, count);
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring(size_type count, CharT ch)
|
||||
{
|
||||
assign(count, ch);
|
||||
}
|
||||
|
||||
template<std::size_t M>
|
||||
constexpr basic_static_cstring(const CharT (&arr)[M])
|
||||
{
|
||||
static_assert(M <= N + 1, "String literal too long for static_cstring");
|
||||
assign(arr, M - 1);
|
||||
}
|
||||
|
||||
constexpr size_type size() const noexcept
|
||||
{
|
||||
return get_size();
|
||||
}
|
||||
|
||||
constexpr size_type length() const noexcept
|
||||
{
|
||||
return size();
|
||||
}
|
||||
|
||||
constexpr bool empty() const noexcept
|
||||
{
|
||||
return data_[0] == value_type{};
|
||||
}
|
||||
|
||||
static constexpr size_type max_size() noexcept
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
static constexpr size_type capacity() noexcept
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
// Element access.
|
||||
constexpr reference operator[](size_type pos) noexcept
|
||||
{
|
||||
return data_[pos];
|
||||
}
|
||||
|
||||
constexpr const_reference operator[](size_type pos) const noexcept
|
||||
{
|
||||
return data_[pos];
|
||||
}
|
||||
|
||||
constexpr reference at(size_type pos)
|
||||
{
|
||||
if (pos >= size())
|
||||
{
|
||||
throw std::out_of_range("static_cstring::at");
|
||||
}
|
||||
return data_[pos];
|
||||
}
|
||||
|
||||
constexpr const_reference at(size_type pos) const
|
||||
{
|
||||
if (pos >= size())
|
||||
{
|
||||
throw std::out_of_range("static_cstring::at");
|
||||
}
|
||||
return data_[pos];
|
||||
}
|
||||
|
||||
constexpr reference front() noexcept
|
||||
{
|
||||
BOOST_STATIC_STRING_ASSERT(!empty());
|
||||
return data_[0];
|
||||
}
|
||||
|
||||
constexpr const_reference front() const noexcept
|
||||
{
|
||||
BOOST_STATIC_STRING_ASSERT(!empty());
|
||||
return data_[0];
|
||||
}
|
||||
|
||||
constexpr reference back() noexcept
|
||||
{
|
||||
BOOST_STATIC_STRING_ASSERT(!empty());
|
||||
return data_[size() - 1];
|
||||
}
|
||||
|
||||
constexpr const_reference back() const noexcept
|
||||
{
|
||||
BOOST_STATIC_STRING_ASSERT(!empty());
|
||||
return data_[size() - 1];
|
||||
}
|
||||
|
||||
constexpr pointer data() noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
constexpr const_pointer data() const noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
constexpr const_pointer c_str() const noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
// Iterators.
|
||||
constexpr iterator begin() noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
constexpr const_iterator begin() const noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
constexpr const_iterator cbegin() const noexcept
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
constexpr iterator end() noexcept
|
||||
{
|
||||
return data_ + size();
|
||||
}
|
||||
|
||||
constexpr const_iterator end() const noexcept
|
||||
{
|
||||
return data_ + size();
|
||||
}
|
||||
|
||||
constexpr const_iterator cend() const noexcept
|
||||
{
|
||||
return data_ + size();
|
||||
}
|
||||
|
||||
// Modifiers.
|
||||
constexpr void clear() noexcept
|
||||
{
|
||||
set_size(0);
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& assign(const CharT* s)
|
||||
{
|
||||
return assign(s, traits_type::length(s));
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& assign(const CharT* s, size_type count)
|
||||
{
|
||||
if (count > N)
|
||||
{
|
||||
throw std::length_error("static_cstring::assign");
|
||||
}
|
||||
traits_type::copy(data_, s, count);
|
||||
set_size(count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& assign(size_type count, CharT ch)
|
||||
{
|
||||
if (count > N)
|
||||
{
|
||||
throw std::length_error("static_cstring::assign");
|
||||
}
|
||||
traits_type::assign(data_, count, ch);
|
||||
set_size(count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& operator=(const CharT* s)
|
||||
{
|
||||
return assign(s);
|
||||
}
|
||||
|
||||
constexpr void push_back(CharT ch)
|
||||
{
|
||||
const size_type sz = size();
|
||||
if (sz >= N)
|
||||
{
|
||||
throw std::length_error("static_cstring::push_back");
|
||||
}
|
||||
data_[sz] = ch;
|
||||
set_size(sz + 1);
|
||||
}
|
||||
|
||||
constexpr void pop_back() noexcept
|
||||
{
|
||||
BOOST_STATIC_STRING_ASSERT(!empty());
|
||||
set_size(size() - 1);
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& append(const CharT* s)
|
||||
{
|
||||
return append(s, traits_type::length(s));
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& append(const CharT* s, size_type count)
|
||||
{
|
||||
const size_type sz = size();
|
||||
if (sz + count > N)
|
||||
{
|
||||
throw std::length_error("static_cstring::append");
|
||||
}
|
||||
traits_type::copy(data_ + sz, s, count);
|
||||
set_size(sz + count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& append(size_type count, CharT ch)
|
||||
{
|
||||
const size_type sz = size();
|
||||
if (sz + count > N)
|
||||
{
|
||||
throw std::length_error("static_cstring::append");
|
||||
}
|
||||
traits_type::assign(data_ + sz, count, ch);
|
||||
set_size(sz + count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& operator+=(const CharT* s)
|
||||
{
|
||||
return append(s);
|
||||
}
|
||||
|
||||
constexpr basic_static_cstring& operator+=(CharT ch)
|
||||
{
|
||||
push_back(ch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Comparisons.
|
||||
constexpr int compare(const basic_static_cstring& other) const noexcept
|
||||
{
|
||||
const size_type lhs_sz = size();
|
||||
const size_type rhs_sz = other.size();
|
||||
const int result = traits_type::compare(data_, other.data_, (std::min)(lhs_sz, rhs_sz));
|
||||
|
||||
return result != 0
|
||||
? result
|
||||
: lhs_sz < rhs_sz
|
||||
? -1
|
||||
: lhs_sz > rhs_sz
|
||||
? 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
constexpr int compare(const CharT* s) const noexcept
|
||||
{
|
||||
return compare(basic_static_cstring(s));
|
||||
}
|
||||
|
||||
// Conversions.
|
||||
constexpr operator std::basic_string_view<CharT, Traits>() const noexcept
|
||||
{
|
||||
return {data_, size()};
|
||||
}
|
||||
|
||||
std::basic_string<CharT, Traits> str() const
|
||||
{
|
||||
return {data_, size()};
|
||||
}
|
||||
|
||||
// Swap.
|
||||
constexpr void swap(basic_static_cstring& other) noexcept
|
||||
{
|
||||
basic_static_cstring tmp = *this;
|
||||
*this = other;
|
||||
other = tmp;
|
||||
}
|
||||
|
||||
// Defaulted comparisons for structural type (C++20).
|
||||
constexpr bool operator==(const basic_static_cstring&) const noexcept = default;
|
||||
constexpr auto operator<=>(const basic_static_cstring&) const noexcept = default;
|
||||
};
|
||||
|
||||
#if defined(BOOST_STATIC_STRING_USE_DEDUCT)
|
||||
|
||||
// Deduction guide.
|
||||
template<std::size_t N, typename CharT>
|
||||
basic_static_cstring(const CharT(&)[N]) -> basic_static_cstring<N - 1, CharT>;
|
||||
|
||||
#endif
|
||||
|
||||
// Comparison with const CharT*.
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
constexpr bool operator==(const basic_static_cstring<N, CharT, Traits>& lhs,
|
||||
const CharT* rhs) noexcept
|
||||
{
|
||||
return lhs.compare(rhs) == 0;
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
constexpr bool operator==(const CharT* lhs,
|
||||
const basic_static_cstring<N, CharT, Traits>& rhs) noexcept
|
||||
{
|
||||
return rhs.compare(lhs) == 0;
|
||||
}
|
||||
|
||||
// Stream output.
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
|
||||
const basic_static_cstring<N, CharT, Traits>& str)
|
||||
{
|
||||
return os << str.c_str();
|
||||
}
|
||||
|
||||
// Alias templates.
|
||||
template<std::size_t N>
|
||||
using static_cstring = basic_static_cstring<N, char>;
|
||||
|
||||
template<std::size_t N>
|
||||
using static_wcstring = basic_static_cstring<N, wchar_t>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
671
example/static_cstring/static_cstring_test.cpp
Normal file
671
example/static_cstring/static_cstring_test.cpp
Normal file
@@ -0,0 +1,671 @@
|
||||
//
|
||||
// Copyright (c) 2025 Gennaro Prota (gennaro dot prota at gmail dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/static_string
|
||||
//
|
||||
|
||||
#include "static_cstring.hpp"
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace static_strings {
|
||||
|
||||
static
|
||||
void
|
||||
testCStringSizeGuarantee()
|
||||
{
|
||||
// Core guarantee: sizeof is exactly N + 1 (no size member).
|
||||
static_assert(sizeof(static_cstring<0>) == 1, "");
|
||||
static_assert(sizeof(static_cstring<1>) == 2, "");
|
||||
static_assert(sizeof(static_cstring<10>) == 11, "");
|
||||
static_assert(sizeof(static_cstring<63>) == 64, "");
|
||||
static_assert(sizeof(static_cstring<64>) == 65, "");
|
||||
static_assert(sizeof(static_cstring<127>) == 128, "");
|
||||
static_assert(sizeof(static_cstring<UCHAR_MAX>) == (UCHAR_MAX + 1), "");
|
||||
static_assert(sizeof(static_cstring<UCHAR_MAX + 1>) == (UCHAR_MAX + 2), "");
|
||||
static_assert(sizeof(static_cstring<1000>) == 1001, "");
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringRemainingCapacityTrick()
|
||||
{
|
||||
// Test the remaining-capacity optimization for N <= UCHAR_MAX.
|
||||
|
||||
// Full capacity: Last byte is both null terminator AND remaining == 0.
|
||||
{
|
||||
static_cstring<5> full("12345");
|
||||
BOOST_TEST(full.size() == 5);
|
||||
BOOST_TEST(full.capacity() == 5);
|
||||
BOOST_TEST(full.data()[5] == '\0');
|
||||
BOOST_TEST(std::strcmp(full.c_str(), "12345") == 0);
|
||||
}
|
||||
|
||||
// Partial fill: Null terminator at position size, remaining at position N.
|
||||
{
|
||||
static_cstring<10> partial("Hi");
|
||||
BOOST_TEST(partial.size() == 2);
|
||||
BOOST_TEST(partial.capacity() == 10);
|
||||
BOOST_TEST(partial.data()[2] == '\0');
|
||||
BOOST_TEST(static_cast<unsigned char>(partial.data()[10]) == 8);
|
||||
}
|
||||
|
||||
// Empty string.
|
||||
{
|
||||
static_cstring<10> empty;
|
||||
BOOST_TEST(empty.size() == 0);
|
||||
BOOST_TEST(empty.capacity() == 10);
|
||||
BOOST_TEST(empty.data()[0] == '\0');
|
||||
BOOST_TEST(static_cast<unsigned char>(empty.data()[10]) == 10);
|
||||
}
|
||||
|
||||
// Edge case: N == UCHAR_MAX (max for our trick).
|
||||
{
|
||||
static_cstring<UCHAR_MAX> large;
|
||||
large.assign(100, 'x');
|
||||
BOOST_TEST(large.size() == 100);
|
||||
BOOST_TEST(large.capacity() == UCHAR_MAX);
|
||||
BOOST_TEST(static_cast<unsigned char>(large.data()[UCHAR_MAX]) == (UCHAR_MAX - large.size()));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
struct CStringTypeTraits
|
||||
{
|
||||
static_assert(std::is_trivially_copyable<S>::value);
|
||||
static_assert(std::is_trivially_copy_constructible<S>::value);
|
||||
static_assert(std::is_trivially_move_constructible<S>::value);
|
||||
static_assert(std::is_trivially_copy_assignable<S>::value);
|
||||
static_assert(std::is_trivially_move_assignable<S>::value);
|
||||
static_assert(std::is_trivially_destructible<S>::value);
|
||||
};
|
||||
|
||||
static
|
||||
void
|
||||
testCStringTypeTraits()
|
||||
{
|
||||
{
|
||||
using S = static_cstring<0>;
|
||||
CStringTypeTraits< S > check;
|
||||
static_cast<void>(check);
|
||||
}
|
||||
{
|
||||
using S = static_cstring<63>;
|
||||
CStringTypeTraits< S > check;
|
||||
static_cast<void>(check);
|
||||
}
|
||||
{
|
||||
using S = static_cstring<300>;
|
||||
CStringTypeTraits< S > check;
|
||||
static_cast<void>(check);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringConstruct()
|
||||
{
|
||||
// Default construction.
|
||||
{
|
||||
static_cstring<1> s;
|
||||
BOOST_TEST(s.empty());
|
||||
BOOST_TEST(s.size() == 0);
|
||||
BOOST_TEST(s == "");
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
}
|
||||
|
||||
// Construct with count and char.
|
||||
{
|
||||
static_cstring<4> s1(3, 'x');
|
||||
BOOST_TEST(!s1.empty());
|
||||
BOOST_TEST(s1.size() == 3);
|
||||
BOOST_TEST(s1 == "xxx");
|
||||
BOOST_TEST(*s1.end() == 0);
|
||||
BOOST_TEST_THROWS(
|
||||
(static_cstring<2>(3, 'x')),
|
||||
std::length_error);
|
||||
}
|
||||
|
||||
// Construct from a C string.
|
||||
{
|
||||
static_cstring<5> s1("12345");
|
||||
BOOST_TEST(s1.size() == 5);
|
||||
BOOST_TEST(s1 == "12345");
|
||||
BOOST_TEST(*s1.end() == 0);
|
||||
BOOST_TEST_THROWS(
|
||||
(static_cstring<4>("12345")),
|
||||
std::length_error);
|
||||
}
|
||||
|
||||
// Construct from a C string with count.
|
||||
{
|
||||
static_cstring<5> s1("UVXYZ", 3);
|
||||
BOOST_TEST(s1 == "UVX");
|
||||
BOOST_TEST(*s1.end() == 0);
|
||||
}
|
||||
|
||||
// Copy construction.
|
||||
{
|
||||
static_cstring<5> s1("12345");
|
||||
static_cstring<5> s2(s1);
|
||||
BOOST_TEST(s2 == "12345");
|
||||
BOOST_TEST(*s2.end() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringAssignment()
|
||||
{
|
||||
// assign(size_type count, CharT ch).
|
||||
BOOST_TEST(static_cstring<3>{}.assign(1, '*') == "*");
|
||||
BOOST_TEST(static_cstring<3>{}.assign(3, '*') == "***");
|
||||
BOOST_TEST(static_cstring<3>{"abc"}.assign(3, '*') == "***");
|
||||
BOOST_TEST_THROWS(static_cstring<1>{"a"}.assign(2, '*'), std::length_error);
|
||||
|
||||
// assign(CharT const* s, size_type count).
|
||||
BOOST_TEST(static_cstring<3>{}.assign("abc", 3) == "abc");
|
||||
BOOST_TEST(static_cstring<3>{"*"}.assign("abc", 3) == "abc");
|
||||
BOOST_TEST_THROWS(static_cstring<1>{}.assign("abc", 3), std::length_error);
|
||||
|
||||
// assign(CharT const* s).
|
||||
BOOST_TEST(static_cstring<3>{}.assign("abc") == "abc");
|
||||
BOOST_TEST(static_cstring<3>{"*"}.assign("abc") == "abc");
|
||||
BOOST_TEST_THROWS(static_cstring<1>{}.assign("abc"), std::length_error);
|
||||
|
||||
// operator=(const CharT* s).
|
||||
{
|
||||
static_cstring<3> s1;
|
||||
s1 = "123";
|
||||
BOOST_TEST(s1 == "123");
|
||||
BOOST_TEST(*s1.end() == 0);
|
||||
static_cstring<1> s2;
|
||||
BOOST_TEST_THROWS(
|
||||
s2 = "123",
|
||||
std::length_error);
|
||||
}
|
||||
|
||||
// Copy assignment.
|
||||
{
|
||||
static_cstring<3> s1("123");
|
||||
static_cstring<3> s2;
|
||||
s2 = s1;
|
||||
BOOST_TEST(s2 == "123");
|
||||
BOOST_TEST(*s2.end() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringElements()
|
||||
{
|
||||
using ccs3 = static_cstring<3> const;
|
||||
|
||||
// at(size_type pos).
|
||||
BOOST_TEST(static_cstring<3>{"abc"}.at(0) == 'a');
|
||||
BOOST_TEST(static_cstring<3>{"abc"}.at(2) == 'c');
|
||||
BOOST_TEST_THROWS(static_cstring<3>{""}.at(0), std::out_of_range);
|
||||
BOOST_TEST_THROWS(static_cstring<3>{"abc"}.at(4), std::out_of_range);
|
||||
|
||||
// at(size_type pos) const.
|
||||
BOOST_TEST(ccs3{"abc"}.at(0) == 'a');
|
||||
BOOST_TEST(ccs3{"abc"}.at(2) == 'c');
|
||||
BOOST_TEST_THROWS(ccs3{""}.at(0), std::out_of_range);
|
||||
|
||||
// operator[](size_type pos).
|
||||
BOOST_TEST(static_cstring<3>{"abc"}[0] == 'a');
|
||||
BOOST_TEST(static_cstring<3>{"abc"}[2] == 'c');
|
||||
BOOST_TEST(static_cstring<3>{"abc"}[3] == 0);
|
||||
BOOST_TEST(static_cstring<3>{""}[0] == 0);
|
||||
|
||||
// front() / back().
|
||||
BOOST_TEST(static_cstring<3>{"abc"}.front() == 'a');
|
||||
BOOST_TEST(static_cstring<3>{"abc"}.back() == 'c');
|
||||
|
||||
// data() / c_str().
|
||||
{
|
||||
static_cstring<3> s("123");
|
||||
BOOST_TEST(std::memcmp(s.data(), "123", 3) == 0);
|
||||
BOOST_TEST(std::memcmp(s.c_str(), "123\0", 4) == 0);
|
||||
}
|
||||
|
||||
// Modification through element access.
|
||||
{
|
||||
static_cstring<5> s("12345");
|
||||
s[1] = '_';
|
||||
BOOST_TEST(s == "1_345");
|
||||
s.front() = 'A';
|
||||
BOOST_TEST(s == "A_345");
|
||||
s.back() = 'Z';
|
||||
BOOST_TEST(s == "A_34Z");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringIterators()
|
||||
{
|
||||
{
|
||||
static_cstring<3> s;
|
||||
BOOST_TEST(std::distance(s.begin(), s.end()) == 0);
|
||||
s = "123";
|
||||
BOOST_TEST(std::distance(s.begin(), s.end()) == 3);
|
||||
}
|
||||
{
|
||||
static_cstring<3> const s("123");
|
||||
BOOST_TEST(std::distance(s.begin(), s.end()) == 3);
|
||||
BOOST_TEST(std::distance(s.cbegin(), s.cend()) == 3);
|
||||
}
|
||||
|
||||
// Iteration.
|
||||
{
|
||||
static_cstring<5> s("hello");
|
||||
std::string result;
|
||||
for (const char c : s)
|
||||
{
|
||||
result += c;
|
||||
}
|
||||
BOOST_TEST(result == "hello");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringCapacity()
|
||||
{
|
||||
// empty().
|
||||
BOOST_TEST(static_cstring<0>{}.empty());
|
||||
BOOST_TEST(static_cstring<1>{}.empty());
|
||||
BOOST_TEST(!static_cstring<1>{"a"}.empty());
|
||||
|
||||
// size().
|
||||
BOOST_TEST(static_cstring<0>{}.size() == 0);
|
||||
BOOST_TEST(static_cstring<1>{"a"}.size() == 1);
|
||||
BOOST_TEST(static_cstring<5>{"abc"}.size() == 3);
|
||||
|
||||
// length().
|
||||
BOOST_TEST(static_cstring<0>{}.length() == 0);
|
||||
BOOST_TEST(static_cstring<3>{"abc"}.length() == 3);
|
||||
|
||||
// max_size().
|
||||
BOOST_TEST(static_cstring<0>{}.max_size() == 0);
|
||||
BOOST_TEST(static_cstring<5>{"abc"}.max_size() == 5);
|
||||
|
||||
// capacity().
|
||||
BOOST_TEST(static_cstring<0>{}.capacity() == 0);
|
||||
BOOST_TEST(static_cstring<5>{"abc"}.capacity() == 5);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringClear()
|
||||
{
|
||||
static_cstring<3> s("123");
|
||||
BOOST_TEST(!s.empty());
|
||||
s.clear();
|
||||
BOOST_TEST(s.empty());
|
||||
BOOST_TEST(s.size() == 0);
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
BOOST_TEST(s == "");
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringPushPop()
|
||||
{
|
||||
// push_back().
|
||||
{
|
||||
static_cstring<5> s("abc");
|
||||
s.push_back('d');
|
||||
BOOST_TEST(s == "abcd");
|
||||
BOOST_TEST(s.size() == 4);
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
|
||||
s.push_back('e');
|
||||
BOOST_TEST(s == "abcde");
|
||||
BOOST_TEST(s.size() == 5);
|
||||
|
||||
BOOST_TEST_THROWS(s.push_back('f'), std::length_error);
|
||||
}
|
||||
|
||||
// pop_back().
|
||||
{
|
||||
static_cstring<5> s("abcde");
|
||||
s.pop_back();
|
||||
BOOST_TEST(s == "abcd");
|
||||
BOOST_TEST(s.size() == 4);
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
|
||||
s.pop_back();
|
||||
s.pop_back();
|
||||
s.pop_back();
|
||||
s.pop_back();
|
||||
BOOST_TEST(s.empty());
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringAppend()
|
||||
{
|
||||
// append(const CharT* s).
|
||||
{
|
||||
static_cstring<12> s("Hello");
|
||||
s.append(", World");
|
||||
BOOST_TEST(s == "Hello, World");
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
}
|
||||
{
|
||||
static_cstring<5> s("abc");
|
||||
BOOST_TEST_THROWS(s.append("def"), std::length_error);
|
||||
}
|
||||
|
||||
// append(const CharT* s, size_type count)
|
||||
{
|
||||
static_cstring<10> s("abc");
|
||||
s.append("defgh", 3);
|
||||
BOOST_TEST(s == "abcdef");
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
}
|
||||
|
||||
// append(size_type count, CharT ch)
|
||||
{
|
||||
static_cstring<10> s("abc");
|
||||
s.append(3, 'x');
|
||||
BOOST_TEST(s == "abcxxx");
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
BOOST_TEST_THROWS(s.append(5, 'y'), std::length_error);
|
||||
}
|
||||
|
||||
// operator+=()
|
||||
{
|
||||
static_cstring<10> s("abc");
|
||||
s += "def";
|
||||
BOOST_TEST(s == "abcdef");
|
||||
s += 'g';
|
||||
BOOST_TEST(s == "abcdefg");
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringComparison()
|
||||
{
|
||||
// operator==() / operator!=().
|
||||
{
|
||||
static_cstring<10> a("abc");
|
||||
static_cstring<10> b("abc");
|
||||
static_cstring<10> c("abd");
|
||||
|
||||
BOOST_TEST(a == b);
|
||||
BOOST_TEST(!(a == c));
|
||||
BOOST_TEST(a != c);
|
||||
BOOST_TEST(!(a != b));
|
||||
}
|
||||
|
||||
// operator<(), <=(), >(), >=().
|
||||
{
|
||||
static_cstring<10> a("abc");
|
||||
static_cstring<10> b("abd");
|
||||
|
||||
BOOST_TEST(a < b);
|
||||
BOOST_TEST(a <= b);
|
||||
BOOST_TEST(a <= a);
|
||||
BOOST_TEST(b > a);
|
||||
BOOST_TEST(b >= a);
|
||||
BOOST_TEST(b >= b);
|
||||
}
|
||||
|
||||
// Comparison with CharT const*.
|
||||
{
|
||||
static_cstring<10> s("hello");
|
||||
BOOST_TEST(s == "hello");
|
||||
BOOST_TEST("hello" == s);
|
||||
BOOST_TEST(s != "world");
|
||||
BOOST_TEST("world" != s);
|
||||
}
|
||||
|
||||
// compare().
|
||||
{
|
||||
static_cstring<10> s("abc");
|
||||
BOOST_TEST(s.compare("abc") == 0);
|
||||
BOOST_TEST(s.compare("abd") < 0);
|
||||
BOOST_TEST(s.compare("abb") > 0);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringConversion()
|
||||
{
|
||||
// operator string_view().
|
||||
{
|
||||
static_cstring<10> s("hello");
|
||||
std::string_view sv = s;
|
||||
BOOST_TEST(sv == "hello");
|
||||
BOOST_TEST(sv.size() == 5);
|
||||
}
|
||||
|
||||
// str().
|
||||
{
|
||||
static_cstring<10> s("hello");
|
||||
std::string str = s.str();
|
||||
BOOST_TEST(str == "hello");
|
||||
BOOST_TEST(str.size() == 5);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringStream()
|
||||
{
|
||||
static_cstring<10> s("hello");
|
||||
std::ostringstream oss;
|
||||
oss << s;
|
||||
BOOST_TEST(oss.str() == "hello");
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringSwap()
|
||||
{
|
||||
static_cstring<10> a("hello");
|
||||
static_cstring<10> b("world");
|
||||
|
||||
a.swap(b);
|
||||
|
||||
BOOST_TEST(a == "world");
|
||||
BOOST_TEST(b == "hello");
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringConstexpr()
|
||||
{
|
||||
// constexpr construction and operations.
|
||||
constexpr static_cstring<10> ce("test");
|
||||
static_assert(ce.size() == 4, "");
|
||||
static_assert(ce[0] == 't', "");
|
||||
static_assert(ce[1] == 'e', "");
|
||||
static_assert(ce[2] == 's', "");
|
||||
static_assert(ce[3] == 't', "");
|
||||
static_assert(!ce.empty(), "");
|
||||
static_assert(ce.max_size() == 10, "");
|
||||
static_assert(ce.capacity() == 10, "");
|
||||
|
||||
constexpr static_cstring<5> ce_empty;
|
||||
static_assert(ce_empty.empty(), "");
|
||||
static_assert(ce_empty.size() == 0, "");
|
||||
}
|
||||
|
||||
// Helper struct to test NTTP.
|
||||
template<basic_static_cstring S>
|
||||
struct NTTPHelper
|
||||
{
|
||||
static constexpr std::size_t size() noexcept
|
||||
{
|
||||
return S.size();
|
||||
}
|
||||
|
||||
static constexpr const char* c_str() noexcept
|
||||
{
|
||||
return S.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
static
|
||||
void
|
||||
testCStringNTTP()
|
||||
{
|
||||
// Test non-type template parameter usage (C++20).
|
||||
|
||||
// Test size deduction from string literals.
|
||||
BOOST_TEST(NTTPHelper<"hello">::size() == 5);
|
||||
BOOST_TEST(NTTPHelper<"">::size() == 0);
|
||||
BOOST_TEST(NTTPHelper<"test">::size() == 4);
|
||||
|
||||
// Test that different strings create different types
|
||||
constexpr bool same_type = std::is_same_v<
|
||||
NTTPHelper<"hello">,
|
||||
NTTPHelper<"hello">>;
|
||||
BOOST_TEST(same_type);
|
||||
|
||||
constexpr bool different_type = !std::is_same_v<
|
||||
NTTPHelper<"hello">,
|
||||
NTTPHelper<"world">>;
|
||||
BOOST_TEST(different_type);
|
||||
|
||||
// Test constexpr access.
|
||||
constexpr std::size_t len = NTTPHelper<"constexpr">::size();
|
||||
static_assert(len == 9, "");
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringPODUsage()
|
||||
{
|
||||
// Test usage in POD types (the original motivation).
|
||||
struct UserRecord
|
||||
{
|
||||
int id;
|
||||
static_cstring<63> name;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
static_assert(sizeof(static_cstring<63>) == 64, "");
|
||||
static_assert(std::is_trivially_copyable<UserRecord>::value, "");
|
||||
|
||||
UserRecord user{};
|
||||
user.id = 42;
|
||||
user.name = "Alice";
|
||||
user.flags = 0xFF;
|
||||
|
||||
BOOST_TEST(user.id == 42);
|
||||
BOOST_TEST(user.name.size() == 5);
|
||||
BOOST_TEST(user.name == "Alice");
|
||||
BOOST_TEST(user.flags == 0xFF);
|
||||
|
||||
// Copy the struct.
|
||||
UserRecord copy = user;
|
||||
BOOST_TEST(copy.name == "Alice");
|
||||
|
||||
// memcpy() should work.
|
||||
UserRecord memcpy_dest;
|
||||
std::memcpy(&memcpy_dest, &user, sizeof(UserRecord));
|
||||
BOOST_TEST(memcpy_dest.name == "Alice");
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringLargeCapacity()
|
||||
{
|
||||
// Test strings with N > UCHAR_MAX (no remaining-capacity trick).
|
||||
{
|
||||
static_cstring<300> s;
|
||||
BOOST_TEST(s.empty());
|
||||
BOOST_TEST(s.size() == 0);
|
||||
|
||||
s = "This is a test string";
|
||||
BOOST_TEST(s.size() == 21);
|
||||
BOOST_TEST(s == "This is a test string");
|
||||
|
||||
s.clear();
|
||||
BOOST_TEST(s.empty());
|
||||
}
|
||||
|
||||
// Large string operations.
|
||||
{
|
||||
static_cstring<500> s;
|
||||
s.assign(400, 'x');
|
||||
BOOST_TEST(s.size() == 400);
|
||||
BOOST_TEST(s[0] == 'x');
|
||||
BOOST_TEST(s[399] == 'x');
|
||||
BOOST_TEST(*s.end() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
testCStringWideChar()
|
||||
{
|
||||
// Test with wchar_t.
|
||||
{
|
||||
static_wcstring<10> ws;
|
||||
BOOST_TEST(ws.empty());
|
||||
BOOST_TEST(ws.size() == 0);
|
||||
}
|
||||
|
||||
{
|
||||
static_wcstring<10> ws(L"hello");
|
||||
BOOST_TEST(ws.size() == 5);
|
||||
BOOST_TEST(ws[0] == L'h');
|
||||
BOOST_TEST(ws[4] == L'o');
|
||||
BOOST_TEST(*ws.end() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
runTests()
|
||||
{
|
||||
testCStringSizeGuarantee();
|
||||
testCStringRemainingCapacityTrick();
|
||||
testCStringTypeTraits();
|
||||
testCStringConstruct();
|
||||
testCStringAssignment();
|
||||
testCStringElements();
|
||||
testCStringIterators();
|
||||
testCStringCapacity();
|
||||
testCStringClear();
|
||||
testCStringPushPop();
|
||||
testCStringAppend();
|
||||
testCStringComparison();
|
||||
testCStringConversion();
|
||||
testCStringStream();
|
||||
testCStringSwap();
|
||||
testCStringConstexpr();
|
||||
testCStringNTTP();
|
||||
testCStringPODUsage();
|
||||
testCStringLargeCapacity();
|
||||
testCStringWideChar();
|
||||
|
||||
return report_errors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
return boost::static_strings::runTests();
|
||||
}
|
||||
@@ -14,6 +14,17 @@
|
||||
// Are we dependent on Boost?
|
||||
// #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?
|
||||
#if __cpp_deduction_guides >= 201703L
|
||||
#define BOOST_STATIC_STRING_USE_DEDUCT
|
||||
@@ -128,9 +139,6 @@
|
||||
#ifndef BOOST_STATIC_STRING_THROW
|
||||
#define BOOST_STATIC_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex)
|
||||
#endif
|
||||
#ifndef BOOST_STATIC_STRING_STATIC_ASSERT
|
||||
#define BOOST_STATIC_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg)
|
||||
#endif
|
||||
#ifndef BOOST_STATIC_STRING_ASSERT
|
||||
#define BOOST_STATIC_STRING_ASSERT(cond) BOOST_ASSERT(cond)
|
||||
#endif
|
||||
@@ -138,9 +146,6 @@
|
||||
#ifndef BOOST_STATIC_STRING_THROW
|
||||
#define BOOST_STATIC_STRING_THROW(ex) throw ex
|
||||
#endif
|
||||
#ifndef BOOST_STATIC_STRING_STATIC_ASSERT
|
||||
#define BOOST_STATIC_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
|
||||
#endif
|
||||
#ifndef BOOST_STATIC_STRING_ASSERT
|
||||
#define BOOST_STATIC_STRING_ASSERT(cond) assert(cond)
|
||||
#endif
|
||||
@@ -150,7 +155,6 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/utility/string_view.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@@ -164,27 +168,31 @@
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(__has_include)
|
||||
# if !__has_include(<string_view>)
|
||||
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
|
||||
# endif
|
||||
/*
|
||||
* 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
|
||||
#elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||
# if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 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
|
||||
# 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
|
||||
# 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) || \
|
||||
@@ -228,6 +236,24 @@ defined(BOOST_STATIC_STRING_CPP14)
|
||||
#define BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR
|
||||
#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.
|
||||
@@ -249,4 +275,25 @@ using basic_string_view =
|
||||
} // boost
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if defined(__cpp_lib_to_string) && __cpp_lib_to_string >= 202306L // std::to_[w]string() redefined in terms of std::format()
|
||||
#define BOOST_STATIC_STRING_USE_STD_FORMAT
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 5) && (__GNUC__ <= 10) && !defined(__clang__)
|
||||
// Workaround for GCC complaining about nested classes being private.
|
||||
#define BOOST_STATIC_STRING_GCC_NESTED_CLASS_WORKAROUND public:
|
||||
#else
|
||||
#define BOOST_STATIC_STRING_GCC_NESTED_CLASS_WORKAROUND
|
||||
#endif
|
||||
|
||||
// GCC 9 incorrectly rejects the pointer equality comparison in
|
||||
// ptr_in_range() in constant expressions. GCC 10 and later handle
|
||||
// it correctly.
|
||||
//
|
||||
// Clang 3.7 and 9-19 have the same issue.
|
||||
#if (defined(__GNUC__) && !defined(__clang__) && (__GNUC__ == 9)) \
|
||||
|| (defined(__clang__) && ((__clang_major__ == 3 && __clang_minor__ == 7) || ((__clang_major__ >= 9) && (__clang_major__ <= 19))))
|
||||
#define BOOST_STATIC_STRING_CONSTEXPR_PTR_CMP_BROKEN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,12 +7,13 @@
|
||||
],
|
||||
"description": "A fixed capacity dynamically sized string.",
|
||||
"category": [
|
||||
"Container",
|
||||
"Containers",
|
||||
"String"
|
||||
],
|
||||
"maintainers": [
|
||||
"Alan de Freitas <alandefreitas@gmail.com>",
|
||||
"Vinnie Falco <vinnie.falco@gmail.com>"
|
||||
"Vinnie Falco <vinnie.falco@gmail.com>",
|
||||
"Gennaro Prota <gennaro.prota@gmail.com>"
|
||||
],
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
# Official repository: https://github.com/boostorg/static_string
|
||||
#
|
||||
|
||||
# Custom target used by the boost super-project
|
||||
if(NOT TARGET tests)
|
||||
add_custom_target(tests)
|
||||
set_property(TARGET tests PROPERTY FOLDER _deps)
|
||||
endif()
|
||||
|
||||
set(BOOST_STATIC_STRING_TESTS_FILES
|
||||
CMakeLists.txt
|
||||
Jamfile
|
||||
@@ -23,3 +29,4 @@ add_executable(boost_static_string_tests ${BOOST_STATIC_STRING_TESTS_FILES})
|
||||
# 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)
|
||||
|
||||
@@ -8,18 +8,21 @@
|
||||
#
|
||||
|
||||
import testing ;
|
||||
import ../../config/checks/config : requires ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
|
||||
local defines =
|
||||
[ requires
|
||||
cxx11_constexpr
|
||||
cxx11_decltype
|
||||
cxx11_hdr_tuple
|
||||
cxx11_hdr_type_traits
|
||||
cxx11_template_aliases
|
||||
cxx11_variadic_templates
|
||||
]
|
||||
;
|
||||
|
||||
project : requirements $(defines) ;
|
||||
project : requirements $(defines)
|
||||
<library>/boost/static_string//boost_static_string ;
|
||||
|
||||
run static_string.cpp ;
|
||||
|
||||
24
test/cmake_test/CMakeLists.txt
Normal file
24
test/cmake_test/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
# Copyright 2021-2025 Alexander Grund
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.8...3.16)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
# Those 2 should work the same
|
||||
# while using find_package for the installed Boost avoids the need to manually specify dependencies
|
||||
if(BOOST_CI_INSTALL_TEST)
|
||||
find_package(boost_static_string REQUIRED)
|
||||
else()
|
||||
set(BOOST_INCLUDE_LIBRARIES static_string)
|
||||
add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::static_string)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME main COMMAND main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
18
test/cmake_test/main.cpp
Normal file
18
test/cmake_test/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright (c) 2025 Alexander Grund
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <boost/static_string.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Smoke test only
|
||||
boost::static_string<1> s_empty;
|
||||
boost::static_string<4> s_3(3, 'x');
|
||||
return (s_empty.empty() && s_3.size() == 3) ? 0 : 1;
|
||||
}
|
||||
@@ -4,16 +4,6 @@
|
||||
namespace boost {
|
||||
namespace static_strings {
|
||||
|
||||
static_assert(std::is_base_of<
|
||||
detail::static_string_base<0, char, std::char_traits<char>>,
|
||||
static_string<0>>::value,
|
||||
"the zero size optimization shall be used for N = 0");
|
||||
|
||||
static_assert(std::is_base_of<
|
||||
detail::static_string_base<(std::numeric_limits<char>::max)() + 1, char, std::char_traits<char>>,
|
||||
static_string<(std::numeric_limits<char>::max)() + 1>>::value,
|
||||
"the minimum size type optimization shall be used for N > 0");
|
||||
|
||||
static_assert(!detail::is_input_iterator<int>::value, "is_input_iterator is incorrect");
|
||||
static_assert(!detail::is_input_iterator<double>::value, "is_input_iterator is incorrect");
|
||||
static_assert(detail::is_input_iterator<int*>::value, "is_input_iterator is incorrect");
|
||||
|
||||
@@ -22,38 +22,77 @@ struct cxper_char_traits
|
||||
using int_type = int;
|
||||
using state_type = std::mbstate_t;
|
||||
|
||||
static constexpr void assign(char_type& a, const char_type& b) noexcept { a = b; }
|
||||
static constexpr bool eq(char_type a, char_type b) noexcept { return a == b; }
|
||||
static constexpr bool lt(char_type a, char_type b) noexcept { return a < b; }
|
||||
static constexpr void assign(char_type& a, const char_type& b) noexcept
|
||||
{
|
||||
a = b;
|
||||
}
|
||||
|
||||
static constexpr bool eq(char_type a, char_type b) noexcept
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
static constexpr bool lt(char_type a, char_type b) noexcept
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
|
||||
static constexpr int compare(const char_type* a, const char_type* b, std::size_t n)
|
||||
{
|
||||
for (; n--; ++a, ++b)
|
||||
{
|
||||
if(lt(*a, *b))
|
||||
return 1;
|
||||
else if(lt(*b, *a))
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static constexpr int compare(const char_type*, const char_type*, std::size_t) { return 0; }
|
||||
static constexpr std::size_t length(const char_type* s)
|
||||
{
|
||||
std::size_t n = 0;
|
||||
while (*(s++));
|
||||
return n;
|
||||
auto ptr = s;
|
||||
while (!eq(*ptr, char_type()))
|
||||
++ptr;
|
||||
return ptr - s;
|
||||
}
|
||||
static constexpr const char_type* find(const char_type*, std::size_t, const char_type&){ return 0; }
|
||||
|
||||
static constexpr const char_type* find(const char_type* s, std::size_t n, const char_type& ch)
|
||||
{
|
||||
for (; n--; ++s)
|
||||
{
|
||||
if (eq(*s, ch))
|
||||
return s;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static constexpr char_type* move(char_type* dest, const char_type* src, std::size_t n)
|
||||
{
|
||||
const auto temp = dest;
|
||||
while (n--)
|
||||
*(dest++) = *(src++);
|
||||
return temp;
|
||||
// This implementation does not handle overlapping ranges where
|
||||
// dest > src. A correct implementation would need to detect this
|
||||
// case and copy backwards, but detecting overlap requires pointer
|
||||
// comparisons that many of the tested compiles (incorrectly) refuse
|
||||
// in constant expressions.
|
||||
//
|
||||
// Since cxper_char_traits is only used for testing constexpr
|
||||
// functionality and the tests do not exercise overlapping moves
|
||||
// where dest > src, this simple forward copy is sufficient.
|
||||
return copy(dest, src, n);
|
||||
}
|
||||
|
||||
static constexpr char_type* copy(char_type* dest, const char_type* src, std::size_t n)
|
||||
{
|
||||
const auto temp = dest;
|
||||
while (n--)
|
||||
*(dest++) = *(src++);
|
||||
return temp;
|
||||
for (auto ptr = dest; n--;)
|
||||
assign(*ptr++, *src++);
|
||||
return dest;
|
||||
}
|
||||
|
||||
static constexpr char_type* assign(char_type* dest, std::size_t n, char_type ch)
|
||||
{
|
||||
const auto temp = dest;
|
||||
while (n--)
|
||||
*(dest++) = ch;
|
||||
return temp;
|
||||
for (auto ptr = dest; n--;)
|
||||
assign(*ptr++, ch);
|
||||
return dest;
|
||||
}
|
||||
};
|
||||
#else
|
||||
@@ -67,6 +106,23 @@ bool
|
||||
testConstantEvaluation()
|
||||
{
|
||||
#ifdef BOOST_STATIC_STRING_CPP20
|
||||
|
||||
// Check construction in a constexpr context
|
||||
constexpr basic_static_string s("hello");
|
||||
static_assert(s.size() == 5);
|
||||
static_assert(s.static_capacity == 5);
|
||||
static_assert(s == "hello");
|
||||
|
||||
// Check assignment in a constexpr context
|
||||
constexpr auto s2 =
|
||||
[]()
|
||||
{
|
||||
basic_static_string s("hello");
|
||||
s = "world";
|
||||
return s;
|
||||
}();
|
||||
static_assert(s2 == "world");
|
||||
|
||||
// c++20 constexpr tests
|
||||
cstatic_string a;
|
||||
cstatic_string b(1, 'a');
|
||||
@@ -171,8 +227,10 @@ testConstantEvaluation()
|
||||
|
||||
a.substr(0);
|
||||
|
||||
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
|
||||
// subview
|
||||
a.subview(0);
|
||||
#endif
|
||||
|
||||
// copy
|
||||
char k[20]{};
|
||||
@@ -198,7 +256,8 @@ testConstantEvaluation()
|
||||
a.replace(a.begin(), a.end(), a.begin(), a.end());
|
||||
a.replace(a.begin(), a.end(), {'a'});
|
||||
|
||||
#ifdef BOOST_STATIC_STRING_IS_CONST_EVAL
|
||||
#if defined(BOOST_STATIC_STRING_IS_CONST_EVAL) \
|
||||
&& !defined(BOOST_STATIC_STRING_CONSTEXPR_PTR_CMP_BROKEN)
|
||||
a.clear();
|
||||
a.replace(a.begin(), a.end(), "a");
|
||||
a.replace(a.begin(), a.end(), "a", 1);
|
||||
@@ -386,7 +445,8 @@ testConstantEvaluation()
|
||||
a.replace(a.begin(), a.end(), a.begin(), a.end());
|
||||
a.replace(a.begin(), a.end(), {'a'});
|
||||
|
||||
#ifdef BOOST_STATIC_STRING_IS_CONST_EVAL
|
||||
#if defined(BOOST_STATIC_STRING_IS_CONST_EVAL) \
|
||||
&& !defined(BOOST_STATIC_STRING_CONSTEXPR_PTR_CMP_BROKEN)
|
||||
a.clear();
|
||||
a.replace(a.begin(), a.end(), "a");
|
||||
a.replace(a.begin(), a.end(), "a", 1);
|
||||
@@ -558,7 +618,8 @@ testConstantEvaluation()
|
||||
a.replace(a.begin(), a.end(), a.begin(), a.end());
|
||||
a.replace(a.begin(), a.end(), {'a'});
|
||||
|
||||
#ifdef BOOST_STATIC_STRING_IS_CONST_EVAL
|
||||
#if defined(BOOST_STATIC_STRING_IS_CONST_EVAL) \
|
||||
&& !defined(BOOST_STATIC_STRING_CONSTEXPR_PTR_CMP_BROKEN)
|
||||
a.clear();
|
||||
a.replace(a.begin(), a.end(), "a");
|
||||
a.replace(a.begin(), a.end(), "a", 1);
|
||||
@@ -605,5 +666,28 @@ testConstantEvaluation()
|
||||
cstatic_string().empty();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __cpp_nontype_template_args >= 201911L
|
||||
|
||||
template<basic_static_string<32, char, cxper_char_traits> X>
|
||||
struct nttp_primary
|
||||
{
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct nttp_primary<"test string">
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
static_assert(!nttp_primary<"random string">::value,
|
||||
"structural equality broken");
|
||||
|
||||
static_assert(nttp_primary<"test string">::value,
|
||||
"structural equality broken");
|
||||
|
||||
#endif
|
||||
|
||||
} // static_strings
|
||||
} // boost
|
||||
} // boost
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user