mirror of
https://github.com/boostorg/static_string.git
synced 2025-07-29 12:07:42 +02:00
Initial commit
This commit is contained in:
147
.appveyor.yml
Normal file
147
.appveyor.yml
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
# Copyright 2016, 2017 Peter Dimov
|
||||||
|
# Copyright (C) 2017 - 2019 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)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generic Appveyor build script for boostorg repositories
|
||||||
|
# See: https://github.com/boostorg/boost-ci/
|
||||||
|
#
|
||||||
|
# Instructions for customizing this script for your library:
|
||||||
|
#
|
||||||
|
# 1. Customize the compilers and language levels you want.
|
||||||
|
# 2. If you have more than include/, src/, test/, example/, examples/,
|
||||||
|
# benchmark/ or tools/ directories, set the environment variable DEPINST.
|
||||||
|
# For example if your build uses code in "bench/" and "fog/" directories:
|
||||||
|
# - DEPINST: --include bench --include fog
|
||||||
|
# 3. Enable pull request builds in your boostorg/<library> account.
|
||||||
|
#
|
||||||
|
# That's it - the script will do everything else for you.
|
||||||
|
#
|
||||||
|
|
||||||
|
version: 1.0.{build}-{branch}
|
||||||
|
|
||||||
|
shallow_clone: true
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- /bugfix\/.*/
|
||||||
|
- /feature\/.*/
|
||||||
|
- /fix\/.*/
|
||||||
|
- /pr\/.*/
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
|
||||||
|
allow_failures:
|
||||||
|
- MAYFAIL: true
|
||||||
|
|
||||||
|
environment:
|
||||||
|
global:
|
||||||
|
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||||
|
# to use the default for a given environment, comment it out; recommend you build debug and release however:
|
||||||
|
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
|
||||||
|
# libraries that care about this exercise it in their Jamfiles...
|
||||||
|
# B2_ADDRESS_MODEL: address-model=64,32
|
||||||
|
# B2_LINK: link=shared,static
|
||||||
|
# B2_THREADING: threading=multi,single
|
||||||
|
B2_VARIANT: variant=release
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
- FLAVOR: Visual Studio 2019
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
B2_CXXFLAGS: cxxflags=-permissive-
|
||||||
|
B2_CXXSTD: latest # 2a
|
||||||
|
B2_TOOLSET: msvc-14.2
|
||||||
|
|
||||||
|
- FLAVOR: Visual Studio 2017 C++2a Strict
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
B2_CXXFLAGS: cxxflags=-permissive-
|
||||||
|
B2_CXXSTD: latest # 2a
|
||||||
|
B2_TOOLSET: msvc-14.1
|
||||||
|
|
||||||
|
- FLAVOR: Visual Studio 2017 C++17
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
B2_CXXSTD: 17
|
||||||
|
B2_TOOLSET: msvc-14.1
|
||||||
|
B2_VARIANT: variant=debug
|
||||||
|
|
||||||
|
- FLAVOR: Visual Studio 2017 C++14 (Default)
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
B2_ADDRESS_MODEL: address-model=64,32
|
||||||
|
B2_TOOLSET: msvc-14.1
|
||||||
|
|
||||||
|
- FLAVOR: clang-cl
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
B2_CXXSTD: 11
|
||||||
|
B2_TOOLSET: clang-win
|
||||||
|
|
||||||
|
- FLAVOR: Visual Studio 2015 C++14 (Default)
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
B2_ADDRESS_MODEL: address-model=64,32
|
||||||
|
B2_TOOLSET: msvc-14.0
|
||||||
|
B2_VARIANT: variant=debug
|
||||||
|
|
||||||
|
- FLAVOR: Visual Studio 2010, 2012, 2013
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
B2_TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
|
||||||
|
|
||||||
|
- FLAVOR: cygwin (32-bit)
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
ADDPATH: C:\cygwin\bin;
|
||||||
|
B2_ADDRESS_MODEL: address-model=32
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
# https://github.com/boostorg/test/issues/144
|
||||||
|
B2_DEFINES: define=_POSIX_C_SOURCE=200112L
|
||||||
|
B2_THREADING: threadapi=pthread
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
B2_VARIANT: variant=debug
|
||||||
|
|
||||||
|
- FLAVOR: cygwin (64-bit)
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
ADDPATH: C:\cygwin64\bin;
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
B2_CXXSTD: 11,17
|
||||||
|
# https://github.com/boostorg/test/issues/144
|
||||||
|
B2_DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
|
||||||
|
B2_THREADING: threadapi=pthread
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
|
||||||
|
- FLAVOR: mingw32
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
ARCH: i686
|
||||||
|
B2_ADDRESS_MODEL: address-model=32
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
SCRIPT: ci\appveyor\mingw.bat
|
||||||
|
B2_VARIANT: variant=debug
|
||||||
|
|
||||||
|
- FLAVOR: mingw64
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
ARCH: x86_64
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
B2_CXXSTD: 11,17
|
||||||
|
B2_DEFINES: define=__USE_ISOC99
|
||||||
|
SCRIPT: ci\appveyor\mingw.bat
|
||||||
|
|
||||||
|
install:
|
||||||
|
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
||||||
|
- git clone https://github.com/boostorg/boost-ci.git C:\boost-ci
|
||||||
|
- xcopy /s /e /q /i C:\boost-ci\ci .\ci
|
||||||
|
- ci\appveyor\install.bat
|
||||||
|
|
||||||
|
build: off
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
||||||
|
- PATH=%ADDPATH%%PATH%
|
||||||
|
# The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
|
||||||
|
- IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
|
||||||
|
# Echo the complete build command to the build log
|
||||||
|
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
||||||
|
# Now go build...
|
||||||
|
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
311
.azure-pipelines.yml
Normal file
311
.azure-pipelines.yml
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
# Copyright 2015-2019 Rene Rivera.
|
||||||
|
# Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generic Azure Pipelines build script for boostorg repositories
|
||||||
|
# See: https://github.com/boostorg/boost-ci/
|
||||||
|
#
|
||||||
|
# Instructions for customizing this script for your library:
|
||||||
|
#
|
||||||
|
# 1. Customize the compilers and language levels you want.
|
||||||
|
# 2. If you have more than include/, src/, test/, example/, examples/,
|
||||||
|
# benchmark/ or tools/ directories, set the environment variable DEPINST.
|
||||||
|
# For example if your build uses code in "bench/" and "fog/" directories:
|
||||||
|
# - DEPINST: --include bench --include fog
|
||||||
|
# 3. Enable pull request builds in your boostorg/<library> account.
|
||||||
|
#
|
||||||
|
# That's it - the script will do everything else for you.
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- develop
|
||||||
|
- master
|
||||||
|
- bugfix/*
|
||||||
|
- feature/*
|
||||||
|
- fix/*
|
||||||
|
- pr/*
|
||||||
|
|
||||||
|
pr:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: B2_VARIANT
|
||||||
|
value: variant=release,debug
|
||||||
|
|
||||||
|
stages:
|
||||||
|
|
||||||
|
- stage: Test
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
- job: 'Linux'
|
||||||
|
pool:
|
||||||
|
vmImage: 'ubuntu-16.04'
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
GCC 8:
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
B2_CXXSTD: 14,17,2a
|
||||||
|
CXX: g++-8
|
||||||
|
PACKAGES: g++-8
|
||||||
|
GCC 7:
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
B2_CXXSTD: 11,14,17
|
||||||
|
CXX: g++-7
|
||||||
|
PACKAGES: g++-7
|
||||||
|
GCC 6:
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
B2_CXXSTD: 11,14
|
||||||
|
CXX: g++-6
|
||||||
|
PACKAGES: g++-6
|
||||||
|
GCC 5:
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
B2_CXXSTD: 11
|
||||||
|
CXX: g++-5
|
||||||
|
PACKAGES: g++-5
|
||||||
|
GCC 4.9:
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
CXX: g++-4.9
|
||||||
|
PACKAGES: g++-4.9
|
||||||
|
GCC 4.8:
|
||||||
|
B2_TOOLSET: gcc
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
CXX: g++-4.8
|
||||||
|
PACKAGES: g++-4.8
|
||||||
|
Clang 8:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 14,17,2a
|
||||||
|
CXX: clang++-8
|
||||||
|
PACKAGES: clang-8
|
||||||
|
LLVM_REPO: llvm-toolchain-xenial-8
|
||||||
|
Clang 7:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 14,17,2a
|
||||||
|
CXX: clang++-7
|
||||||
|
PACKAGES: clang-7
|
||||||
|
LLVM_REPO: llvm-toolchain-xenial-7
|
||||||
|
Clang 6:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11,14,17,2a
|
||||||
|
B2_CXXFLAGS: -stdlib=libc++
|
||||||
|
CXX: clang++-6.0
|
||||||
|
PACKAGES: clang-6.0
|
||||||
|
LLVM_REPO: llvm-toolchain-xenial-6.0
|
||||||
|
Clang 6:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 14,17,2a
|
||||||
|
CXX: clang++-6.0
|
||||||
|
PACKAGES: clang-6.0
|
||||||
|
LLVM_REPO: llvm-toolchain-xenial-6.0
|
||||||
|
Clang 5:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 11,14,17
|
||||||
|
PACKAGES: clang-5.0
|
||||||
|
CXX: clang++-5.0
|
||||||
|
LLVM_REPO: llvm-toolchain-xenial-5.0
|
||||||
|
Clang 4:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 11,14,17
|
||||||
|
CXX: clang++-4.0
|
||||||
|
PACKAGES: clang-4.0
|
||||||
|
LLVM_REPO: llvm-toolchain-xenial-4.0
|
||||||
|
Clang 3.9:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11,14
|
||||||
|
CXX: clang++-3.9
|
||||||
|
PACKAGES: clang-3.9
|
||||||
|
Clang 3.8:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
CXX: clang++-3.8
|
||||||
|
B2_CXXSTD: 03,11,14
|
||||||
|
PACKAGES: clang-3.8
|
||||||
|
Clang 3.7:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
CXX: clang++-3.7
|
||||||
|
PACKAGES: clang-3.7
|
||||||
|
Clang 3.6:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
CXX: clang++-3.6
|
||||||
|
PACKAGES: clang-3.6
|
||||||
|
Clang 3.5:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
CXX: clang++-3.5
|
||||||
|
PACKAGES: clang-3.5
|
||||||
|
steps:
|
||||||
|
- bash: |
|
||||||
|
set -e
|
||||||
|
uname -a
|
||||||
|
sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
|
||||||
|
if test -n "${LLVM_REPO}" ; then
|
||||||
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
|
sudo -E apt-add-repository "deb http://apt.llvm.org/xenial/ ${LLVM_REPO} main"
|
||||||
|
fi
|
||||||
|
sudo -E apt-get update
|
||||||
|
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install ${PACKAGES}
|
||||||
|
|
||||||
|
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
|
||||||
|
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||||
|
rm -rf boost-ci
|
||||||
|
source ci/azure-pipelines/install.sh
|
||||||
|
|
||||||
|
# AzP requires to run special task in order to export
|
||||||
|
# SELF and BOOST_ROOT as job-scoped variable from a script.
|
||||||
|
# NOTE: Disable set -x is necessary, see the troubleshooting guide
|
||||||
|
# on "Variables having ' (single quote) appended":
|
||||||
|
# https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting
|
||||||
|
set +x
|
||||||
|
echo "##vso[task.setvariable variable=SELF]"$SELF
|
||||||
|
echo "##vso[task.setvariable variable=BOOST_ROOT]"$BOOST_ROOT
|
||||||
|
set -x
|
||||||
|
displayName: 'Install'
|
||||||
|
- bash: |
|
||||||
|
set -e
|
||||||
|
echo "SELF=$SELF"
|
||||||
|
echo "BOOST_ROOT=$BOOST_ROOT"
|
||||||
|
|
||||||
|
cd $BOOST_ROOT/libs/$SELF
|
||||||
|
ci/azure-pipelines/build.sh --debug-configuration
|
||||||
|
displayName: 'Build'
|
||||||
|
|
||||||
|
- job: 'Windows'
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
VS 2019 C++2a Strict:
|
||||||
|
B2_TOOLSET: msvc-14.2
|
||||||
|
B2_CXXSTD: latest # 2a
|
||||||
|
B2_CXXFLAGS: cxxflags=-permissive-
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
VM_IMAGE: 'windows-2019'
|
||||||
|
VS 2017 C++2a Strict:
|
||||||
|
B2_TOOLSET: msvc-14.1
|
||||||
|
B2_CXXSTD: latest # 2a
|
||||||
|
B2_CXXFLAGS: cxxflags=-permissive-
|
||||||
|
B2_ADDRESS_MODEL: address-model=64
|
||||||
|
VM_IMAGE: 'vs2017-win2016'
|
||||||
|
VS 2017 C++17:
|
||||||
|
B2_TOOLSET: msvc-14.1
|
||||||
|
B2_CXXSTD: 17
|
||||||
|
B2_ADDRESS_MODEL: address-model=64,32
|
||||||
|
VM_IMAGE: 'vs2017-win2016'
|
||||||
|
VS 2017 C++14:
|
||||||
|
B2_TOOLSET: msvc-14.1
|
||||||
|
#B2_CXXSTD: 14 # default
|
||||||
|
B2_ADDRESS_MODEL: address-model=64,32
|
||||||
|
VM_IMAGE: 'vs2017-win2016'
|
||||||
|
VS 2015 C++14:
|
||||||
|
B2_TOOLSET: msvc-14.0
|
||||||
|
#B2_CXXSTD: 14 # default
|
||||||
|
B2_ADDRESS_MODEL: address-model=64,32
|
||||||
|
VM_IMAGE: 'vs2015-win2012r2'
|
||||||
|
|
||||||
|
pool:
|
||||||
|
vmImage: $(VM_IMAGE)
|
||||||
|
steps:
|
||||||
|
- script: |
|
||||||
|
set SELF=%BUILD_REPOSITORY_NAME:-=_%
|
||||||
|
for /f "tokens=2 delims=/" %%a in ("%SELF%") do set SELF=%%a
|
||||||
|
set BOOST_ROOT=%BUILD_SOURCESDIRECTORY%\boost-root
|
||||||
|
|
||||||
|
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
|
||||||
|
xcopy /s /e /q /i boost-ci\ci .\ci
|
||||||
|
cmd /k ci\azure-pipelines\install.bat
|
||||||
|
|
||||||
|
echo ##vso[task.setvariable variable=SELF]%SELF%
|
||||||
|
echo ##vso[task.setvariable variable=BOOST_ROOT]%BOOST_ROOT%
|
||||||
|
displayName: 'Install'
|
||||||
|
- script: |
|
||||||
|
PATH=%ADDPATH%%PATH%
|
||||||
|
REM The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
|
||||||
|
IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
|
||||||
|
cd %BOOST_ROOT%
|
||||||
|
ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
|
||||||
|
b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
|
||||||
|
displayName: 'Build'
|
||||||
|
|
||||||
|
- job: 'macOS'
|
||||||
|
pool:
|
||||||
|
vmImage: 'macOS-10.13'
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
Xcode 10.1:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 14,17,2a
|
||||||
|
XCODE_APP: /Applications/Xcode_10.1.app
|
||||||
|
Xcode 10.0:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 14,17,2a
|
||||||
|
XCODE_APP: /Applications/Xcode_10.app
|
||||||
|
Xcode 9.4.1:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 11,14,17
|
||||||
|
XCODE_APP: /Applications/Xcode_9.4.1.app
|
||||||
|
Xcode 9.4:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 11,14,17
|
||||||
|
XCODE_APP: /Applications/Xcode_9.4.app
|
||||||
|
Xcode 9.3.1:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 11,14,17
|
||||||
|
XCODE_APP: /Applications/Xcode_9.3.1.app
|
||||||
|
Xcode 9.3:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 11,14
|
||||||
|
XCODE_APP: /Applications/Xcode_9.3.app
|
||||||
|
Xcode 9.2:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 11,14
|
||||||
|
XCODE_APP: /Applications/Xcode_9.2.app
|
||||||
|
Xcode 9.1:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
XCODE_APP: /Applications/Xcode_9.1.app
|
||||||
|
Xcode 9.0.1:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
XCODE_APP: /Applications/Xcode_9.0.1.app
|
||||||
|
Xcode 9.0:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
XCODE_APP: /Applications/Xcode_9.app
|
||||||
|
Xcode 8.3.3:
|
||||||
|
B2_TOOLSET: clang
|
||||||
|
B2_CXXSTD: 03,11
|
||||||
|
XCODE_APP: /Applications/Xcode_8.3.3.app
|
||||||
|
steps:
|
||||||
|
- bash: |
|
||||||
|
set -e
|
||||||
|
uname -a
|
||||||
|
sudo xcode-select -switch ${XCODE_APP}
|
||||||
|
which clang++
|
||||||
|
|
||||||
|
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
|
||||||
|
cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||||
|
rm -rf boost-ci
|
||||||
|
source ci/azure-pipelines/install.sh
|
||||||
|
|
||||||
|
# AzP requires to run special task in order to export
|
||||||
|
# SELF and BOOST_ROOT as job-scoped variable from a script.
|
||||||
|
# NOTE: Disable set -x is necessary, see the troubleshooting guide
|
||||||
|
# on "Variables having ' (single quote) appended":
|
||||||
|
# https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting
|
||||||
|
set +x
|
||||||
|
echo "##vso[task.setvariable variable=SELF]"$SELF
|
||||||
|
echo "##vso[task.setvariable variable=BOOST_ROOT]"$BOOST_ROOT
|
||||||
|
set -x
|
||||||
|
displayName: Install
|
||||||
|
- bash: |
|
||||||
|
set -e
|
||||||
|
echo "SELF=$SELF"
|
||||||
|
echo "BOOST_ROOT=$BOOST_ROOT"
|
||||||
|
|
||||||
|
cd $BOOST_ROOT/libs/$SELF
|
||||||
|
ci/azure-pipelines/build.sh --debug-configuration
|
||||||
|
displayName: 'Build'
|
12
.gitattributes
vendored
Normal file
12
.gitattributes
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Set default behaviour, in case users don't have core.autocrlf set.
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Github
|
||||||
|
.md text eol=lf
|
||||||
|
|
||||||
|
# Visual Studio
|
||||||
|
*.sln text eol=crlf
|
||||||
|
*.vcproj text eol=crlf
|
||||||
|
*.vcxproj text eol=crlf
|
||||||
|
*.props text eol=crlf
|
||||||
|
*.filters text eol=crlf
|
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
bin/
|
||||||
|
bin64/
|
||||||
|
|
||||||
|
# Because of CMake and VS2017
|
||||||
|
Win32/
|
||||||
|
x64/
|
||||||
|
|
236
.travis.yml
Normal file
236
.travis.yml
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
# Copyright 2016 Peter Dimov
|
||||||
|
# Copyright 2017 - 2019 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)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generic Travis CI build script for boostorg repositories
|
||||||
|
# See: https://github.com/boostorg/boost-ci
|
||||||
|
#
|
||||||
|
# Instructions for customizing this script for your library:
|
||||||
|
#
|
||||||
|
# 1. Customize the compilers and language levels you want in the 'jobs'.
|
||||||
|
# 2. If you have more than include/, src/, test/, example/, examples/, or
|
||||||
|
# tools/ directories, modify your Travis CI project and add the environment
|
||||||
|
# variable DEPINST. For example if your build uses code in "bench/" and
|
||||||
|
# "fog/" directories, then set DEPINST to the following:
|
||||||
|
# --include bench --include fog
|
||||||
|
# 3. If you want to enable Coverity Scan, you need to provide the environment
|
||||||
|
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
|
||||||
|
# your github settings.
|
||||||
|
# 4. If you want to enable a big-endian build, you need to uncomment the
|
||||||
|
# big-endian build job.
|
||||||
|
# 5. Enable pull request builds in your boostorg/<library> account.
|
||||||
|
#
|
||||||
|
# That's it - the scripts will do everything else for you.
|
||||||
|
|
||||||
|
dist: xenial
|
||||||
|
language: cpp
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||||
|
# - B2_ADDRESS_MODEL=address-model=64,32
|
||||||
|
# - B2_LINK=link=shared,static
|
||||||
|
# - B2_THREADING=threading=multi,single
|
||||||
|
- B2_VARIANT=variant=release
|
||||||
|
|
||||||
|
install:
|
||||||
|
- git clone https://github.com/boostorg/boost-ci.git boost-ci
|
||||||
|
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
|
||||||
|
- source ci/travis/install.sh
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- binutils-gold
|
||||||
|
- gdb
|
||||||
|
- libc6-dbg
|
||||||
|
- qemu-user-static
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- /bugfix\/.*/
|
||||||
|
- /feature\/.*/
|
||||||
|
- /fix\/.*/
|
||||||
|
- /pr\/.*/
|
||||||
|
|
||||||
|
script:
|
||||||
|
- cd $BOOST_ROOT/libs/$SELF
|
||||||
|
- ci/travis/build.sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Default toolsets in Ubuntu
|
||||||
|
#
|
||||||
|
# trusty xenial bionic
|
||||||
|
# 14.04 16.04 18.04
|
||||||
|
# ------ ------ ------
|
||||||
|
# clang 3.4 3.8 6.0
|
||||||
|
# gcc 4.8.2 5.3.1 7.3.0
|
||||||
|
#
|
||||||
|
|
||||||
|
anchors:
|
||||||
|
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
|
||||||
|
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-3.8",
|
||||||
|
"ubuntu-toolchain-r-test" ] } }
|
||||||
|
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
|
||||||
|
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-4.0",
|
||||||
|
"ubuntu-toolchain-r-test" ] } }
|
||||||
|
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
|
||||||
|
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-xenial-5.0",
|
||||||
|
"ubuntu-toolchain-r-test" ] } }
|
||||||
|
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
|
||||||
|
"libc6-dbg",
|
||||||
|
"libc++-dev",
|
||||||
|
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-6.0",
|
||||||
|
"ubuntu-toolchain-r-test" ] } }
|
||||||
|
clang-7: &clang-7 { apt: { packages: [ "clang-7",
|
||||||
|
"libc6-dbg",
|
||||||
|
"libc++-dev",
|
||||||
|
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-7",
|
||||||
|
"ubuntu-toolchain-r-test" ] } }
|
||||||
|
clang-8: &clang-8 { apt: { packages: [ "clang-8",
|
||||||
|
"libc6-dbg",
|
||||||
|
"libc++-dev",
|
||||||
|
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8",
|
||||||
|
"ubuntu-toolchain-r-test" ] } }
|
||||||
|
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } }
|
||||||
|
gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||||
|
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } }
|
||||||
|
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||||
|
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||||
|
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||||
|
gcc-9: &gcc-9 { apt: { packages: [ "g++-9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
allow_failures:
|
||||||
|
- env:
|
||||||
|
- COPY="all the environment settings from your job"
|
||||||
|
|
||||||
|
include:
|
||||||
|
# coverage
|
||||||
|
- os: linux
|
||||||
|
env:
|
||||||
|
- COMMENT=codecov.io
|
||||||
|
- B2_CXXSTD=11
|
||||||
|
- B2_TOOLSET=gcc-8
|
||||||
|
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||||
|
addons: *gcc-8
|
||||||
|
script:
|
||||||
|
- cd $BOOST_ROOT/libs/$SELF
|
||||||
|
- ci/travis/codecov.sh
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
env:
|
||||||
|
- COMMENT=asan
|
||||||
|
- B2_VARIANT=variant=debug
|
||||||
|
- B2_TOOLSET=gcc-8
|
||||||
|
- B2_CXXSTD=11,14
|
||||||
|
- B2_CXXFLAGS="address-sanitizer=norecover"
|
||||||
|
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||||
|
addons: *gcc-8
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
env:
|
||||||
|
- COMMENT=tsan
|
||||||
|
- B2_VARIANT=variant=debug
|
||||||
|
- B2_TOOLSET=gcc-8
|
||||||
|
- B2_CXXSTD=11,14
|
||||||
|
- B2_CXXFLAGS="thread-sanitizer=norecover"
|
||||||
|
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||||
|
addons: *gcc-8
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
env:
|
||||||
|
- COMMENT=ubsan
|
||||||
|
- B2_VARIANT=variant=debug
|
||||||
|
- B2_TOOLSET=gcc-8
|
||||||
|
- B2_CXXSTD=11,14
|
||||||
|
- B2_CXXFLAGS="undefined-sanitizer=norecover"
|
||||||
|
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||||
|
- B2_LINKFLAGS="linkflags=-fuse-ld=gold"
|
||||||
|
- UBSAN_OPTIONS=print_stacktrace=1
|
||||||
|
addons: *gcc-8
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
env:
|
||||||
|
- COMMENT=valgrind
|
||||||
|
- B2_TOOLSET=clang-6.0
|
||||||
|
- B2_CXXSTD=11,14
|
||||||
|
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||||
|
- B2_VARIANT=variant=debug
|
||||||
|
- B2_TESTFLAGS=testing.launcher=valgrind
|
||||||
|
- VALGRIND_OPTS=--error-exitcode=1
|
||||||
|
addons: *clang-6
|
||||||
|
script:
|
||||||
|
- cd $BOOST_ROOT/libs/$SELF
|
||||||
|
- ci/travis/valgrind.sh
|
||||||
|
|
||||||
|
# libstdc++
|
||||||
|
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||||
|
env: [ "B2_TOOLSET=gcc-4.8", "B2_CXXSTD=11" ], addons: *gcc-48 }
|
||||||
|
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||||
|
env: [ "B2_TOOLSET=gcc-4.9", "B2_CXXSTD=11" ], addons: *gcc-49 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=gcc-5", "B2_CXXSTD=11" ], addons: *gcc-5 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=gcc-6", "B2_CXXSTD=11,14" ], addons: *gcc-6 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=gcc-7", "B2_CXXSTD=14,17" ], addons: *gcc-7 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=gcc-8", "B2_CXXSTD=17,2a" ], addons: *gcc-8 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=gcc-9", "B2_CXXSTD=17,2a" ], addons: *gcc-9 }
|
||||||
|
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
|
||||||
|
env: [ "B2_TOOLSET=clang-3.8", "B2_CXXSTD=11" ], addons: *clang-38 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=clang-4.0", "B2_CXXSTD=11,14" ], addons: *clang-4 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=clang-5.0", "B2_CXXSTD=11,14" ], addons: *clang-5 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17,2a" ], addons: *clang-7 }
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17,2a" ], addons: *clang-8 }
|
||||||
|
|
||||||
|
# libc++
|
||||||
|
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=11,14",
|
||||||
|
"B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
|
||||||
|
- { os: "osx" , env: [ "B2_TOOLSET=clang", "B2_CXXSTD=11,17" ] }
|
||||||
|
|
||||||
|
# to enable Intel ICC define INTEL_ICC_SERIAL_NUMBER and the following (under development):
|
||||||
|
# - { os: "linux", env: [ "B2_TOOLSET=intel-linux", "B2_CXXSTD=11,14,17" ], addons: *gcc-7,
|
||||||
|
# script: cd $BOOST_ROOT/libs/$SELF && ci/travis/intelicc.sh }
|
||||||
|
|
||||||
|
# uncomment to enable a big-endian build job, just note that it is 5-10 times slower
|
||||||
|
# than a regular build and travis has a 50 minute time limit per job
|
||||||
|
# - os: linux
|
||||||
|
# env:
|
||||||
|
# - COMMENT=big-endian
|
||||||
|
# - B2_CXXSTD=03
|
||||||
|
# - B2_TOOLSET=gcc
|
||||||
|
# - B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
|
||||||
|
# - BDDE_OS=red
|
||||||
|
# - BDDE_ARCH=ppc64
|
||||||
|
# script:
|
||||||
|
# - cd $BOOST_ROOT/libs/$SELF
|
||||||
|
# - ci/travis/bdde.sh
|
||||||
|
|
||||||
|
# - os: linux
|
||||||
|
# env:
|
||||||
|
# - COMMENT=cppcheck
|
||||||
|
# script:
|
||||||
|
# - cd $BOOST_ROOT/libs/$SELF
|
||||||
|
# - ci/travis/cppcheck.sh
|
||||||
|
|
||||||
|
#################### Jobs to run on pushes to master, develop ###################
|
||||||
|
|
||||||
|
# Coverity Scan
|
||||||
|
- os: linux
|
||||||
|
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
|
||||||
|
env:
|
||||||
|
- COMMENT="Coverity Scan"
|
||||||
|
- B2_TOOLSET=clang
|
||||||
|
script:
|
||||||
|
- cd $BOOST_ROOT/libs/$SELF
|
||||||
|
- ci/travis/coverity.sh
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
email:
|
||||||
|
false
|
1
CHANGELOG.md
Normal file
1
CHANGELOG.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
--------------------------------------------------------------------------------
|
152
CMakeLists.txt
Normal file
152
CMakeLists.txt
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2016-2017 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/fixed_string
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required (VERSION 3.5.1)
|
||||||
|
|
||||||
|
if (POLICY CMP0074)
|
||||||
|
cmake_policy (SET CMP0074 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function (DoGroupSources curdir rootdir folder)
|
||||||
|
file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
|
||||||
|
foreach (child ${children})
|
||||||
|
if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
|
||||||
|
DoGroupSources (${curdir}/${child} ${rootdir} ${folder})
|
||||||
|
elseif (${child} STREQUAL "CMakeLists.txt")
|
||||||
|
source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
|
||||||
|
else()
|
||||||
|
string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir})
|
||||||
|
string (REPLACE "/" "\\" groupname ${groupname})
|
||||||
|
source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function (GroupSources curdir folder)
|
||||||
|
DoGroupSources (${curdir} ${curdir} ${folder})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# FixedString
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
project (FixedString VERSION 1)
|
||||||
|
|
||||||
|
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set (CMAKE_VERBOSE_MAKEFILE FALSE)
|
||||||
|
|
||||||
|
add_definitions (
|
||||||
|
-D_WIN32_WINNT=0x0601
|
||||||
|
)
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
/permissive- # strict C++
|
||||||
|
/W4 # enable all warnings
|
||||||
|
/MP # Multi-processor compilation
|
||||||
|
)
|
||||||
|
|
||||||
|
set (Boost_USE_STATIC_LIBS ON)
|
||||||
|
set (Boost_USE_STATIC_RUNTIME ON)
|
||||||
|
|
||||||
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT")
|
||||||
|
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
|
||||||
|
|
||||||
|
# for RelWithDebInfo builds, disable incremental linking
|
||||||
|
# since CMake sets it ON by default for that build type and it
|
||||||
|
# causes warnings
|
||||||
|
#
|
||||||
|
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags
|
||||||
|
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags})
|
||||||
|
|
||||||
|
else()
|
||||||
|
set (THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
find_package (Threads)
|
||||||
|
|
||||||
|
set( CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter")
|
||||||
|
|
||||||
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrange-loop-analysis")
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Must come before Boost includes, otherwise the
|
||||||
|
# IDE sees the wrong file due to boost/ symlinks.
|
||||||
|
include_directories (include)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Boost
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_filename_component (BOOST_ROOT ../../ ABSOLUTE)
|
||||||
|
|
||||||
|
# VFALCO I want static but "b2 stage" builds a minimal set which excludes static
|
||||||
|
add_definitions (-DBOOST_ALL_STATIC_LINK=1)
|
||||||
|
|
||||||
|
include_directories (${BOOST_ROOT})
|
||||||
|
|
||||||
|
link_directories(${BOOST_ROOT}/stage/lib)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ("${VARIANT}" STREQUAL "coverage")
|
||||||
|
if (MSVC)
|
||||||
|
else()
|
||||||
|
set (CMAKE_BUILD_TYPE DEBUG)
|
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 --coverage")
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
elseif ("${VARIANT}" STREQUAL "ubasan")
|
||||||
|
if (MSVC)
|
||||||
|
else()
|
||||||
|
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
|
||||||
|
set (CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tools/blacklist.supp")
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-sanitize-recover=address,undefined")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
elseif ("${VARIANT}" STREQUAL "debug")
|
||||||
|
set (CMAKE_BUILD_TYPE DEBUG)
|
||||||
|
|
||||||
|
elseif ("${VARIANT}" STREQUAL "release")
|
||||||
|
set (CMAKE_BUILD_TYPE RELEASE)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#GroupSources (test "/")
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Tests and examples
|
||||||
|
#
|
||||||
|
|
||||||
|
#include_directories (.)
|
||||||
|
|
||||||
|
file (GLOB_RECURSE PROJECT_FILES
|
||||||
|
${PROJECT_SOURCE_DIR}/include/boost/fixed_string/*.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/boost/fixed_string/*.ipp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory (test)
|
9
CODE_OF_CONDUCT.md
Normal file
9
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Code of Conduct
|
||||||
|
|
||||||
|
* Be respectful of others
|
||||||
|
|
||||||
|
* Please use professional conduct
|
||||||
|
|
||||||
|
* Treat others the way you want to be treated
|
||||||
|
|
||||||
|
Thank you!
|
45
Jamfile
Normal file
45
Jamfile
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#
|
||||||
|
# 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/beast
|
||||||
|
#
|
||||||
|
|
||||||
|
import ac ;
|
||||||
|
import os ;
|
||||||
|
import feature ;
|
||||||
|
import boost ;
|
||||||
|
import modules ;
|
||||||
|
import testing ;
|
||||||
|
import ../../config/checks/config : requires ;
|
||||||
|
|
||||||
|
boost.use-project ;
|
||||||
|
|
||||||
|
local defines =
|
||||||
|
[ requires
|
||||||
|
cxx11_constexpr
|
||||||
|
cxx11_decltype
|
||||||
|
cxx11_hdr_tuple
|
||||||
|
cxx11_template_aliases
|
||||||
|
cxx11_variadic_templates
|
||||||
|
]
|
||||||
|
<implicit-dependency>/boost//headers
|
||||||
|
<include>.
|
||||||
|
<define>BOOST_ALL_NO_LIB=1
|
||||||
|
<toolset>msvc-14.1:<cxxflags>"/permissive-"
|
||||||
|
<toolset>msvc-14.2:<cxxflags>"/permissive-"
|
||||||
|
<toolset>msvc,<variant>release:<cxxflags>"/Ob2 /Oi /Ot"
|
||||||
|
<target-os>windows:<define>_WIN32_WINNT=0x0601
|
||||||
|
;
|
||||||
|
|
||||||
|
project /boost/fixed_string
|
||||||
|
: requirements
|
||||||
|
<link>static
|
||||||
|
$(defines)
|
||||||
|
: usage-requirements
|
||||||
|
$(defines)
|
||||||
|
;
|
||||||
|
|
||||||
|
build-project test ;
|
23
LICENSE_1_0.txt
Normal file
23
LICENSE_1_0.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Boost.FixedString
|
||||||
|
|
||||||
|
Branch | Travis | Appveyor | Azure Pipelines | codecov.io | Docs | Matrix |
|
||||||
|
:-------------: | ------ | -------- | --------------- | ---------- | ---- | ------ |
|
||||||
|
[`master`](https://github.com/boostorg/fixed_string/tree/master) | [](https://travis-ci.org/boostorg/fixed_string) | [](https://ci.appveyor.com/project/maintainer/fixed_string-xyzzy/branch/master) | [](https://dev.azure.com/maintainer/fixed_string/_build/latest?definitionId=6&branchName=master) | [](https://codecov.io/gh/boostorg/fixed_string/branch/master) | [](http://www.boost.org/doc/libs/master/doc/html/fixed_string.html) | [](http://www.boost.org/development/tests/master/developer/fixed_string.html)
|
||||||
|
[`develop`](https://github.com/boostorg/fixed_string/tree/develop) | [](https://travis-ci.org/boostorg/fixed_string) | [](https://ci.appveyor.com/project/maintainer/fixed_string-xyzzy/branch/develop) | [](https://dev.azure.com/maintainer/fixed_string/_build/latest?definitionId=6&branchName=master) | [](https://codecov.io/gh/boostorg/fixed_string/branch/develop) | [](http://www.boost.org/doc/libs/develop/doc/html/fixed_string.html) | [](http://www.boost.org/development/tests/develop/developer/fixed_string.html)
|
||||||
|
|
||||||
|
This is currently **NOT** an official Boost library.
|
29
include/boost/fixed_string/config.hpp
Normal file
29
include/boost/fixed_string/config.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2016-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/fixed_string
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BOOST_FIXED_STRING_CONFIG_HPP
|
||||||
|
#define BOOST_FIXED_STRING_CONFIG_HPP
|
||||||
|
|
||||||
|
#include <boost/utility/string_view.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace fixed_string {
|
||||||
|
|
||||||
|
/// The type of `string_view` used by the library
|
||||||
|
using string_view = boost::string_view;
|
||||||
|
|
||||||
|
/// The type of `basic_string_view` used by the library
|
||||||
|
template<class CharT, class Traits>
|
||||||
|
using basic_string_view =
|
||||||
|
boost::basic_string_view<CharT, Traits>;
|
||||||
|
|
||||||
|
} // fixed_string
|
||||||
|
} // boost
|
||||||
|
|
||||||
|
#endif
|
133
include/boost/fixed_string/detail/fixed_string.hpp
Normal file
133
include/boost/fixed_string/detail/fixed_string.hpp
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2016-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/fixed_string
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BOOST_FIXED_STRING_DETAIL_FIXED_STRING_HPP
|
||||||
|
#define BOOST_FIXED_STRING_DETAIL_FIXED_STRING_HPP
|
||||||
|
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
#include <boost/core/ignore_unused.hpp>
|
||||||
|
#include <iterator>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace fixed_string {
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
// Because k-ballo said so
|
||||||
|
template<class T>
|
||||||
|
using is_input_iterator =
|
||||||
|
std::integral_constant<bool,
|
||||||
|
! std::is_integral<T>::value>;
|
||||||
|
|
||||||
|
template<class CharT, class Traits>
|
||||||
|
int
|
||||||
|
lexicographical_compare(
|
||||||
|
CharT const* s1, std::size_t n1,
|
||||||
|
CharT const* s2, std::size_t n2)
|
||||||
|
{
|
||||||
|
if(n1 < n2)
|
||||||
|
return Traits::compare(
|
||||||
|
s1, s2, n1) <= 0 ? -1 : 1;
|
||||||
|
if(n1 > n2)
|
||||||
|
return Traits::compare(
|
||||||
|
s1, s2, n2) >= 0 ? 1 : -1;
|
||||||
|
return Traits::compare(s1, s2, n1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class CharT, class Traits>
|
||||||
|
int
|
||||||
|
lexicographical_compare(
|
||||||
|
basic_string_view<CharT, Traits> s1,
|
||||||
|
CharT const* s2, std::size_t n2)
|
||||||
|
{
|
||||||
|
return detail::lexicographical_compare<
|
||||||
|
CharT, Traits>(s1.data(), s1.size(), s2, n2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class CharT, class Traits>
|
||||||
|
int
|
||||||
|
lexicographical_compare(
|
||||||
|
basic_string_view<CharT, Traits> s1,
|
||||||
|
basic_string_view<CharT, Traits> s2)
|
||||||
|
{
|
||||||
|
return detail::lexicographical_compare<CharT, Traits>(
|
||||||
|
s1.data(), s1.size(), s2.data(), s2.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maximum number of characters in the decimal
|
||||||
|
// representation of a binary number. This includes
|
||||||
|
// the potential minus sign.
|
||||||
|
//
|
||||||
|
inline
|
||||||
|
std::size_t constexpr
|
||||||
|
max_digits(std::size_t bytes)
|
||||||
|
{
|
||||||
|
return static_cast<std::size_t>(
|
||||||
|
bytes * 2.41) + 1 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class CharT, class Integer, class Traits>
|
||||||
|
CharT*
|
||||||
|
raw_to_string(
|
||||||
|
CharT* buf, Integer x, std::true_type)
|
||||||
|
{
|
||||||
|
if(x == 0)
|
||||||
|
{
|
||||||
|
Traits::assign(*--buf, '0');
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
if(x < 0)
|
||||||
|
{
|
||||||
|
x = -x;
|
||||||
|
for(;x > 0; x /= 10)
|
||||||
|
Traits::assign(*--buf ,
|
||||||
|
"0123456789"[x % 10]);
|
||||||
|
Traits::assign(*--buf, '-');
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
for(;x > 0; x /= 10)
|
||||||
|
Traits::assign(*--buf ,
|
||||||
|
"0123456789"[x % 10]);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class CharT, class Integer, class Traits>
|
||||||
|
CharT*
|
||||||
|
raw_to_string(
|
||||||
|
CharT* buf, Integer x, std::false_type)
|
||||||
|
{
|
||||||
|
if(x == 0)
|
||||||
|
{
|
||||||
|
*--buf = '0';
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
for(;x > 0; x /= 10)
|
||||||
|
Traits::assign(*--buf ,
|
||||||
|
"0123456789"[x % 10]);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
class CharT,
|
||||||
|
class Integer,
|
||||||
|
class Traits = std::char_traits<CharT>>
|
||||||
|
CharT*
|
||||||
|
raw_to_string(CharT* last, std::size_t size, Integer i)
|
||||||
|
{
|
||||||
|
boost::ignore_unused(size);
|
||||||
|
BOOST_ASSERT(size >= max_digits(sizeof(Integer)));
|
||||||
|
return raw_to_string<CharT, Integer, Traits>(
|
||||||
|
last, i, std::is_signed<Integer>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // detail
|
||||||
|
} // fixed_string
|
||||||
|
} // boost
|
||||||
|
|
||||||
|
#endif
|
1113
include/boost/fixed_string/fixed_string.hpp
Normal file
1113
include/boost/fixed_string/fixed_string.hpp
Normal file
File diff suppressed because it is too large
Load Diff
585
include/boost/fixed_string/impl/fixed_string.hpp
Normal file
585
include/boost/fixed_string/impl/fixed_string.hpp
Normal file
@ -0,0 +1,585 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2016-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/fixed_string
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BOOST_FIXED_STRING_IMPL_FIXED_STRING_HPP
|
||||||
|
#define BOOST_FIXED_STRING_IMPL_FIXED_STRING_HPP
|
||||||
|
|
||||||
|
#include <boost/fixed_string/detail/fixed_string.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace fixed_string {
|
||||||
|
|
||||||
|
//
|
||||||
|
// (constructor)
|
||||||
|
//
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string()
|
||||||
|
{
|
||||||
|
n_ = 0;
|
||||||
|
term();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(size_type count, CharT ch)
|
||||||
|
{
|
||||||
|
assign(count, ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<std::size_t M>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(fixed_string<M, CharT, Traits> const& other,
|
||||||
|
size_type pos)
|
||||||
|
{
|
||||||
|
assign(other, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<std::size_t M>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(fixed_string<M, CharT, Traits> const& other,
|
||||||
|
size_type pos, size_type count)
|
||||||
|
{
|
||||||
|
assign(other, pos, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(CharT const* s, size_type count)
|
||||||
|
{
|
||||||
|
assign(s, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(CharT const* s)
|
||||||
|
{
|
||||||
|
auto const count = Traits::length(s);
|
||||||
|
if(count > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"count > max_size()"});
|
||||||
|
n_ = count;
|
||||||
|
Traits::copy(&s_[0], s, n_ + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<class InputIt>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(InputIt first, InputIt last)
|
||||||
|
{
|
||||||
|
assign(first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(fixed_string const& s)
|
||||||
|
{
|
||||||
|
assign(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<std::size_t M>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(fixed_string<M, CharT, Traits> const& s)
|
||||||
|
{
|
||||||
|
assign(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(std::initializer_list<CharT> init)
|
||||||
|
{
|
||||||
|
assign(init.begin(), init.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(string_view_type sv)
|
||||||
|
{
|
||||||
|
assign(sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<class T, class>
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
fixed_string(T const& t, size_type pos, size_type n)
|
||||||
|
{
|
||||||
|
assign(t, pos, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// (assignment)
|
||||||
|
//
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
operator=(CharT const* s) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
auto const count = Traits::length(s);
|
||||||
|
if(count > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"count > max_size()"});
|
||||||
|
n_ = count;
|
||||||
|
Traits::copy(&s_[0], s, n_ + 1);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign(size_type count, CharT ch) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
if(count > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"count > max_size()"});
|
||||||
|
n_ = count;
|
||||||
|
Traits::assign(&s_[0], n_, ch);
|
||||||
|
term();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign(fixed_string const& str) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
n_ = str.n_;
|
||||||
|
auto const n = n_ + 1;
|
||||||
|
// VFALCO I can't remember the thinking behind this
|
||||||
|
//BOOST_BEAST_ASSUME(n != 0);
|
||||||
|
Traits::copy(&s_[0], &str.s_[0], n);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<std::size_t M>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign(fixed_string<M, CharT, Traits> const& str,
|
||||||
|
size_type pos, size_type count) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
auto const ss = str.substr(pos, count);
|
||||||
|
return assign(ss.data(), ss.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign(CharT const* s, size_type count) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
if(count > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"count > max_size()"});
|
||||||
|
n_ = count;
|
||||||
|
Traits::copy(&s_[0], s, n_);
|
||||||
|
term();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<class InputIt>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign(InputIt first, InputIt last) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
std::size_t const n = std::distance(first, last);
|
||||||
|
if(n > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"n > max_size()"});
|
||||||
|
n_ = n;
|
||||||
|
for(auto it = &s_[0]; first != last; ++it, ++first)
|
||||||
|
Traits::assign(*it, *first);
|
||||||
|
term();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<class T>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign(T const& t, size_type pos, size_type count) ->
|
||||||
|
typename std::enable_if<std::is_convertible<T,
|
||||||
|
string_view_type>::value, fixed_string&>::type
|
||||||
|
{
|
||||||
|
auto const sv = string_view_type(t).substr(pos, count);
|
||||||
|
if(sv.size() > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"sv.size() > max_size()"});
|
||||||
|
n_ = sv.size();
|
||||||
|
Traits::copy(&s_[0], &sv[0], n_);
|
||||||
|
term();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Element access
|
||||||
|
//
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
at(size_type pos) ->
|
||||||
|
reference
|
||||||
|
{
|
||||||
|
if(pos >= size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||||
|
"pos >= size()"});
|
||||||
|
return s_[pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
at(size_type pos) const ->
|
||||||
|
const_reference
|
||||||
|
{
|
||||||
|
if(pos >= size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||||
|
"pos >= size()"});
|
||||||
|
return s_[pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Capacity
|
||||||
|
//
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
void
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
reserve(std::size_t n)
|
||||||
|
{
|
||||||
|
if(n > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"n > max_size()"});
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Operations
|
||||||
|
//
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
void
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
clear()
|
||||||
|
{
|
||||||
|
n_ = 0;
|
||||||
|
term();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
insert(size_type index, size_type count, CharT ch) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
if(index > size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||||
|
"index > size()"});
|
||||||
|
insert(begin() + index, count, ch);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
insert(size_type index, CharT const* s, size_type count) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
if(index > size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||||
|
"index > size()"});
|
||||||
|
if(size() + count > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"size() + count > max_size()"});
|
||||||
|
Traits::move(
|
||||||
|
&s_[index + count], &s_[index], size() - index);
|
||||||
|
n_ += count;
|
||||||
|
Traits::copy(&s_[index], s, count);
|
||||||
|
term();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<std::size_t M>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
insert(size_type index,
|
||||||
|
fixed_string<M, CharT, Traits> const& str,
|
||||||
|
size_type index_str, size_type count) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
auto const ss = str.substr(index_str, count);
|
||||||
|
return insert(index, ss.data(), ss.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
insert(const_iterator pos, size_type count, CharT ch) ->
|
||||||
|
iterator
|
||||||
|
{
|
||||||
|
if(size() + count > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"size() + count() > max_size()"});
|
||||||
|
auto const index = pos - &s_[0];
|
||||||
|
Traits::move(
|
||||||
|
&s_[index + count], &s_[index], size() - index);
|
||||||
|
n_ += count;
|
||||||
|
Traits::assign(&s_[index], count, ch);
|
||||||
|
term();
|
||||||
|
return &s_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<class InputIt>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
insert(const_iterator pos, InputIt first, InputIt last) ->
|
||||||
|
typename std::enable_if<
|
||||||
|
detail::is_input_iterator<InputIt>::value,
|
||||||
|
iterator>::type
|
||||||
|
{
|
||||||
|
std::size_t const count = std::distance(first, last);
|
||||||
|
if(size() + count > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"size() + count > max_size()"});
|
||||||
|
std::size_t const index = pos - begin();
|
||||||
|
Traits::move(
|
||||||
|
&s_[index + count], &s_[index], size() - index);
|
||||||
|
n_ += count;
|
||||||
|
for(auto it = begin() + index;
|
||||||
|
first != last; ++it, ++first)
|
||||||
|
Traits::assign(*it, *first);
|
||||||
|
term();
|
||||||
|
return begin() + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<class T>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
insert(size_type index, const T& t,
|
||||||
|
size_type index_str, size_type count) ->
|
||||||
|
typename std::enable_if<std::is_convertible<
|
||||||
|
T const&, string_view_type>::value &&
|
||||||
|
! std::is_convertible<T const&, CharT const*>::value,
|
||||||
|
fixed_string&>::type
|
||||||
|
{
|
||||||
|
auto const str =
|
||||||
|
string_view_type(t).substr(index_str, count);
|
||||||
|
return insert(index, str.data(), str.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
erase(size_type index, size_type count) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
if(index > size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||||
|
"index > size()"});
|
||||||
|
auto const n = (std::min)(count, size() - index);
|
||||||
|
Traits::move(
|
||||||
|
&s_[index], &s_[index + n], size() - (index + n) + 1);
|
||||||
|
n_ -= n;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
erase(const_iterator pos) ->
|
||||||
|
iterator
|
||||||
|
{
|
||||||
|
erase(pos - begin(), 1);
|
||||||
|
return begin() + (pos - begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
erase(const_iterator first, const_iterator last) ->
|
||||||
|
iterator
|
||||||
|
{
|
||||||
|
erase(first - begin(),
|
||||||
|
std::distance(first, last));
|
||||||
|
return begin() + (first - begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
void
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
push_back(CharT ch)
|
||||||
|
{
|
||||||
|
if(size() >= max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"size() >= max_size()"});
|
||||||
|
Traits::assign(s_[n_++], ch);
|
||||||
|
term();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<std::size_t M>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
append(fixed_string<M, CharT, Traits> const& str,
|
||||||
|
size_type pos, size_type count) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
// Valid range is [0, size)
|
||||||
|
if(pos >= str.size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||||
|
"pos > str.size()"});
|
||||||
|
string_view_type const ss{&str.s_[pos],
|
||||||
|
(std::min)(count, str.size() - pos)};
|
||||||
|
insert(size(), ss.data(), ss.size());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
substr(size_type pos, size_type count) const ->
|
||||||
|
string_view_type
|
||||||
|
{
|
||||||
|
if(pos > size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||||
|
"pos > size()"});
|
||||||
|
return{&s_[pos], (std::min)(count, size() - pos)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
copy(CharT* dest, size_type count, size_type pos) const ->
|
||||||
|
size_type
|
||||||
|
{
|
||||||
|
auto const str = substr(pos, count);
|
||||||
|
Traits::copy(dest, str.data(), str.size());
|
||||||
|
return str.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
void
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
resize(std::size_t n)
|
||||||
|
{
|
||||||
|
if(n > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"n > max_size()"});
|
||||||
|
if(n > n_)
|
||||||
|
Traits::assign(&s_[n_], n - n_, CharT{});
|
||||||
|
n_ = n;
|
||||||
|
term();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
void
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
resize(std::size_t n, CharT c)
|
||||||
|
{
|
||||||
|
if(n > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"n > max_size()"});
|
||||||
|
if(n > n_)
|
||||||
|
Traits::assign(&s_[n_], n - n_, c);
|
||||||
|
n_ = n;
|
||||||
|
term();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
void
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
swap(fixed_string& str)
|
||||||
|
{
|
||||||
|
fixed_string tmp(str);
|
||||||
|
str.n_ = n_;
|
||||||
|
Traits::copy(&str.s_[0], &s_[0], n_ + 1);
|
||||||
|
n_ = tmp.n_;
|
||||||
|
Traits::copy(&s_[0], &tmp.s_[0], n_ + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
template<std::size_t M>
|
||||||
|
void
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
swap(fixed_string<M, CharT, Traits>& str)
|
||||||
|
{
|
||||||
|
if(size() > str.max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"size() > str.max_size()"});
|
||||||
|
if(str.size() > max_size())
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"str.size() > max_size()"});
|
||||||
|
fixed_string tmp(str);
|
||||||
|
str.n_ = n_;
|
||||||
|
Traits::copy(&str.s_[0], &s_[0], n_ + 1);
|
||||||
|
n_ = tmp.n_;
|
||||||
|
Traits::copy(&s_[0], &tmp.s_[0], n_ + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign_char(CharT ch, std::true_type) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
n_ = 1;
|
||||||
|
Traits::assign(s_[0], ch);
|
||||||
|
term();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, class CharT, class Traits>
|
||||||
|
auto
|
||||||
|
fixed_string<N, CharT, Traits>::
|
||||||
|
assign_char(CharT, std::false_type) ->
|
||||||
|
fixed_string&
|
||||||
|
{
|
||||||
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
|
"max_size() == 0"});
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Integer, class>
|
||||||
|
fixed_string<detail::max_digits(sizeof(Integer))>
|
||||||
|
to_fixed_string(Integer x)
|
||||||
|
{
|
||||||
|
using CharT = char;
|
||||||
|
using Traits = std::char_traits<CharT>;
|
||||||
|
BOOST_STATIC_ASSERT(std::is_integral<Integer>::value);
|
||||||
|
char buf[detail::max_digits(sizeof(Integer))];
|
||||||
|
auto last = buf + sizeof(buf);
|
||||||
|
auto it = detail::raw_to_string<
|
||||||
|
CharT, Integer, Traits>(last, sizeof(buf), x);
|
||||||
|
fixed_string<detail::max_digits(sizeof(Integer))> s;
|
||||||
|
s.resize(static_cast<std::size_t>(last - it));
|
||||||
|
auto p = s.data();
|
||||||
|
while(it < last)
|
||||||
|
Traits::assign(*p++, *it++);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // fixed_string
|
||||||
|
} // boost
|
||||||
|
|
||||||
|
#endif
|
21
index.html
Normal file
21
index.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Boost.FixedString</title>
|
||||||
|
<meta http-equiv="refresh" content="0; URL=./doc/html/index.html">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Automatic redirection failed, please go to
|
||||||
|
<a href="./doc/html/index.html">./doc/html/index.html</a>
|
||||||
|
<hr>
|
||||||
|
<tt>
|
||||||
|
Boost.Beast<br>
|
||||||
|
<br>
|
||||||
|
Copyright (C) 2016 Vinnie Falco<br>
|
||||||
|
<br>
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
(See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
<a href=http://www.boost.org/LICENSE_1_0.txt>http://www.boost.org/LICENSE_1_0.txt</a>) <br>
|
||||||
|
<br>
|
||||||
|
</tt>
|
||||||
|
</body>
|
||||||
|
</html>
|
23
test/CMakeLists.txt
Normal file
23
test/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2016-2017 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/fixed_string
|
||||||
|
#
|
||||||
|
|
||||||
|
GroupSources (include/boost/fixed_string fixed_string)
|
||||||
|
GroupSources (test "/")
|
||||||
|
|
||||||
|
add_executable (tests
|
||||||
|
${PROJECT_FILES}
|
||||||
|
Jamfile
|
||||||
|
lib.cpp
|
||||||
|
fixed_string.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(tests
|
||||||
|
)
|
||||||
|
|
||||||
|
set_property(TARGET tests PROPERTY FOLDER "tests")
|
34
test/Jamfile
Normal file
34
test/Jamfile
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2016-2017 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/fixed_string
|
||||||
|
#
|
||||||
|
|
||||||
|
local SOURCES =
|
||||||
|
fixed_string.cpp
|
||||||
|
;
|
||||||
|
|
||||||
|
local RUN_TESTS ;
|
||||||
|
|
||||||
|
for local f in $(SOURCES)
|
||||||
|
{
|
||||||
|
RUN_TESTS += [ run $(f) lib.cpp ] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
alias run-tests : $(RUN_TESTS) ;
|
||||||
|
|
||||||
|
exe fat-tests :
|
||||||
|
$(SOURCES)
|
||||||
|
lib.cpp
|
||||||
|
;
|
||||||
|
|
||||||
|
explicit fat-tests ;
|
||||||
|
|
||||||
|
run $(SOURCES)
|
||||||
|
lib.cpp
|
||||||
|
: : : : run-fat-tests ;
|
||||||
|
|
||||||
|
explicit run-fat-tests ;
|
1481
test/fixed_string.cpp
Normal file
1481
test/fixed_string.cpp
Normal file
File diff suppressed because it is too large
Load Diff
11
test/lib.cpp
Normal file
11
test/lib.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) 2016-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/fixed_string
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/beast/_experimental/unit_test/main.ipp>
|
||||||
|
|
Reference in New Issue
Block a user