mirror of
https://github.com/boostorg/conversion.git
synced 2026-08-07 14:04:20 +02:00
Compare commits
81 Commits
boost-1.64.0
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 827dd94c68 | |||
| 782e083f61 | |||
| 1e6424563d | |||
| 6632ca9309 | |||
| b74a4c34cb | |||
| 452adac97f | |||
| 5f82d5aa7d | |||
| 9d64c899df | |||
| 35a71f0701 | |||
| 8a860e05d0 | |||
| 9f285ef0c4 | |||
| 5f36c2c710 | |||
| 41e62ed851 | |||
| 5cf5f78376 | |||
| 5a3587c988 | |||
| f7f3c9b5ce | |||
| 668030fcd6 | |||
| 0d60a3f7ce | |||
| 0ff5adc258 | |||
| 2598281d10 | |||
| a1104f580c | |||
| 9a03296816 | |||
| 7ba0984b34 | |||
| 4ae8b4d495 | |||
| 71b6a864a4 | |||
| b2a49138cf | |||
| 00f06d3549 | |||
| 968dfd47f1 | |||
| f0fe02f7d6 | |||
| 19b5a1cf29 | |||
| 1a2e4fd8ef | |||
| 8d1721f312 | |||
| c6ab56e983 | |||
| 1c62347706 | |||
| 56becb8fee | |||
| 67ae26b0f0 | |||
| d4e593120d | |||
| 76ed70b0b1 | |||
| 4b7d551907 | |||
| 9e3216d22f | |||
| 4e557d31d1 | |||
| 46695ffb86 | |||
| c1c098fac1 | |||
| b171fe1ff6 | |||
| a178d1a691 | |||
| 5176e189b8 | |||
| 49e6421271 | |||
| a0bfc39077 | |||
| 2bf2bba4be | |||
| f882ab890d | |||
| e0bb75e096 | |||
| 80b9240f2e | |||
| df86cb59c4 | |||
| 4fec53f3db | |||
| db398fc1c8 | |||
| 1576ff7be6 | |||
| 9540be42b4 | |||
| 7624b70a6d | |||
| 78fc22c66a | |||
| f1d5059c75 | |||
| f2e83915c3 | |||
| e0a40b7067 | |||
| 1dd1c98b79 | |||
| a1788bc31b | |||
| 58c33270a2 | |||
| e130cd860c | |||
| 9d4a518e74 | |||
| 1525157560 | |||
| 3421136ef0 | |||
| 441d4e4e1b | |||
| b3f8e9f014 | |||
| 24f2769eb7 | |||
| 6806d99529 | |||
| e38c0753ef | |||
| 6b3395e57d | |||
| 83e57ed513 | |||
| 56393150bb | |||
| e8d104f34d | |||
| a770ff87d7 | |||
| 29997a9fe1 | |||
| 2a0a2a59f5 |
@@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- feature/**
|
||||||
|
|
||||||
|
env:
|
||||||
|
UBSAN_OPTIONS: print_stacktrace=1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
posix:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below
|
||||||
|
cxxstd: "03,11,14,17,20"
|
||||||
|
os: ubuntu-24.04
|
||||||
|
- toolset: gcc-12
|
||||||
|
cxxstd: "03,11,14,17,2a"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
|
||||||
|
linkflags: "linkflags=--coverage -lasan -lubsan"
|
||||||
|
gcov_tool: "gcov-12"
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-14
|
||||||
|
cxxstd: "03,11,14,17,2a"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
if: matrix.install
|
||||||
|
run: sudo apt install ${{matrix.install}}
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
run: |
|
||||||
|
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||||
|
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||||
|
echo LIBRARY: $LIBRARY
|
||||||
|
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||||
|
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||||
|
echo GITHUB_REF: $GITHUB_REF
|
||||||
|
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||||
|
REF=${REF#refs/heads/}
|
||||||
|
echo REF: $REF
|
||||||
|
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||||
|
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||||
|
cd ..
|
||||||
|
git clone -b $BOOST_BRANCH --depth 10 https://github.com/boostorg/boost.git boost-root
|
||||||
|
cd boost-root
|
||||||
|
git submodule update --init --depth 10 --jobs 2 tools/boostdep tools/inspect libs/filesystem
|
||||||
|
python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 3" filesystem
|
||||||
|
rm -rf libs/$LIBRARY/*
|
||||||
|
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||||
|
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY
|
||||||
|
./bootstrap.sh
|
||||||
|
./b2 -j4 variant=debug tools/inspect
|
||||||
|
|
||||||
|
- name: Run CMake tests
|
||||||
|
if: ${{matrix.toolset == 'gcc-14'}}
|
||||||
|
run: |
|
||||||
|
cd ../boost-root/
|
||||||
|
mkdir __build
|
||||||
|
cd __build
|
||||||
|
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=conversion -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 ..
|
||||||
|
cmake --build . --target tests
|
||||||
|
ctest --output-on-failure --no-tests=error
|
||||||
|
cd ..
|
||||||
|
rm -rf __build
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release "${{matrix.cxxflags}}" "${{matrix.linkflags}}" "${{matrix.launcher}}"
|
||||||
|
dist/bin/inspect libs/$LIBRARY
|
||||||
|
|
||||||
|
- name: Prepare coverage data
|
||||||
|
if: matrix.gcov_tool
|
||||||
|
run: |
|
||||||
|
mkdir -p $GITHUB_WORKSPACE/coveralls
|
||||||
|
|
||||||
|
echo -e "#!/bin/bash\nexec ${{matrix.gcov_tool}} \"\$@\"" > $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
|
||||||
|
chmod +x $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
|
||||||
|
wget https://github.com/linux-test-project/lcov/archive/v1.16.zip
|
||||||
|
unzip v1.16.zip
|
||||||
|
LCOV="`pwd`/lcov-1.16/bin/lcov --gcov-tool $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh"
|
||||||
|
|
||||||
|
echo "$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory `pwd`/libs/$LIBRARY/test --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info"
|
||||||
|
$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory ../boost-root/ --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info
|
||||||
|
$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info "/usr*" "*/$LIBRARY/test/*" ${{matrix.ignore_coverage}} "*/$LIBRARY/tests/*" "*/$LIBRARY/examples/*" "*/$LIBRARY/example/*" -o $GITHUB_WORKSPACE/coveralls/coverage.info
|
||||||
|
|
||||||
|
cd ../boost-root
|
||||||
|
OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$LIBRARY\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
|
||||||
|
echo $OTHER_LIBS
|
||||||
|
eval "$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info $OTHER_LIBS -o $GITHUB_WORKSPACE/coveralls/coverage.info"
|
||||||
|
|
||||||
|
- name: Coveralls
|
||||||
|
uses: coverallsapp/github-action@master
|
||||||
|
if: matrix.gcov_tool
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
path-to-lcov: ./coveralls/coverage.info
|
||||||
|
parallel: true
|
||||||
|
|
||||||
|
windows:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- toolset: msvc-14.3
|
||||||
|
cxxstd: "14,17,latest"
|
||||||
|
addrmd: 32,64
|
||||||
|
os: windows-2025
|
||||||
|
- toolset: gcc
|
||||||
|
cxxstd: "03,11,14,17,2a"
|
||||||
|
addrmd: 64
|
||||||
|
os: windows-2025
|
||||||
|
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- 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 10 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 --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY%
|
||||||
|
cmd /c bootstrap
|
||||||
|
|
||||||
|
- name: Run CMake tests
|
||||||
|
if: ${{matrix.toolset == 'msvc-14.3'}}
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
choco install --no-progress ninja
|
||||||
|
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64
|
||||||
|
cd ../boost-root/
|
||||||
|
mkdir __build
|
||||||
|
cd __build
|
||||||
|
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=conversion ..
|
||||||
|
cmake --build . --target tests --config Debug
|
||||||
|
ctest --output-on-failure --no-tests=error -C Debug
|
||||||
|
cd ..
|
||||||
|
rm -rf __build
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
cd ../boost-root
|
||||||
|
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
|
||||||
|
|
||||||
|
finish:
|
||||||
|
needs: posix
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Coveralls Finished
|
||||||
|
uses: coverallsapp/github-action@master
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.github_token }}
|
||||||
|
parallel-finished: true
|
||||||
-119
@@ -1,119 +0,0 @@
|
|||||||
# Use, modification, and distribution are
|
|
||||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
#
|
|
||||||
# Copyright Antony Polukhin 2014-2016.
|
|
||||||
|
|
||||||
#
|
|
||||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
|
||||||
# and how it can be used with Boost libraries.
|
|
||||||
#
|
|
||||||
# File revision #7
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
language: cpp
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
# - clang
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
# Autodetect Boost branch by using the following code: - BRANCH_TO_TEST=$TRAVIS_BRANCH
|
|
||||||
# or just directly specify it
|
|
||||||
- BRANCH_TO_TEST=$TRAVIS_BRANCH
|
|
||||||
|
|
||||||
# Files, which coverage results must be ignored (files from other projects).
|
|
||||||
# Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/*'
|
|
||||||
- IGNORE_COVERAGE=''
|
|
||||||
|
|
||||||
# Explicitly remove the following library from Boost. This may be usefull, if you're for example running Travis
|
|
||||||
# from `Boost.DLL` repo, while Boost already has `dll`.
|
|
||||||
#
|
|
||||||
# By default is eaual to - BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
|
|
||||||
# This will force to use local repo content, instead of the Boost's default.
|
|
||||||
- BOOST_REMOVE=$(basename $TRAVIS_BUILD_DIR)
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
# Note that "--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD" are added automatically lower in code
|
|
||||||
- CXX_FLAGS="-std=c++98" LINK_FLAGS="" TOOLSET=gcc-6
|
|
||||||
- CXX_FLAGS="-std=c++11" LINK_FLAGS="" TOOLSET=gcc-6
|
|
||||||
- CXX_FLAGS="-std=c++1y" LINK_FLAGS="" TOOLSET=gcc-6
|
|
||||||
#- CXX_FLAGS="-std=c++11 -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
|
|
||||||
#- CXX_FLAGS="-std=c++1y -stdlib=libc++" LINK_FLAGS="-stdlib=libc++" TOOLSET=clang
|
|
||||||
|
|
||||||
###############################################################################################################
|
|
||||||
# From this point and below code is same for all the Boost libs
|
|
||||||
###############################################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
# Installing additional tools
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- git-core
|
|
||||||
packages:
|
|
||||||
- git
|
|
||||||
- python-yaml
|
|
||||||
- gcc-6
|
|
||||||
- g++-6
|
|
||||||
- clang
|
|
||||||
- libc++-dev
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
# Set this to the name of the library
|
|
||||||
- PROJECT_TO_TEST=`basename $TRAVIS_BUILD_DIR`
|
|
||||||
# Cloning Boost libraries (fast nondeep cloning)
|
|
||||||
- BOOST=$HOME/boost-local
|
|
||||||
- echo "Testing $PROJECT_TO_TEST, to remove $BOOST/libs/$BOOST_REMOVE, testing branch $BRANCH_TO_TEST"
|
|
||||||
- git init $BOOST
|
|
||||||
- cd $BOOST
|
|
||||||
- git remote add --no-tags -t $BRANCH_TO_TEST origin https://github.com/boostorg/boost.git
|
|
||||||
- git fetch --depth=1
|
|
||||||
- git checkout $BRANCH_TO_TEST
|
|
||||||
- git submodule update --jobs=3 --init --merge
|
|
||||||
- git remote set-branches --add origin $BRANCH_TO_TEST
|
|
||||||
- git pull --recurse-submodules
|
|
||||||
- git status
|
|
||||||
- rm -rf $BOOST/libs/$BOOST_REMOVE
|
|
||||||
- mv $TRAVIS_BUILD_DIR $BOOST/libs/$PROJECT_TO_TEST
|
|
||||||
- TRAVIS_BUILD_DIR=$BOOST/libs/$PROJECT_TO_TEST
|
|
||||||
- ./bootstrap.sh
|
|
||||||
- ./b2 headers
|
|
||||||
- cd $BOOST/libs/$PROJECT_TO_TEST/test/
|
|
||||||
|
|
||||||
script:
|
|
||||||
# `--coverage` flags required to generate coverage info for Coveralls
|
|
||||||
- ../../../b2 "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.3 " address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="--coverage -fsanitize=address,leak,undefined -DBOOST_TRAVISCI_BUILD $CXX_FLAGS" linkflags="$LINK_FLAGS --coverage -lasan -lubsan"
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
# Copying Coveralls data to a separate folder
|
|
||||||
- mkdir -p $TRAVIS_BUILD_DIR/coverals
|
|
||||||
- find ../../../bin.v2/ -name "*.gcda" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
|
||||||
- find ../../../bin.v2/ -name "*.gcno" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
|
||||||
- find ../../../bin.v2/ -name "*.da" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
|
||||||
- find ../../../bin.v2/ -name "*.no" -exec cp "{}" $TRAVIS_BUILD_DIR/coverals/ \;
|
|
||||||
- wget https://github.com/linux-test-project/lcov/archive/v1.12.zip
|
|
||||||
- unzip v1.12.zip
|
|
||||||
- LCOV="`pwd`/lcov-1.12/bin/lcov --gcov-tool gcov-6"
|
|
||||||
|
|
||||||
# Preparing Coveralls data by changind data format to a readable one
|
|
||||||
- echo "$LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info"
|
|
||||||
- $LCOV --directory $TRAVIS_BUILD_DIR/coverals --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info
|
|
||||||
|
|
||||||
# ... erasing /test/ /example/ folder data
|
|
||||||
- cd $BOOST
|
|
||||||
- $LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info "/usr*" "*/$PROJECT_TO_TEST/test/*" $IGNORE_COVERAGE "*/$PROJECT_TO_TEST/tests/*" "*/$PROJECT_TO_TEST/examples/*" "*/$PROJECT_TO_TEST/example/*" -o $TRAVIS_BUILD_DIR/coverals/coverage.info
|
|
||||||
|
|
||||||
# ... erasing data that is not related to this project directly
|
|
||||||
- OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$PROJECT_TO_TEST\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
|
|
||||||
- echo $OTHER_LIBS
|
|
||||||
- eval "$LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info $OTHER_LIBS -o $TRAVIS_BUILD_DIR/coverals/coverage.info"
|
|
||||||
|
|
||||||
# Sending data to Coveralls
|
|
||||||
- cd $TRAVIS_BUILD_DIR
|
|
||||||
- gem install coveralls-lcov
|
|
||||||
- coveralls-lcov coverals/coverage.info
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Copyright 2019 Mike Dev
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.5...4.20 )
|
||||||
|
project( boost_conversion VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
|
||||||
|
|
||||||
|
add_library( boost_conversion INTERFACE )
|
||||||
|
add_library( Boost::conversion ALIAS boost_conversion )
|
||||||
|
|
||||||
|
target_include_directories( boost_conversion INTERFACE include )
|
||||||
|
|
||||||
|
target_link_libraries( boost_conversion
|
||||||
|
INTERFACE
|
||||||
|
Boost::assert
|
||||||
|
Boost::config
|
||||||
|
Boost::throw_exception
|
||||||
|
)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
#[Boost.Conversion](http://boost.org/libs/conversion)
|
# [Boost.Conversion](https://boost.org/libs/conversion)
|
||||||
Boost.Conversion is one of the [Boost C++ Libraries](http://github.com/boostorg). This library improves program safety and clarity by performing otherwise messy conversions.
|
Boost.Conversion is one of the [Boost C++ Libraries](https://github.com/boostorg). This library improves program safety and clarity by performing otherwise messy conversions.
|
||||||
|
|
||||||
### Test results
|
### Test results
|
||||||
|
|
||||||
@ | Build | Tests coverage | More info
|
@ | Build | Tests coverage | More info
|
||||||
----------------|-------------- | -------------- |-----------
|
----------------|-------------- | -------------- |-----------
|
||||||
Develop branch: | [](https://travis-ci.org/apolukhin/conversion) [](https://ci.appveyor.com/project/apolukhin/conversion/branch/develop) | [](https://coveralls.io/r/apolukhin/conversion?branch=develop) | [details...](http://www.boost.org/development/tests/develop/developer/conversion.html)
|
Develop branch: | [](https://github.com/boostorg/conversion/actions/workflows/ci.yml) [](https://ci.appveyor.com/project/apolukhin/conversion/branch/develop) | [](https://coveralls.io/github/boostorg/conversion?branch=develop) | [details...](https://regression.boost.io/develop/developer/conversion.html)
|
||||||
Master branch: | [](https://travis-ci.org/apolukhin/conversion) [](https://ci.appveyor.com/project/apolukhin/conversion/branch/master) | [](https://coveralls.io/r/apolukhin/conversion?branch=master) | [details...](http://www.boost.org/development/tests/master/developer/conversion.html)
|
Master branch: | [](https://github.com/boostorg/conversion/actions/workflows/ci.yml) [](https://ci.appveyor.com/project/apolukhin/conversion/branch/master) | [](https://coveralls.io/github/boostorg/conversion?branch=master) | [details...](https://regression.boost.io/master/developer/conversion.html)
|
||||||
|
|
||||||
|
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/conversion.html)
|
||||||
[Open Issues](https://svn.boost.org/trac/boost/query?status=!closed&component=conversion&or&status=!closed&component=lexical_cast)
|
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
|
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# 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/throw_exception//boost_throw_exception ;
|
||||||
|
|
||||||
|
project /boost/conversion
|
||||||
|
: common-requirements
|
||||||
|
<include>include
|
||||||
|
;
|
||||||
|
|
||||||
|
explicit
|
||||||
|
[ alias boost_conversion : : : : <library>$(boost_dependencies) ]
|
||||||
|
[ alias all : boost_conversion test ]
|
||||||
|
;
|
||||||
|
|
||||||
|
call-if : boost-library conversion
|
||||||
|
;
|
||||||
|
|
||||||
+92
-74
@@ -1,5 +1,7 @@
|
|||||||
[/
|
[/
|
||||||
Copyright 2016 Mikhail Maximov.
|
Copyright 2016 Mikhail Maximov.
|
||||||
|
Copyright Antony Polukhin, 2020-2026.
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)
|
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>)
|
||||||
]
|
]
|
||||||
@@ -8,15 +10,15 @@
|
|||||||
[quickbook 1.6]
|
[quickbook 1.6]
|
||||||
[compatibility-mode 1.5]
|
[compatibility-mode 1.5]
|
||||||
[id conversion]
|
[id conversion]
|
||||||
[version 1.6]
|
[version 1.7]
|
||||||
[authors [Stroustrup, Bjarne], [Abrahams, Dave], [Rasin, Boris], [Polukhin, Antony]]
|
[authors [Stroustrup, Bjarne], [Abrahams, Dave], [Rasin, Boris], [Polukhin, Antony]]
|
||||||
[copyright 2001 Beman Dawes]
|
[copyright 2001 Beman Dawes, 2014-2026 Antony Polukhin]
|
||||||
[license
|
[license
|
||||||
Distributed under the Boost Software License, Version 1.0.
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
(See accompanying file LICENSE_1_0.txt or copy at
|
(See accompanying file LICENSE_1_0.txt or copy at
|
||||||
[@http://www.boost.org/LICENSE_1_0.txt])
|
[@http://www.boost.org/LICENSE_1_0.txt])
|
||||||
]
|
]
|
||||||
[source-mode teletype]
|
[source-mode c++]
|
||||||
]
|
]
|
||||||
|
|
||||||
[/ QuickBook Document version 1.5 ]
|
[/ QuickBook Document version 1.5 ]
|
||||||
@@ -28,8 +30,7 @@ The Conversion Library improves program safety and clarity by performing
|
|||||||
otherwise messy conversions. It includes cast-style function templates designed
|
otherwise messy conversions. It includes cast-style function templates designed
|
||||||
to complement the C++ Standard's built-in casts.
|
to complement the C++ Standard's built-in casts.
|
||||||
|
|
||||||
To reduce coupling, particularly to standard library IOStreams,
|
To reduce coupling, the Boost Conversion Library is supplied by several headers:
|
||||||
the Boost Conversion Library is supplied by several headers:
|
|
||||||
|
|
||||||
# The [@boost:boost/polymorphic_cast.hpp boost/polymorphic_cast.hpp] header
|
# The [@boost:boost/polymorphic_cast.hpp boost/polymorphic_cast.hpp] header
|
||||||
provides [link polymorphic_cast `polymorphic_cast<>`] and
|
provides [link polymorphic_cast `polymorphic_cast<>`] and
|
||||||
@@ -40,11 +41,9 @@ the Boost Conversion Library is supplied by several headers:
|
|||||||
[link polymorphic_pointer_cast `polymorphic_pointer_downcast<>`]
|
[link polymorphic_pointer_cast `polymorphic_pointer_downcast<>`]
|
||||||
# The [@boost:boost/implicit_cast.hpp boost/implicit_cast.hpp] header provides `implicit_cast<>`
|
# The [@boost:boost/implicit_cast.hpp boost/implicit_cast.hpp] header provides `implicit_cast<>`
|
||||||
to perform implicit casts only (no down-cast, no void*->T*, no U->T if T has only explicit constructors for U).
|
to perform implicit casts only (no down-cast, no void*->T*, no U->T if T has only explicit constructors for U).
|
||||||
# The [@boost:boost/lexical_cast.hpp boost/lexical_cast.hpp] header
|
|
||||||
provides [@boost:libs/lexical_cast/doc/html/index.html `lexical_cast<>`] general literal text conversions, such as an `int` represented as a `string`, or vice-versa.
|
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[section Polymorphic casts]
|
[section Polymorphic casts]
|
||||||
Pointers to polymorphic objects (objects of classes which define at
|
Pointers to polymorphic objects (objects of classes which define at
|
||||||
least one virtual function) are sometimes downcast or crosscast.
|
least one virtual function) are sometimes downcast or crosscast.
|
||||||
@@ -58,6 +57,7 @@ safety, suffer poor readability, and are difficult to locate with search
|
|||||||
tools.
|
tools.
|
||||||
|
|
||||||
[#polymorphic_downcast]
|
[#polymorphic_downcast]
|
||||||
|
[section polymorphic_downcast]
|
||||||
|
|
||||||
The C++ built-in `static_cast` can be used for efficiently
|
The C++ built-in `static_cast` can be used for efficiently
|
||||||
downcasting pointers to polymorphic objects, but provides no error
|
downcasting pointers to polymorphic objects, but provides no error
|
||||||
@@ -68,11 +68,11 @@ debug compilations adds safety via an `assert()` that a `dynamic_cast`
|
|||||||
succeeds.
|
succeeds.
|
||||||
|
|
||||||
A `polymorphic_downcast` should be used for
|
A `polymorphic_downcast` should be used for
|
||||||
downcasts that you are certain should succeed. Error checking is
|
downcasts that you are certain should succeed. Error checking is
|
||||||
only performed in translation units where `NDEBUG` is
|
only performed in translation units where `NDEBUG` is
|
||||||
not defined, via
|
not defined, via
|
||||||
```
|
```
|
||||||
assert( dynamic_cast<Derived>(x) == x )
|
assert( dynamic_cast<Derived>(x) == x )
|
||||||
```
|
```
|
||||||
where `x` is the source pointer. This approach
|
where `x` is the source pointer. This approach
|
||||||
ensures that not only is a non-zero pointer returned, but also
|
ensures that not only is a non-zero pointer returned, but also
|
||||||
@@ -81,17 +81,33 @@ Attempts to crosscast using `polymorphic_downcast` will
|
|||||||
fail to compile.
|
fail to compile.
|
||||||
|
|
||||||
[warning Because `polymorphic_downcast` uses `assert()`, it
|
[warning Because `polymorphic_downcast` uses `assert()`, it
|
||||||
violates the One Definition Rule (ODR) if NDEBUG is inconsistently
|
violates the One Definition Rule (ODR) if `NDEBUG` is inconsistently
|
||||||
defined across translation units. See ISO Std 3.2]
|
defined across translation units. See ISO Std 3.2]
|
||||||
|
|
||||||
|
[h4 Example:]
|
||||||
|
```
|
||||||
|
#include <boost/polymorphic_cast.hpp>
|
||||||
|
...
|
||||||
|
class Fruit { public: virtual ~Fruit(){}; ... };
|
||||||
|
class Banana : public Fruit { ... };
|
||||||
|
...
|
||||||
|
void f( Fruit * fruit ) {
|
||||||
|
// ... logic which leads us to believe it is a Banana
|
||||||
|
Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
[endsect]
|
||||||
|
|
||||||
[#polymorphic_cast]
|
[#polymorphic_cast]
|
||||||
|
[section polymorphic_cast]
|
||||||
|
|
||||||
The C++ built-in `dynamic_cast` can be used for downcasts and
|
The C++ built-in `dynamic_cast` can be used for downcasts and
|
||||||
crosscasts of pointers to polymorphic objects, but error notification in
|
crosscasts of pointers to polymorphic objects, but error notification in
|
||||||
the form of a returned value of 0 is inconvenient to test, or worse yet,
|
the form of a returned value of 0 is inconvenient to test, or worse yet,
|
||||||
easy to forget to test. The throwing form of `dynamic_cast`, which
|
easy to forget to test. The throwing form of `dynamic_cast`, which
|
||||||
works on references, can be used on pointers through the ugly expression
|
works on references, can be used on pointers through the ugly expression
|
||||||
`&dynamic_cast<T&>(*p), which causes undefined
|
`&dynamic_cast<T&>(*p)`, which causes undefined
|
||||||
behavior if `p` is `0`. The `polymorphic_cast`
|
behavior if `p` is `0`. The `polymorphic_cast`
|
||||||
template performs a `dynamic_cast` on a pointer, and throws an
|
template performs a `dynamic_cast` on a pointer, and throws an
|
||||||
exception if the `dynamic_cast` returns 0.
|
exception if the `dynamic_cast` returns 0.
|
||||||
@@ -99,91 +115,91 @@ exception if the `dynamic_cast` returns 0.
|
|||||||
For crosscasts, or when the success of a cast can only be known at runtime,
|
For crosscasts, or when the success of a cast can only be known at runtime,
|
||||||
or when efficiency is not important, `polymorphic_cast` is preferred.
|
or when efficiency is not important, `polymorphic_cast` is preferred.
|
||||||
|
|
||||||
The C++ built-in dynamic_cast must be used to cast references rather than pointers.
|
The C++ built-in `dynamic_cast` must be used to cast references rather than pointers.
|
||||||
It is also the only cast that can be used to check whether a given interface is supported; in that case a return of 0 isn't an error condition.
|
It is also the only cast that can be used to check whether a given interface is supported; in that case a return of 0 isn't an error condition.
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
|
||||||
[#polymorphic_pointer_cast]
|
[#polymorphic_pointer_cast]
|
||||||
While polymorphic_downcast and polymorphic_cast work with built-in pointer types only,
|
[section polymorphic_pointer_cast]
|
||||||
polymorphic_pointer_downcast and polymorphic_pointer_cast are more generic versions
|
While `polymorphic_downcast` and `polymorphic_cast` work with built-in pointer types only,
|
||||||
|
`polymorphic_pointer_downcast` and `polymorphic_pointer_cast` are more generic versions
|
||||||
with support for any pointer type for which the following expressions would be valid:
|
with support for any pointer type for which the following expressions would be valid:
|
||||||
|
|
||||||
For `polymorphic_pointer_downcast`:
|
For `polymorphic_pointer_downcast`:
|
||||||
```
|
```
|
||||||
static_pointer_cast<Derived>(p);
|
static_pointer_cast<Derived>(p);
|
||||||
dynamic_pointer_cast<Derived>(p);
|
dynamic_pointer_cast<Derived>(p);
|
||||||
```
|
```
|
||||||
For `polymorphic_pointer_cast`:
|
For `polymorphic_pointer_cast`:
|
||||||
```
|
```
|
||||||
dynamic_pointer_cast<Derived>(p);
|
dynamic_pointer_cast<Derived>(p);
|
||||||
!p; // conversion to bool with negation
|
!p; // conversion to bool with negation
|
||||||
```
|
```
|
||||||
|
|
||||||
This includes C++ built-in pointers, `std::shared_ptr`,
|
This includes C++ built-in pointers, `std::shared_ptr`,
|
||||||
`boost::shared_ptr`, `boost::intrusive_ptr`, etc.
|
`boost::shared_ptr`, `boost::intrusive_ptr`, etc.
|
||||||
|
|
||||||
[endsect]
|
|
||||||
[section `polymorphic_cast`, `polymorphic_downcast`, `polymorphic_pointer_cast` and `polymorphic_pointer_downcast` synopsis]
|
[h4 Example:]
|
||||||
```
|
```
|
||||||
namespace boost {
|
#include <boost/polymorphic_pointer_cast.hpp>
|
||||||
|
|
||||||
template <class Derived, class Base>
|
class Fruit { public: virtual ~Fruit(){} };
|
||||||
inline Derived polymorphic_cast(Base* x);
|
class Banana : public Fruit {};
|
||||||
// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
|
|
||||||
// Returns: dynamic_cast<Derived>(x)
|
|
||||||
|
|
||||||
template <class Derived, class Base>
|
// Use one of these:
|
||||||
inline Derived polymorphic_downcast(Base* x);
|
using FruitPtr = Fruit*;
|
||||||
// Effects: assert( dynamic_cast<Derived>(x) == x );
|
using FruitPtr = std::shared_ptr<Fruit>;
|
||||||
// Returns: static_cast<Derived>(x)
|
using FruitPtr = boost::shared_ptr<Fruit>;
|
||||||
|
using FruitPtr = boost::intrusive_ptr<Fruit>;
|
||||||
|
|
||||||
template <class Derived, class Base>
|
void f(FruitPtr fruit) {
|
||||||
inline auto polymorphic_pointer_cast(Base x);
|
// ... logic which leads us to believe it is a banana
|
||||||
// Throws: std::bad_cast if ( dynamic_pointer_cast<Derived>(x) == 0 )
|
auto banana = boost::polymorphic_pointer_downcast<Banana>(fruit);
|
||||||
// Returns: dynamic_pointer_cast<Derived>(x)
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
template <class Derived, class Base>
|
[endsect]
|
||||||
inline auto polymorphic_pointer_downcast(Base x);
|
|
||||||
// Effects: assert( dynamic_pointer_cast<Derived>(x) == x );
|
|
||||||
// Returns: static_pointer_cast<Derived>(x)
|
|
||||||
|
|
||||||
}
|
[endsect]
|
||||||
|
|
||||||
|
[section Synopsis]
|
||||||
|
```
|
||||||
|
namespace boost {
|
||||||
|
|
||||||
|
// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
|
||||||
|
// Returns: dynamic_cast<Derived>(x)
|
||||||
|
template <class Derived, class Base>
|
||||||
|
constexpr Derived polymorphic_cast(Base* x);
|
||||||
|
|
||||||
|
// Effects: assert( dynamic_cast<Derived>(x) == x );
|
||||||
|
// Returns: static_cast<Derived>(x)
|
||||||
|
template <class Derived, class Base>
|
||||||
|
constexpr Derived polymorphic_downcast(Base* x);
|
||||||
|
|
||||||
|
// Effects: assert( dynamic_cast<Derived>(&x) == &x );
|
||||||
|
// Returns: static_cast<Derived>(x)
|
||||||
|
template <class Derived, class Base>
|
||||||
|
constexpr Derived polymorphic_downcast(Base& x);
|
||||||
|
|
||||||
|
// Throws: std::bad_cast if ( dynamic_pointer_cast<Derived>(x) == 0 )
|
||||||
|
// Returns: dynamic_pointer_cast<Derived>(x)
|
||||||
|
template <class Derived, class Base>
|
||||||
|
inline auto polymorphic_pointer_cast(Base x);
|
||||||
|
|
||||||
|
// Effects: assert( dynamic_pointer_cast<Derived>(x) == x );
|
||||||
|
// Returns: static_pointer_cast<Derived>(x)
|
||||||
|
template <class Derived, class Base>
|
||||||
|
inline auto polymorphic_pointer_downcast(Base x);
|
||||||
|
|
||||||
|
}
|
||||||
```
|
```
|
||||||
[endsect]
|
[endsect]
|
||||||
[section `polymorphic_downcast` example]
|
|
||||||
```
|
|
||||||
#include <boost/polymorphic_cast.hpp>
|
|
||||||
...
|
|
||||||
class Fruit { public: virtual ~Fruit(){}; ... };
|
|
||||||
class Banana : public Fruit { ... };
|
|
||||||
...
|
|
||||||
void f( Fruit * fruit ) {
|
|
||||||
// ... logic which leads us to believe it is a Banana
|
|
||||||
Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
[endsect]
|
|
||||||
[section `polymorphic_pointer_downcast` example]
|
|
||||||
```
|
|
||||||
#include <boost/polymorphic_pointer_cast.hpp>
|
|
||||||
|
|
||||||
class Fruit { public: virtual ~Fruit(){} };
|
|
||||||
class Banana : public Fruit {};
|
|
||||||
|
|
||||||
// use one of these:
|
|
||||||
|
|
||||||
typedef Fruit* FruitPtr;
|
|
||||||
typedef std::shared_ptr<Fruit> FruitPtr;
|
|
||||||
typedef boost::shared_ptr<Fruit> FruitPtr;
|
|
||||||
typedef boost::intrusive_ptr<Fruit> FruitPtr;
|
|
||||||
|
|
||||||
void f(FruitPtr fruit) {
|
|
||||||
// ... logic which leads us to believe it is a banana
|
|
||||||
auto banana = boost::polymorphic_pointer_downcast<Banana>(fruit);
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
[endsect]
|
|
||||||
[section History]
|
[section History]
|
||||||
`polymorphic_cast` was suggested by Bjarne Stroustrup in "The C++ Programming Language".
|
`polymorphic_cast` was suggested by Bjarne Stroustrup in "The C++ Programming Language".
|
||||||
|
|
||||||
@@ -192,6 +208,8 @@ This includes C++ built-in pointers, `std::shared_ptr`,
|
|||||||
`polymorphic_pointer_downcast` was contributed by [@http://www.boost.org/people/boris_rasin.htm Boris Rasin]
|
`polymorphic_pointer_downcast` was contributed by [@http://www.boost.org/people/boris_rasin.htm Boris Rasin]
|
||||||
and `polymorphic_pointer_cast` by Antony Polukhin.
|
and `polymorphic_pointer_cast` by Antony Polukhin.
|
||||||
|
|
||||||
An old numeric_cast that was contributed by [@http://www.boost.org/people/kevlin_henney.htm Kevlin Henney]
|
`polymorphic_downcast` overload for references was contributed by Julien Delacroix.
|
||||||
is now superseeded by the [@boost:numeric_conversion/doc/html/html/boost_numericconversion/improved_numeric_cast__.html Boost Numeric Conversion Library]
|
|
||||||
|
An old `numeric_cast` that was contributed by [@http://www.boost.org/people/kevlin_henney.htm Kevlin Henney]
|
||||||
|
is now superseded by the [@boost:numeric_conversion/doc/html/html/boost_numericconversion/improved_numeric_cast__.html Boost Numeric Conversion Library]
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -2,8 +2,14 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#ifndef IMPLICIT_CAST_DWA200356_HPP
|
|
||||||
# define IMPLICIT_CAST_DWA200356_HPP
|
#ifndef BOOST_IMPLICIT_CAST_DWA200356_HPP
|
||||||
|
#define BOOST_IMPLICIT_CAST_DWA200356_HPP
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
@@ -11,7 +17,7 @@ namespace detail {
|
|||||||
|
|
||||||
template<class T> struct icast_identity
|
template<class T> struct icast_identity
|
||||||
{
|
{
|
||||||
typedef T type;
|
using type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
@@ -22,15 +28,11 @@ template<class T> struct icast_identity
|
|||||||
// The use of identity creates a non-deduced form, so that the
|
// The use of identity creates a non-deduced form, so that the
|
||||||
// explicit template argument must be supplied
|
// explicit template argument must be supplied
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
|
constexpr T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// incomplete return type now is here
|
|
||||||
//template <typename T>
|
|
||||||
//void implicit_cast (...);
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
#endif // IMPLICIT_CAST_DWA200356_HPP
|
#endif // BOOST_IMPLICIT_CAST_DWA200356_HPP
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// 08 Nov 14 Add polymorphic_pointer_downcast (Boris Rasin)
|
// 08 Nov 14 Add polymorphic_pointer_downcast (Boris Rasin)
|
||||||
// 09 Jun 14 "cast.hpp" was renamed to "polymorphic_cast.hpp" and
|
// 09 Jun 14 "cast.hpp" was renamed to "polymorphic_cast.hpp" and
|
||||||
// inclusion of numeric_cast was removed (Antony Polukhin)
|
// inclusion of numeric_cast was removed (Antony Polukhin)
|
||||||
// 23 Jun 05 numeric_cast removed and redirected to the new verion (Fernando Cacciola)
|
// 23 Jun 05 numeric_cast removed and redirected to the new version (Fernando Cacciola)
|
||||||
// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included
|
// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included
|
||||||
// <boost/limits.hpp> instead (the workaround did not
|
// <boost/limits.hpp> instead (the workaround did not
|
||||||
// actually compile when BOOST_NO_LIMITS was defined in
|
// actually compile when BOOST_NO_LIMITS was defined in
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams)
|
// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams)
|
||||||
// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC
|
// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC
|
||||||
// (Dave Abrahams)
|
// (Dave Abrahams)
|
||||||
// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams)
|
// 30 Jun 00 More MSVC6 workarounds. See comments below. (Dave Abrahams)
|
||||||
// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes)
|
// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes)
|
||||||
// 27 Jun 00 More MSVC6 workarounds
|
// 27 Jun 00 More MSVC6 workarounds
|
||||||
// 15 Jun 00 Add workarounds for MSVC6
|
// 15 Jun 00 Add workarounds for MSVC6
|
||||||
@@ -49,15 +49,25 @@
|
|||||||
#ifndef BOOST_POLYMORPHIC_CAST_HPP
|
#ifndef BOOST_POLYMORPHIC_CAST_HPP
|
||||||
#define BOOST_POLYMORPHIC_CAST_HPP
|
#define BOOST_POLYMORPHIC_CAST_HPP
|
||||||
|
|
||||||
# include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# include <boost/assert.hpp>
|
|
||||||
# include <boost/throw_exception.hpp>
|
|
||||||
# include <typeinfo>
|
|
||||||
|
|
||||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
# include <boost/assert.hpp>
|
||||||
|
# include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
|
# include <memory> // std::addressof
|
||||||
|
# include <typeinfo>
|
||||||
|
# include <type_traits>
|
||||||
|
|
||||||
|
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
|
||||||
|
#define BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST constexpr
|
||||||
|
#else
|
||||||
|
#define BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST inline
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
// See the documentation for descriptions of how to choose between
|
// See the documentation for descriptions of how to choose between
|
||||||
@@ -70,7 +80,7 @@ namespace boost
|
|||||||
// section 15.8 exercise 1, page 425.
|
// section 15.8 exercise 1, page 425.
|
||||||
|
|
||||||
template <class Target, class Source>
|
template <class Target, class Source>
|
||||||
inline Target polymorphic_cast(Source* x)
|
BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST Target polymorphic_cast(Source* x)
|
||||||
{
|
{
|
||||||
Target tmp = dynamic_cast<Target>(x);
|
Target tmp = dynamic_cast<Target>(x);
|
||||||
if ( tmp == 0 ) boost::throw_exception( std::bad_cast() );
|
if ( tmp == 0 ) boost::throw_exception( std::bad_cast() );
|
||||||
@@ -79,7 +89,7 @@ namespace boost
|
|||||||
|
|
||||||
// polymorphic_downcast ----------------------------------------------------//
|
// polymorphic_downcast ----------------------------------------------------//
|
||||||
|
|
||||||
// BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited.
|
// BOOST_ASSERT() checked raw pointer polymorphic downcast. Crosscasts prohibited.
|
||||||
|
|
||||||
// WARNING: Because this cast uses BOOST_ASSERT(), it violates
|
// WARNING: Because this cast uses BOOST_ASSERT(), it violates
|
||||||
// the One Definition Rule if used in multiple translation units
|
// the One Definition Rule if used in multiple translation units
|
||||||
@@ -89,12 +99,34 @@ namespace boost
|
|||||||
// Contributed by Dave Abrahams
|
// Contributed by Dave Abrahams
|
||||||
|
|
||||||
template <class Target, class Source>
|
template <class Target, class Source>
|
||||||
inline Target polymorphic_downcast(Source* x)
|
BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST Target polymorphic_downcast(Source* x)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( dynamic_cast<Target>(x) == x ); // detect logic error
|
BOOST_ASSERT( dynamic_cast<Target>(x) == x ); // detect logic error
|
||||||
return static_cast<Target>(x);
|
return static_cast<Target>(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BOOST_ASSERT() checked reference polymorphic downcast. Crosscasts prohibited.
|
||||||
|
|
||||||
|
// WARNING: Because this cast uses BOOST_ASSERT(), it violates
|
||||||
|
// the One Definition Rule if used in multiple translation units
|
||||||
|
// where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER
|
||||||
|
// NDEBUG are defined inconsistently.
|
||||||
|
|
||||||
|
// Contributed by Julien Delacroix
|
||||||
|
|
||||||
|
template <class Target, class Source>
|
||||||
|
BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST typename std::enable_if<
|
||||||
|
std::is_reference<Target>::value, Target
|
||||||
|
>::type polymorphic_downcast(Source& x)
|
||||||
|
{
|
||||||
|
using target_pointer_type = typename std::remove_reference<Target>::type*;
|
||||||
|
return *boost::polymorphic_downcast<target_pointer_type>(
|
||||||
|
std::addressof(x)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
#undef BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST
|
||||||
|
|
||||||
#endif // BOOST_POLYMORPHIC_CAST_HPP
|
#endif // BOOST_POLYMORPHIC_CAST_HPP
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// boost polymorphic_pointer_cast.hpp header file ----------------------------------------------//
|
// boost polymorphic_pointer_cast.hpp header file ----------------------------------------------//
|
||||||
// (C) Copyright Boris Rasin and Antony Polukhin 2014-2015.
|
// (C) Copyright Boris Rasin, 2014-2021.
|
||||||
|
// (C) Copyright Antony Polukhin, 2014-2026.
|
||||||
// Distributed under the Boost
|
// Distributed under the Boost
|
||||||
// Software License, Version 1.0. (See accompanying file
|
// Software License, Version 1.0. (See accompanying file
|
||||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@@ -9,19 +10,16 @@
|
|||||||
#ifndef BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
|
#ifndef BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
|
||||||
#define BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
|
#define BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
|
||||||
|
|
||||||
# include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
# include <boost/assert.hpp>
|
|
||||||
# include <boost/pointer_cast.hpp>
|
|
||||||
# include <boost/throw_exception.hpp>
|
|
||||||
# include <boost/utility/declval.hpp>
|
|
||||||
# ifdef BOOST_NO_CXX11_DECLTYPE
|
|
||||||
# include <boost/typeof/typeof.hpp>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
# include <boost/assert.hpp>
|
||||||
|
# include <boost/pointer_cast.hpp>
|
||||||
|
# include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
// See the documentation for descriptions of how to choose between
|
// See the documentation for descriptions of how to choose between
|
||||||
@@ -40,36 +38,20 @@ namespace boost
|
|||||||
|
|
||||||
// Contributed by Boris Rasin
|
// Contributed by Boris Rasin
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
template <typename Target, typename Source>
|
|
||||||
struct dynamic_pointer_cast_result
|
|
||||||
{
|
|
||||||
#ifdef BOOST_NO_CXX11_DECLTYPE
|
|
||||||
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, dynamic_pointer_cast<Target>(boost::declval<Source>()))
|
|
||||||
typedef typename nested::type type;
|
|
||||||
#else
|
|
||||||
typedef decltype(dynamic_pointer_cast<Target>(boost::declval<Source>())) type;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Target, typename Source>
|
template <typename Target, typename Source>
|
||||||
inline typename detail::dynamic_pointer_cast_result<Target, Source>::type
|
inline auto polymorphic_pointer_downcast (const Source& x)
|
||||||
polymorphic_pointer_downcast (const Source& x)
|
-> decltype(static_pointer_cast<Target>(x))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(dynamic_pointer_cast<Target> (x) == x);
|
BOOST_ASSERT(dynamic_pointer_cast<Target> (x) == x);
|
||||||
return static_pointer_cast<Target> (x);
|
return static_pointer_cast<Target> (x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Target, typename Source>
|
template <typename Target, typename Source>
|
||||||
inline typename detail::dynamic_pointer_cast_result<Target, Source>::type
|
inline auto polymorphic_pointer_cast (const Source& x)
|
||||||
polymorphic_pointer_cast (const Source& x)
|
-> decltype(dynamic_pointer_cast<Target>(x))
|
||||||
{
|
{
|
||||||
typename detail::dynamic_pointer_cast_result<Target, Source>::type tmp
|
auto tmp = dynamic_pointer_cast<Target> (x);
|
||||||
= dynamic_pointer_cast<Target> (x);
|
|
||||||
if ( !tmp ) boost::throw_exception( std::bad_cast() );
|
if ( !tmp ) boost::throw_exception( std::bad_cast() );
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -2,10 +2,14 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright (c) 2016 Mikhail Maximov
|
Copyright (c) 2016 Mikhail Maximov
|
||||||
vigorous.activity at gmail dot com
|
vigorous.activity at gmail dot com
|
||||||
|
|
||||||
|
Copyright (c) Antony Polukhin, 2021-2026
|
||||||
|
|
||||||
Distributed under the Boost Software License,
|
Distributed under the Boost Software License,
|
||||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||||
or copy at http://boost.org/LICENSE_1_0.txt)
|
or copy at http://boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
boost-no-inspect
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -29,7 +33,7 @@
|
|||||||
<a href="../../doc/html/conversion.html">../../doc/html/conversion.html</a>
|
<a href="../../doc/html/conversion.html">../../doc/html/conversion.html</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© 2014 Antony Polukhin
|
© Antony Polukhin, 2014-2024
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-1
@@ -11,5 +11,6 @@
|
|||||||
],
|
],
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
"Antony Polukhin <antoshkka -at- gmail.com>"
|
"Antony Polukhin <antoshkka -at- gmail.com>"
|
||||||
]
|
],
|
||||||
|
"cxxstd": "11"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Copyright (c) 2016-2026 Antony Polukhin
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||||
|
|
||||||
|
if(NOT HAVE_BOOST_TEST)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(BOOST_TEST_LINK_LIBRARIES Boost::conversion Boost::core)
|
||||||
|
|
||||||
|
boost_test(TYPE run SOURCES cast_test.cpp)
|
||||||
|
boost_test(TYPE run SOURCES implicit_cast.cpp)
|
||||||
|
boost_test(TYPE compile-fail SOURCES implicit_cast_fail.cpp)
|
||||||
|
boost_test(TYPE compile-fail SOURCES implicit_cast_fail2.cpp)
|
||||||
|
boost_test(TYPE run SOURCES polymorphic_cast_test.cpp LINK_LIBRARIES Boost::smart_ptr)
|
||||||
+7
-5
@@ -1,18 +1,20 @@
|
|||||||
# Copyright (C) 2001-2003 Douglas Gregor
|
# Copyright (C) 2001-2003 Douglas Gregor
|
||||||
# Copyright (C) 2011-2014 Antony Polukhin
|
# Copyright (C) Antony Polukhin, 2011-2024
|
||||||
#
|
#
|
||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
require-b2 5.0.1 ;
|
||||||
|
import-search /boost/config/checks ;
|
||||||
|
import config : requires ;
|
||||||
import testing ;
|
import testing ;
|
||||||
import feature ;
|
import feature ;
|
||||||
|
|
||||||
project
|
project
|
||||||
: requirements
|
: requirements
|
||||||
<toolset>gcc-4.7:<cxxflags>-ftrapv
|
<library>/boost/conversion//boost_conversion
|
||||||
<toolset>gcc-4.6:<cxxflags>-ftrapv
|
[ requires cxx11_decltype ]
|
||||||
<toolset>clang:<cxxflags>-ftrapv
|
|
||||||
# default to all warnings on:
|
# default to all warnings on:
|
||||||
<warnings>all
|
<warnings>all
|
||||||
# set warnings as errors for those compilers we know we get warning free:
|
# set warnings as errors for those compilers we know we get warning free:
|
||||||
@@ -24,6 +26,6 @@ test-suite conversion
|
|||||||
: [ run implicit_cast.cpp ]
|
: [ run implicit_cast.cpp ]
|
||||||
[ compile-fail implicit_cast_fail.cpp ]
|
[ compile-fail implicit_cast_fail.cpp ]
|
||||||
[ run cast_test.cpp ]
|
[ run cast_test.cpp ]
|
||||||
[ run polymorphic_cast_test.cpp ]
|
[ run polymorphic_cast_test.cpp : : : <library>/boost/smart_ptr//boost_smart_ptr ]
|
||||||
[ compile-fail implicit_cast_fail2.cpp ]
|
[ compile-fail implicit_cast_fail2.cpp ]
|
||||||
;
|
;
|
||||||
|
|||||||
+47
-24
@@ -2,23 +2,26 @@
|
|||||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
# subject to the Boost Software License, Version 1.0. (See accompanying
|
||||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
# Copyright Antony Polukhin 2016-2017.
|
# Copyright Antony Polukhin, 2016-2025.
|
||||||
|
|
||||||
#
|
#
|
||||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||||
# and how it can be used with Boost libraries.
|
# and how it can be used with Boost libraries.
|
||||||
#
|
#
|
||||||
# File revision #3
|
# File revision #6
|
||||||
|
|
||||||
init:
|
init:
|
||||||
- set BRANCH_TO_TEST=%APPVEYOR_REPO_BRANCH% # Change to branch you wish to test. Use %APPVEYOR_REPO_BRANCH% for current branch.
|
# boost-local/libs/ folder to put this library into. This may be useful, if you're for example running Travis
|
||||||
- set BOOST_REMOVE=conversion # Remove this folder from lib from full clone of Boost. If you are testing `any` repo, write here `any`.
|
# from `Boost.DLL` repo while Boost already has `dll` and with to replace `dll` with content of`Boost.DLL`.
|
||||||
|
#
|
||||||
|
# Otherwise just leave the default value - set BOOST_LIBS_FOLDER=%APPVEYOR_PROJECT_NAME%
|
||||||
|
- set BOOST_LIBS_FOLDER=%APPVEYOR_PROJECT_NAME%
|
||||||
|
|
||||||
###############################################################################################################
|
###############################################################################################################
|
||||||
# From this point and below code is same for all the Boost libs
|
# From this point and below code is same for all the Boost libs
|
||||||
###############################################################################################################
|
###############################################################################################################
|
||||||
|
|
||||||
version: 1.64.{build}-{branch}
|
version: 1.84.{build}-{branch}
|
||||||
|
|
||||||
# branches to build
|
# branches to build
|
||||||
branches:
|
branches:
|
||||||
@@ -27,36 +30,56 @@ branches:
|
|||||||
|
|
||||||
skip_tags: true
|
skip_tags: true
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
TOOLSET: msvc-14.1,clang-win
|
||||||
|
CXXSTD: 14,17
|
||||||
|
ADDRMD: 32,64
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
ADDPATH: C:\cygwin\bin;
|
||||||
|
TOOLSET: gcc
|
||||||
|
CXXSTD: 03,11,14,1z
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
ADDPATH: C:\cygwin64\bin;
|
||||||
|
TOOLSET: gcc
|
||||||
|
CXXSTD: 03,11,14,1z
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
ADDPATH: C:\mingw\bin;
|
||||||
|
TOOLSET: gcc
|
||||||
|
CXXSTD: 03,11,14,1z
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||||
|
TOOLSET: gcc
|
||||||
|
CXXSTD: 03,11,14,1z
|
||||||
|
|
||||||
before_build:
|
before_build:
|
||||||
- set PATH=%PATH%;C:\\MinGW\\bin
|
- set BOOST_BRANCH=develop
|
||||||
# Set this to the name of the library
|
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||||
- set PROJECT_TO_TEST=%APPVEYOR_PROJECT_NAME%
|
- echo "Testing %APPVEYOR_PROJECT_NAME%"
|
||||||
- echo "Testing %PROJECT_TO_TEST%"
|
|
||||||
# Cloning Boost libraries (fast nondeep cloning)
|
# Cloning Boost libraries (fast nondeep cloning)
|
||||||
- set BOOST=C:/boost-local
|
- set BOOST=C:/boost-local
|
||||||
- git init %BOOST%
|
- git clone -b %BOOST_BRANCH% --depth 10 https://github.com/boostorg/boost.git %BOOST%
|
||||||
- cd %BOOST%
|
- cd %BOOST%
|
||||||
- git remote add --no-tags -t %BRANCH_TO_TEST% origin https://github.com/boostorg/boost.git
|
- git submodule update --init --depth 10 tools/build tools/boostdep
|
||||||
- git fetch --depth=1
|
|
||||||
- git checkout %BRANCH_TO_TEST%
|
- rm -rf %BOOST%/libs/%BOOST_LIBS_FOLDER%
|
||||||
- git submodule update --init --merge
|
- mv -f %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%BOOST_LIBS_FOLDER%
|
||||||
- git remote set-branches --add origin %BRANCH_TO_TEST%
|
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" %BOOST_LIBS_FOLDER%
|
||||||
- git pull --recurse-submodules
|
|
||||||
- git status
|
|
||||||
- rm -rf %BOOST%/libs/%BOOST_REMOVE%
|
|
||||||
- mv %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%PROJECT_TO_TEST%
|
|
||||||
- set TRAVIS_BUILD_DIR=%BOOST%/libs/%PROJECT_TO_TEST%
|
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
|
- cmd /c bootstrap
|
||||||
- bootstrap.bat
|
|
||||||
- b2.exe headers
|
- b2.exe headers
|
||||||
- cd %BOOST%/libs/%PROJECT_TO_TEST%/test
|
- cd %BOOST%/libs/%BOOST_LIBS_FOLDER%/test
|
||||||
|
|
||||||
after_build:
|
after_build:
|
||||||
before_test:
|
before_test:
|
||||||
test_script:
|
test_script:
|
||||||
- ..\..\..\b2.exe address-model=32 architecture=x86 toolset=msvc,gcc cxxflags="-DBOOST_TRAVISCI_BUILD" -sBOOST_BUILD_PATH=.
|
- PATH=%ADDPATH%%PATH%
|
||||||
|
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||||
|
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||||
|
- echo "Running command ..\..\..\b2 -j3 toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release"
|
||||||
|
- ..\..\..\b2.exe -j3 toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release cxxflags="-DBOOST_TRAVISCI_BUILD"
|
||||||
|
|
||||||
after_test:
|
after_test:
|
||||||
on_success:
|
on_success:
|
||||||
|
|||||||
+43
-1
@@ -38,6 +38,48 @@ namespace
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool compile_time_polymorphic_cast_check() {
|
||||||
|
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
|
||||||
|
Derived derived;
|
||||||
|
Base* base = &derived;
|
||||||
|
return polymorphic_cast<Derived*>(base) != nullptr;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
compile_time_polymorphic_cast_check(),
|
||||||
|
"polymorphic_cast does not work at compile time"
|
||||||
|
);
|
||||||
|
|
||||||
|
constexpr bool compile_time_polymorphic_downcast_check() {
|
||||||
|
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
|
||||||
|
Derived derived;
|
||||||
|
Base* base = &derived;
|
||||||
|
return polymorphic_downcast<Derived*>(base) != nullptr;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
compile_time_polymorphic_downcast_check(),
|
||||||
|
"polymorphic_downcast does not work at compile time"
|
||||||
|
);
|
||||||
|
|
||||||
|
constexpr bool compile_time_polymorphic_downcast2_check() {
|
||||||
|
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
|
||||||
|
Derived derived;
|
||||||
|
Base& base = derived;
|
||||||
|
Derived& derived_again = polymorphic_downcast<Derived&>(base);
|
||||||
|
(void)derived_again;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
compile_time_polymorphic_downcast2_check(),
|
||||||
|
"polymorphic_downcast does not work at compile time"
|
||||||
|
);
|
||||||
|
|
||||||
int main( int argc, char * argv[] )
|
int main( int argc, char * argv[] )
|
||||||
{
|
{
|
||||||
@@ -72,7 +114,7 @@ int main( int argc, char * argv[] )
|
|||||||
|
|
||||||
bool caught_exception = false;
|
bool caught_exception = false;
|
||||||
try { derived = polymorphic_cast<Derived*>( base ); }
|
try { derived = polymorphic_cast<Derived*>( base ); }
|
||||||
catch (std::bad_cast)
|
catch (const std::bad_cast&)
|
||||||
{ cout<<"caught bad_cast\n"; caught_exception = true; }
|
{ cout<<"caught bad_cast\n"; caught_exception = true; }
|
||||||
BOOST_TEST( caught_exception );
|
BOOST_TEST( caught_exception );
|
||||||
// the following is just so generated code can be inspected
|
// the following is just so generated code can be inspected
|
||||||
|
|||||||
@@ -4,8 +4,9 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/implicit_cast.hpp>
|
#include <boost/implicit_cast.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/type.hpp>
|
#include <boost/type.hpp>
|
||||||
|
|
||||||
using boost::implicit_cast;
|
using boost::implicit_cast;
|
||||||
using boost::type;
|
using boost::type;
|
||||||
|
|
||||||
@@ -18,8 +19,8 @@ struct foo
|
|||||||
operator long() const { return 0; }
|
operator long() const { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef type<long> long_type;
|
using long_type = type<long>;
|
||||||
typedef type<foo> foo_type;
|
using foo_type = type<foo>;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -34,5 +35,9 @@ int main()
|
|||||||
(void)f;
|
(void)f;
|
||||||
(void)z;
|
(void)z;
|
||||||
|
|
||||||
|
|
||||||
|
constexpr long value = boost::implicit_cast<long>(42);
|
||||||
|
BOOST_TEST(value == 42L);
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
// Copyright 1999 Dave Abrahams
|
// Copyright 1999 Dave Abrahams
|
||||||
// Copyright 2014 Peter Dimov
|
// Copyright 2014 Peter Dimov
|
||||||
// Copyright 2014 Boris Rasin, Antony Polukhin
|
// Copyright 2014 Boris Rasin, Antony Polukhin
|
||||||
|
// Copyright 2023 Antony Polukhin
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
//
|
//
|
||||||
@@ -172,20 +173,23 @@ static void test_polymorphic_pointer_cast()
|
|||||||
|
|
||||||
static void test_polymorphic_downcast()
|
static void test_polymorphic_downcast()
|
||||||
{
|
{
|
||||||
Base * base = new Derived;
|
Base *base_pointer = new Derived;
|
||||||
|
|
||||||
Derived * derived = boost::polymorphic_downcast<Derived*>( base );
|
// test raw pointer cast
|
||||||
|
Derived *derived_pointer = boost::polymorphic_downcast<Derived *>(base_pointer);
|
||||||
|
|
||||||
BOOST_TEST( derived != 0 );
|
BOOST_TEST(derived_pointer != 0);
|
||||||
|
|
||||||
if( derived != 0 )
|
if (derived_pointer != 0)
|
||||||
{
|
{
|
||||||
BOOST_TEST_EQ( derived->kind(), "Derived" );
|
BOOST_TEST_EQ(derived_pointer->kind(), "Derived");
|
||||||
}
|
}
|
||||||
|
|
||||||
// polymorphic_downcast can't do crosscasts
|
// test reference cast
|
||||||
|
Derived& derived_ref = boost::polymorphic_downcast<Derived&>(*base_pointer);
|
||||||
|
BOOST_TEST_EQ(derived_ref.kind(), "Derived");
|
||||||
|
|
||||||
delete base;
|
delete base_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_polymorphic_pointer_downcast_builtin()
|
static void test_polymorphic_pointer_downcast_builtin()
|
||||||
@@ -234,8 +238,6 @@ static void test_polymorphic_pointer_downcast_intrusive()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
|
||||||
|
|
||||||
static void test_polymorphic_pointer_downcast_std_shared()
|
static void test_polymorphic_pointer_downcast_std_shared()
|
||||||
{
|
{
|
||||||
std::shared_ptr<Base> base (new Derived);
|
std::shared_ptr<Base> base (new Derived);
|
||||||
@@ -250,8 +252,6 @@ static void test_polymorphic_pointer_downcast_std_shared()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void test_polymorphic_cast_fail()
|
static void test_polymorphic_cast_fail()
|
||||||
{
|
{
|
||||||
Base * base = new Base;
|
Base * base = new Base;
|
||||||
@@ -269,26 +269,39 @@ static void test_polymorphic_pointer_cast_fail()
|
|||||||
|
|
||||||
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( boost::shared_ptr<Base>(new Base) ), std::bad_cast );
|
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( boost::shared_ptr<Base>(new Base) ), std::bad_cast );
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
|
||||||
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( std::shared_ptr<Base>(new Base) ), std::bad_cast );
|
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( std::shared_ptr<Base>(new Base) ), std::bad_cast );
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( boost::intrusive_ptr<Base>(new Base) ), std::bad_cast );
|
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( boost::intrusive_ptr<Base>(new Base) ), std::bad_cast );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_polymorphic_downcast_fail()
|
static void test_polymorphic_downcast_fail()
|
||||||
{
|
{
|
||||||
Base * base = new Base;
|
Base * base_pointer = new Base;
|
||||||
|
|
||||||
int old_count = assertion_failed_count;
|
{
|
||||||
expect_assertion = true;
|
// test raw pointer cast
|
||||||
|
|
||||||
BOOST_TEST_THROWS( boost::polymorphic_downcast<Derived*>( base ), expected_assertion ); // should assert
|
int old_count = assertion_failed_count;
|
||||||
|
expect_assertion = true;
|
||||||
|
|
||||||
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
|
BOOST_TEST_THROWS(boost::polymorphic_downcast<Derived *>(base_pointer), expected_assertion); // should assert
|
||||||
expect_assertion = false;
|
|
||||||
|
|
||||||
delete base;
|
BOOST_TEST_EQ(assertion_failed_count, old_count + 1);
|
||||||
|
expect_assertion = false;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// test reference cast
|
||||||
|
|
||||||
|
int old_count = assertion_failed_count;
|
||||||
|
expect_assertion = true;
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS(boost::polymorphic_downcast<Derived &>(*base_pointer), expected_assertion); // should assert
|
||||||
|
|
||||||
|
BOOST_TEST_EQ(assertion_failed_count, old_count + 1);
|
||||||
|
expect_assertion = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete base_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_polymorphic_pointer_downcast_builtin_fail()
|
static void test_polymorphic_pointer_downcast_builtin_fail()
|
||||||
@@ -319,7 +332,6 @@ static void test_polymorphic_pointer_downcast_boost_shared_fail()
|
|||||||
expect_assertion = false;
|
expect_assertion = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
|
||||||
|
|
||||||
static void test_polymorphic_pointer_downcast_std_shared_fail()
|
static void test_polymorphic_pointer_downcast_std_shared_fail()
|
||||||
{
|
{
|
||||||
@@ -334,7 +346,6 @@ static void test_polymorphic_pointer_downcast_std_shared_fail()
|
|||||||
expect_assertion = false;
|
expect_assertion = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void test_polymorphic_pointer_downcast_intrusive_fail()
|
static void test_polymorphic_pointer_downcast_intrusive_fail()
|
||||||
{
|
{
|
||||||
@@ -364,10 +375,9 @@ int main()
|
|||||||
test_polymorphic_pointer_downcast_boost_shared_fail();
|
test_polymorphic_pointer_downcast_boost_shared_fail();
|
||||||
test_polymorphic_pointer_downcast_intrusive_fail();
|
test_polymorphic_pointer_downcast_intrusive_fail();
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_SMART_PTR
|
|
||||||
test_polymorphic_pointer_downcast_std_shared();
|
test_polymorphic_pointer_downcast_std_shared();
|
||||||
test_polymorphic_pointer_downcast_std_shared_fail();
|
test_polymorphic_pointer_downcast_std_shared_fail();
|
||||||
#endif
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user