early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

View File

View File

@@ -0,0 +1,96 @@
* text=auto !eol svneol=native#text/plain
*.gitattributes text svneol=native#text/plain
# Scriptish formats
*.bat text svneol=native#text/plain
*.bsh text svneol=native#text/x-beanshell
*.cgi text svneol=native#text/plain
*.cmd text svneol=native#text/plain
*.js text svneol=native#text/javascript
*.php text svneol=native#text/x-php
*.pl text svneol=native#text/x-perl
*.pm text svneol=native#text/x-perl
*.py text svneol=native#text/x-python
*.sh eol=lf svneol=LF#text/x-sh
configure eol=lf svneol=LF#text/x-sh
# Image formats
*.bmp binary svneol=unset#image/bmp
*.gif binary svneol=unset#image/gif
*.ico binary svneol=unset#image/ico
*.jpeg binary svneol=unset#image/jpeg
*.jpg binary svneol=unset#image/jpeg
*.png binary svneol=unset#image/png
*.tif binary svneol=unset#image/tiff
*.tiff binary svneol=unset#image/tiff
*.svg text svneol=native#image/svg%2Bxml
# Data formats
*.pdf binary svneol=unset#application/pdf
*.avi binary svneol=unset#video/avi
*.doc binary svneol=unset#application/msword
*.dsp text svneol=crlf#text/plain
*.dsw text svneol=crlf#text/plain
*.eps binary svneol=unset#application/postscript
*.gz binary svneol=unset#application/gzip
*.mov binary svneol=unset#video/quicktime
*.mp3 binary svneol=unset#audio/mpeg
*.ppt binary svneol=unset#application/vnd.ms-powerpoint
*.ps binary svneol=unset#application/postscript
*.psd binary svneol=unset#application/photoshop
*.rdf binary svneol=unset#text/rdf
*.rss text svneol=unset#text/xml
*.rtf binary svneol=unset#text/rtf
*.sln text svneol=native#text/plain
*.swf binary svneol=unset#application/x-shockwave-flash
*.tgz binary svneol=unset#application/gzip
*.vcproj text svneol=native#text/xml
*.vcxproj text svneol=native#text/xml
*.vsprops text svneol=native#text/xml
*.wav binary svneol=unset#audio/wav
*.xls binary svneol=unset#application/vnd.ms-excel
*.zip binary svneol=unset#application/zip
# Text formats
.htaccess text svneol=native#text/plain
*.bbk text svneol=native#text/xml
*.cmake text svneol=native#text/plain
*.css text svneol=native#text/css
*.dtd text svneol=native#text/xml
*.htm text svneol=native#text/html
*.html text svneol=native#text/html
*.ini text svneol=native#text/plain
*.log text svneol=native#text/plain
*.mak text svneol=native#text/plain
*.qbk text svneol=native#text/plain
*.rst text svneol=native#text/plain
*.sql text svneol=native#text/x-sql
*.txt text svneol=native#text/plain
*.xhtml text svneol=native#text/xhtml%2Bxml
*.xml text svneol=native#text/xml
*.xsd text svneol=native#text/xml
*.xsl text svneol=native#text/xml
*.xslt text svneol=native#text/xml
*.xul text svneol=native#text/xul
*.yml text svneol=native#text/plain
boost-no-inspect text svneol=native#text/plain
CHANGES text svneol=native#text/plain
COPYING text svneol=native#text/plain
INSTALL text svneol=native#text/plain
Jamfile text svneol=native#text/plain
Jamroot text svneol=native#text/plain
Jamfile.v2 text svneol=native#text/plain
Jamrules text svneol=native#text/plain
Makefile* text svneol=native#text/plain
README text svneol=native#text/plain
TODO text svneol=native#text/plain
# Code formats
*.c text svneol=native#text/plain
*.cpp text svneol=native#text/plain
*.h text svneol=native#text/plain
*.hpp text svneol=native#text/plain
*.ipp text svneol=native#text/plain
*.tpp text svneol=native#text/plain
*.jam text svneol=native#text/plain
*.java text svneol=native#text/plain

View File

@@ -0,0 +1,171 @@
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-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
linkflags: "linkflags=--coverage -lasan -lubsan"
gcov_tool: "gcov-10"
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
cxxflags: "cxxflags=-fsanitize=address,undefined,integer -fno-sanitize-recover=undefined"
linkflags: "linkflags=-fsanitize=address,undefined,integer"
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
cxxflags: "cxxflags=-fsanitize=address,undefined -fno-sanitize-recover=undefined"
linkflags: "linkflags=-fsanitize=address,undefined"
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- 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 -d0 headers
./b2 -j4 variant=debug tools/inspect/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.15.zip
unzip v1.15.zip
LCOV="`pwd`/lcov-1.15/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.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2019
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 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
b2 -d0 headers
- 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

View File

@@ -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...3.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::core
Boost::smart_ptr
Boost::throw_exception
Boost::type_traits
Boost::typeof
)

View File

@@ -0,0 +1,15 @@
# [Boost.Conversion](https://boost.org/libs/conversion)
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
@ | Build | Tests coverage | More info
----------------|-------------- | -------------- |-----------
Develop branch: | [![CI](https://github.com/boostorg/conversion/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/conversion/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/1cky1hrunfa46bdx/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/conversion/branch/develop) | [![Coverage Status](https://coveralls.io/repos/github/boostorg/conversion/badge.svg?branch=develop)](https://coveralls.io/github/boostorg/conversion?branch=develop) | [details...](https://www.boost.org/development/tests/develop/developer/conversion.html)
Master branch: | [![CI](https://github.com/boostorg/conversion/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/conversion/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/1cky1hrunfa46bdx/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/conversion/branch/master) | [![Coverage Status](https://coveralls.io/repos/github/boostorg/conversion/badge.svg?branch=master)](https://coveralls.io/github/boostorg/conversion?branch=master) | [details...](https://www.boost.org/development/tests/master/developer/conversion.html)
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/conversion.html)
### License
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).

View File

@@ -0,0 +1,38 @@
# Copyright (c) 2016 Mikhail Maximov <vigorous.activity -at- gmail.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)
project doc/conversion ;
using quickbook ;
import boostbook ;
xml conversion : conversion.qbk ;
boostbook standalone
:
conversion
:
<xsl:param>boost.root=../../../..
# File name of HTML output:
<xsl:param>root.filename=conversion
# How far down we chunk nested sections, basically all of them:
<xsl:param>chunk.section.depth=0
# Don't put the first section on the same page as the TOC:
<xsl:param>chunk.first.sections=0
# How far down sections get TOC's
<xsl:param>toc.section.depth=2
# Max depth in each TOC:
<xsl:param>toc.max.depth=2
# How far down we go with TOC's
<xsl:param>generate.section.toc.level=0
<xsl:param>generate.manifest=0
;
###############################################################################
alias boostdoc : conversion ;
explicit boostdoc ;
alias boostrelease ;
explicit boostrelease ;

View File

@@ -0,0 +1,218 @@
[/
Copyright 2016 Mikhail Maximov.
Copyright Antony Polukhin, 2020-2022.
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>)
]
[article The Conversion Library
[quickbook 1.6]
[compatibility-mode 1.5]
[id conversion]
[version 1.7]
[authors [Stroustrup, Bjarne], [Abrahams, Dave], [Rasin, Boris], [Polukhin, Antony]]
[copyright 2001 Beman Dawes, 2014-2022 Antony Polukhin]
[license
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])
]
[source-mode c++]
]
[/ QuickBook Document version 1.5 ]
[/ Dec, 2016 ]
[section Description]
The Conversion Library improves program safety and clarity by performing
otherwise messy conversions. It includes cast-style function templates designed
to complement the C++ Standard's built-in casts.
To reduce coupling, particularly to standard library IOStreams,
the Boost Conversion Library is supplied by several headers:
# The [@boost:boost/polymorphic_cast.hpp boost/polymorphic_cast.hpp] header
provides [link polymorphic_cast `polymorphic_cast<>`] and
[link polymorphic_downcast `polymorphic_downcast<>`]
to perform safe casting between polymorphic types.
# The [@boost:boost/polymorphic_pointer_cast.hpp boost/polymorphic_pointer_cast.hpp] header
provides [link polymorphic_pointer_cast `polymorphic_pointer_cast<>`] and
[link polymorphic_pointer_cast `polymorphic_pointer_downcast<>`]
# 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).
# The [@boost:boost/lexical_cast.hpp boost/lexical_cast.hpp] header
provides [@boost:doc/libs/release/libs/lexical_cast/ `lexical_cast<>`] general literal text conversions, such as an `int` represented as a `string`, or vice-versa.
[endsect]
[section Polymorphic casts]
Pointers to polymorphic objects (objects of classes which define at
least one virtual function) are sometimes downcast or crosscast.
Downcasting means casting from a base class to a derived class.
Crosscasting means casting across an inheritance hierarchy diagram, such
as from one base to the other in a [^Y] diagram hierarchy.
Such casts can be done with old-style casts, but this approach is
never to be recommended. Old-style casts are sorely lacking in type
safety, suffer poor readability, and are difficult to locate with search
tools.
[#polymorphic_downcast]
[section polymorphic_downcast]
The C++ built-in `static_cast` can be used for efficiently
downcasting pointers to polymorphic objects, but provides no error
detection for the case where the pointer being cast actually points to
the wrong derived class. The `polymorphic_downcast` template retains
the efficiency of `static_cast` for non-debug compilations, but for
debug compilations adds safety via an `assert()` that a `dynamic_cast`
succeeds.
A `polymorphic_downcast` should be used for
downcasts that you are certain should succeed. Error checking is
only performed in translation units where `NDEBUG` is
not defined, via
```
assert( dynamic_cast<Derived>(x) == x )
```
where `x` is the source pointer. This approach
ensures that not only is a non-zero pointer returned, but also
that it is correct in the presence of multiple inheritance.
Attempts to crosscast using `polymorphic_downcast` will
fail to compile.
[warning Because `polymorphic_downcast` uses `assert()`, it
violates the One Definition Rule (ODR) if `NDEBUG` is inconsistently
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]
[section polymorphic_cast]
The C++ built-in `dynamic_cast` can be used for downcasts and
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,
easy to forget to test. The throwing form of `dynamic_cast`, which
works on references, can be used on pointers through the ugly expression
`&dynamic_cast<T&>(*p)`, which causes undefined
behavior if `p` is `0`. The `polymorphic_cast`
template performs a `dynamic_cast` on a pointer, and throws an
exception if the `dynamic_cast` returns 0.
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.
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.
[endsect]
[#polymorphic_pointer_cast]
[section polymorphic_pointer_cast]
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:
For `polymorphic_pointer_downcast`:
```
static_pointer_cast<Derived>(p);
dynamic_pointer_cast<Derived>(p);
```
For `polymorphic_pointer_cast`:
```
dynamic_pointer_cast<Derived>(p);
!p; // conversion to bool with negation
```
This includes C++ built-in pointers, `std::shared_ptr`,
`boost::shared_ptr`, `boost::intrusive_ptr`, etc.
[h4 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]
[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>
inline Derived polymorphic_cast(Base* x);
// Effects: assert( dynamic_cast<Derived>(x) == x );
// Returns: static_cast<Derived>(x)
template <class Derived, class Base>
inline Derived polymorphic_downcast(Base* x);
// Effects: assert( dynamic_cast<Derived>(&x) == &x );
// Returns: static_cast<Derived>(x)
template <class Derived, class Base>
inline 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]
[section History]
`polymorphic_cast` was suggested by Bjarne Stroustrup in "The C++ Programming Language".
`polymorphic_downcast` was contributed by [@http://www.boost.org/people/dave_abrahams.htm Dave Abrahams].
`polymorphic_pointer_downcast` was contributed by [@http://www.boost.org/people/boris_rasin.htm Boris Rasin]
and `polymorphic_pointer_cast` by Antony Polukhin.
`polymorphic_downcast` overload for references was contributed by Julien Delacroix.
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]

View File

@@ -0,0 +1,38 @@
// Copyright David Abrahams 2003.
// 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)
#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 detail {
template<class T> struct icast_identity
{
typedef T type;
};
} // namespace detail
// implementation originally suggested by C. Green in
// http://lists.boost.org/MailArchives/boost/msg00886.php
// The use of identity creates a non-deduced form, so that the
// explicit template argument must be supplied
template <typename T>
BOOST_CONSTEXPR inline T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
return x;
}
} // namespace boost
#endif // BOOST_IMPLICIT_CAST_DWA200356_HPP

View File

@@ -0,0 +1,126 @@
// boost polymorphic_cast.hpp header file ----------------------------------------------//
// (C) Copyright Kevlin Henney and Dave Abrahams 1999.
// (C) Copyright Boris Rasin 2014.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/conversion for Documentation.
// Revision History
// 10 Nov 14 polymorphic_pointer_downcast moved to a separate header,
// minor improvements to stisfy latest Boost coding style
// 08 Nov 14 Add polymorphic_pointer_downcast (Boris Rasin)
// 09 Jun 14 "cast.hpp" was renamed to "polymorphic_cast.hpp" and
// inclusion of numeric_cast was removed (Antony Polukhin)
// 23 Jun 05 numeric_cast removed and redirected to the new verion (Fernando Cacciola)
// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included
// <boost/limits.hpp> instead (the workaround did not
// actually compile when BOOST_NO_LIMITS was defined in
// any case, so we loose nothing). (John Maddock)
// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never
// worked with stock GCC; trying to get it to do that broke
// vc-stlport.
// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp.
// Removed unused BOOST_EXPLICIT_TARGET macro. Moved
// boost::detail::type to boost/type.hpp. Made it compile with
// stock gcc again (Dave Abrahams)
// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal
// Review (Beman Dawes)
// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams)
// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC
// (Dave Abrahams)
// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams)
// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes)
// 27 Jun 00 More MSVC6 workarounds
// 15 Jun 00 Add workarounds for MSVC6
// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov)
// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar)
// 29 Dec 99 Change using declarations so usages in other namespaces work
// correctly (Dave Abrahams)
// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors
// as suggested Darin Adler and improved by Valentin Bonnard.
// 2 Sep 99 Remove controversial asserts, simplify, rename.
// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast,
// place in nested namespace.
// 3 Aug 99 Initial version
#ifndef BOOST_POLYMORPHIC_CAST_HPP
#define BOOST_POLYMORPHIC_CAST_HPP
# include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
# include <boost/assert.hpp>
# include <boost/core/addressof.hpp>
# include <boost/core/enable_if.hpp>
# include <boost/throw_exception.hpp>
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/remove_reference.hpp>
# include <typeinfo>
namespace boost
{
// See the documentation for descriptions of how to choose between
// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<>
// polymorphic_cast --------------------------------------------------------//
// Runtime checked polymorphic downcasts and crosscasts.
// Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup,
// section 15.8 exercise 1, page 425.
template <class Target, class Source>
inline Target polymorphic_cast(Source* x)
{
Target tmp = dynamic_cast<Target>(x);
if ( tmp == 0 ) boost::throw_exception( std::bad_cast() );
return tmp;
}
// polymorphic_downcast ----------------------------------------------------//
// BOOST_ASSERT() checked raw pointer 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 Dave Abrahams
template <class Target, class Source>
inline Target polymorphic_downcast(Source* x)
{
BOOST_ASSERT( dynamic_cast<Target>(x) == x ); // detect logic error
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>
inline typename boost::enable_if_c<
boost::is_reference<Target>::value, Target
>::type polymorphic_downcast(Source& x)
{
typedef typename boost::remove_reference<Target>::type* target_pointer_type;
return *boost::polymorphic_downcast<target_pointer_type>(
boost::addressof(x)
);
}
} // namespace boost
#endif // BOOST_POLYMORPHIC_CAST_HPP

View File

@@ -0,0 +1,79 @@
// boost polymorphic_pointer_cast.hpp header file ----------------------------------------------//
// (C) Copyright Boris Rasin, 2014-2021.
// (C) Copyright Antony Polukhin, 2014-2022.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/conversion for Documentation.
#ifndef BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
#define BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_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
# pragma once
#endif
namespace boost
{
// See the documentation for descriptions of how to choose between
// static_pointer_cast<>, dynamic_pointer_cast<>, polymorphic_pointer_cast<> and polymorphic_pointer_downcast<>
// polymorphic_pointer_downcast --------------------------------------------//
// BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited.
// Supports any type with static_pointer_cast/dynamic_pointer_cast functions:
// built-in pointers, std::shared_ptr, boost::shared_ptr, boost::intrusive_ptr, etc.
// 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 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>
inline typename detail::dynamic_pointer_cast_result<Target, Source>::type
polymorphic_pointer_downcast (const Source& x)
{
BOOST_ASSERT(dynamic_pointer_cast<Target> (x) == x);
return static_pointer_cast<Target> (x);
}
template <typename Target, typename Source>
inline typename detail::dynamic_pointer_cast_result<Target, Source>::type
polymorphic_pointer_cast (const Source& x)
{
typename detail::dynamic_pointer_cast_result<Target, Source>::type tmp
= dynamic_pointer_cast<Target> (x);
if ( !tmp ) boost::throw_exception( std::bad_cast() );
return tmp;
}
} // namespace boost
#endif // BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<!--
Copyright (c) 2016 Mikhail Maximov
vigorous.activity at gmail dot com
Copyright (c) Antony Polukhin, 2021-2022
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)
-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=https://www.boost.org/doc/libs/master/doc/html/conversion.html">
<title>Boost.Conversion</title>
<style>
body {
background: #fff;
color: #000;
}
a {
color: #00f;
text-decoration: none;
}
</style>
</head>
<body>
<p>
Automatic redirection failed, please go to
<a href="https://www.boost.org/doc/libs/master/doc/html/conversion.html">https://www.boost.org/doc/libs/master/doc/html/conversion.html</a>
</p>
<p>
&copy; Antony Polukhin, 2014-2022
</p>
</body>
</html>

View File

@@ -0,0 +1,16 @@
{
"key": "conversion",
"name": "Conversion",
"authors": [
"Dave Abrahams",
"Kevlin Henney"
],
"description": "Polymorphic casts.",
"category": [
"Miscellaneous"
],
"maintainers": [
"Antony Polukhin <antoshkka -at- gmail.com>"
],
"cxxstd": "03"
}

View File

@@ -0,0 +1,29 @@
# Copyright (C) 2001-2003 Douglas Gregor
# Copyright (C) Antony Polukhin, 2011-2022
#
# 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)
#
import testing ;
import feature ;
project
: requirements
<toolset>gcc-4.7:<cxxflags>-ftrapv
<toolset>gcc-4.6:<cxxflags>-ftrapv
<toolset>clang:<cxxflags>-ftrapv
# default to all warnings on:
<warnings>all
# set warnings as errors for those compilers we know we get warning free:
<toolset>gcc:<cxxflags>-Wextra
<toolset>gcc:<cxxflags>-Wno-uninitialized
;
test-suite conversion
: [ run implicit_cast.cpp ]
[ compile-fail implicit_cast_fail.cpp ]
[ run cast_test.cpp ]
[ run polymorphic_cast_test.cpp ]
[ compile-fail implicit_cast_fail2.cpp ]
;

View File

@@ -0,0 +1,90 @@
# 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, 2016-2022.
#
# 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 #6
init:
# boost-local/libs/ folder to put this library into. This may be useful, if you're for example running Travis
# 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
###############################################################################################################
version: 1.71.{build}-{branch}
# branches to build
branches:
except:
- gh-pages
skip_tags: true
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
ADDRMD: 32
- 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:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- echo "Testing %APPVEYOR_PROJECT_NAME%"
# Cloning Boost libraries (fast nondeep cloning)
- set BOOST=C:/boost-local
- git clone -b %BOOST_BRANCH% --depth 10 https://github.com/boostorg/boost.git %BOOST%
- cd %BOOST%
- git submodule update --init --depth 10 tools/build tools/boostdep
- rm -rf %BOOST%/libs/%BOOST_LIBS_FOLDER%
- mv -f %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%BOOST_LIBS_FOLDER%
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" %BOOST_LIBS_FOLDER%
build_script:
- cmd /c bootstrap
- b2.exe headers
- cd %BOOST%/libs/%BOOST_LIBS_FOLDER%/test
after_build:
before_test:
test_script:
- 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:
on_success:
on_failure:
on_finish:

View File

@@ -0,0 +1,82 @@
// boost utility cast test program -----------------------------------------//
// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola)
// 20 Jan 01 removed use of <limits> for portability to raw GCC (David Abrahams)
// 28 Jun 00 implicit_cast removed (Beman Dawes)
// 30 Aug 99 value_cast replaced by numeric_cast
// 3 Aug 99 Initial Version
#include <iostream>
#include <boost/polymorphic_cast.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost;
using std::cout;
namespace
{
struct Base
{
virtual char kind() { return 'B'; }
};
struct Base2
{
virtual char kind2() { return '2'; }
};
struct Derived : public Base, Base2
{
virtual char kind() { return 'D'; }
};
}
int main( int argc, char * argv[] )
{
# ifdef NDEBUG
cout << "NDEBUG is defined\n";
# else
cout << "NDEBUG is not defined\n";
# endif
cout << "\nBeginning tests...\n";
// test polymorphic_cast ---------------------------------------------------//
// tests which should succeed
Derived derived_instance;
Base * base = &derived_instance;
Derived * derived = polymorphic_downcast<Derived*>( base ); // downcast
BOOST_TEST( derived->kind() == 'D' );
derived = polymorphic_cast<Derived*>( base ); // downcast, throw on error
BOOST_TEST( derived->kind() == 'D' );
Base2 * base2 = polymorphic_cast<Base2*>( base ); // crosscast
BOOST_TEST( base2->kind2() == '2' );
// tests which should result in errors being detected
Base base_instance;
base = &base_instance;
if ( argc > 1 && *argv[1] == '1' )
{ derived = polymorphic_downcast<Derived*>( base ); } // #1 assert failure
bool caught_exception = false;
try { derived = polymorphic_cast<Derived*>( base ); }
catch (const std::bad_cast&)
{ cout<<"caught bad_cast\n"; caught_exception = true; }
BOOST_TEST( caught_exception );
// the following is just so generated code can be inspected
BOOST_TEST( derived->kind() != 'B' );
return boost::report_errors();
} // main

View File

@@ -0,0 +1,42 @@
// Copyright David Abrahams 2003.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/implicit_cast.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/type.hpp>
using boost::implicit_cast;
using boost::type;
template <class T>
type<T> check_return(T) { return type<T>(); }
struct foo
{
foo(char const*) {}
operator long() const { return 0; }
};
typedef type<long> long_type;
typedef type<foo> foo_type;
int main()
{
type<long> x = check_return(boost::implicit_cast<long>(1));
BOOST_TEST(boost::implicit_cast<long>(1) == 1L);
type<foo> f = check_return(boost::implicit_cast<foo>("hello"));
type<long> z = check_return(boost::implicit_cast<long>(foo("hello")));
// warning suppression:
(void)x;
(void)f;
(void)z;
BOOST_CONSTEXPR long value = boost::implicit_cast<long>(42);
BOOST_TEST(value == 42L);
return boost::report_errors();
}

View File

@@ -0,0 +1,20 @@
// Copyright David Abrahams 2003.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/implicit_cast.hpp>
using boost::implicit_cast;
struct foo
{
explicit foo(char const*) {}
};
int main()
{
foo x = implicit_cast<foo>("foobar");
(void)x; // warning suppression.
return 0;
}

View File

@@ -0,0 +1,19 @@
//
// Test that implicit_cast requires a template argument
//
// Copyright 2014 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/implicit_cast.hpp>
int main()
{
int x = boost::implicit_cast( 1 );
(void)x;
return 0;
}

View File

@@ -0,0 +1,391 @@
//
// Test boost::polymorphic_cast, boost::polymorphic_downcast and
// boost::polymorphic_pointer_cast, boost::polymorphic_pointer_downcast
//
// Copyright 1999 Beman Dawes
// Copyright 1999 Dave Abrahams
// Copyright 2014 Peter Dimov
// Copyright 2014 Boris Rasin, 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
//
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/polymorphic_cast.hpp>
#include <boost/polymorphic_pointer_cast.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include <boost/smart_ptr/intrusive_ref_counter.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>
#include <memory>
static bool expect_assertion = false;
static int assertion_failed_count = 0;
//assertion handler throws it to exit like assert, but to be able to catch it and stop
//usage: BOOST_TEST_THROWS( function_with_assert(), expected_assertion );
struct expected_assertion {};
// BOOST_ASSERT custom handler
void boost::assertion_failed( char const * expr, char const * function, char const * file, long line )
{
if( expect_assertion )
{
++assertion_failed_count;
throw expected_assertion();
}
else
{
BOOST_ERROR( "unexpected assertion" );
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): assertion '" << expr << "' failed in function '"
<< function << "'" << std::endl;
}
}
//
struct Base : boost::intrusive_ref_counter<Base>
{
virtual ~Base() {}
virtual std::string kind() { return "Base"; }
};
struct Base2
{
virtual ~Base2() {}
virtual std::string kind2() { return "Base2"; }
};
struct Derived : public Base, Base2
{
virtual std::string kind() { return "Derived"; }
};
static void test_polymorphic_cast()
{
Base * base = new Derived;
Derived * derived;
try
{
derived = boost::polymorphic_cast<Derived*>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_cast<Derived*>( base ) threw std::bad_cast" );
}
Base2 * base2;
try
{
base2 = boost::polymorphic_cast<Base2*>( base ); // crosscast
BOOST_TEST( base2 != 0 );
if( base2 != 0 )
{
BOOST_TEST_EQ( base2->kind2(), "Base2" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_cast<Base2*>( base ) threw std::bad_cast" );
}
delete base;
}
static void test_polymorphic_pointer_cast()
{
Base * base = new Derived;
Derived * derived;
try
{
derived = boost::polymorphic_pointer_cast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_pointer_cast<Derived>( base ) threw std::bad_cast" );
}
Base2 * base2;
try
{
base2 = boost::polymorphic_pointer_cast<Base2>( base ); // crosscast
BOOST_TEST( base2 != 0 );
if( base2 != 0 )
{
BOOST_TEST_EQ( base2->kind2(), "Base2" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_pointer_cast<Base2>( base ) threw std::bad_cast" );
}
boost::shared_ptr<Base> sp_base( base );
boost::shared_ptr<Base2> sp_base2;
try
{
sp_base2 = boost::polymorphic_pointer_cast<Base2>( sp_base ); // crosscast
BOOST_TEST( sp_base2 != 0 );
if( sp_base2 != 0 )
{
BOOST_TEST_EQ( sp_base2->kind2(), "Base2" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_pointer_cast<Base2>( sp_base ) threw std::bad_cast" );
}
// we do not `delete base;` because sahred_ptr is holding base
}
static void test_polymorphic_downcast()
{
Base *base_pointer = new Derived;
// test raw pointer cast
Derived *derived_pointer = boost::polymorphic_downcast<Derived *>(base_pointer);
BOOST_TEST(derived_pointer != 0);
if (derived_pointer != 0)
{
BOOST_TEST_EQ(derived_pointer->kind(), "Derived");
}
// test reference cast
Derived& derived_ref = boost::polymorphic_downcast<Derived&>(*base_pointer);
BOOST_TEST_EQ(derived_ref.kind(), "Derived");
delete base_pointer;
}
static void test_polymorphic_pointer_downcast_builtin()
{
Base * base = new Derived;
Derived * derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
// polymorphic_pointer_downcast can't do crosscasts
delete base;
}
static void test_polymorphic_pointer_downcast_boost_shared()
{
boost::shared_ptr<Base> base (new Derived);
boost::shared_ptr<Derived> derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
static void test_polymorphic_pointer_downcast_intrusive()
{
boost::intrusive_ptr<Base> base (new Derived);
boost::intrusive_ptr<Derived> derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
#ifndef BOOST_NO_CXX11_SMART_PTR
static void test_polymorphic_pointer_downcast_std_shared()
{
std::shared_ptr<Base> base (new Derived);
std::shared_ptr<Derived> derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
#endif
static void test_polymorphic_cast_fail()
{
Base * base = new Base;
BOOST_TEST_THROWS( boost::polymorphic_cast<Derived*>( base ), std::bad_cast );
delete base;
}
static void test_polymorphic_pointer_cast_fail()
{
Base * base = new Base;
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( base ), std::bad_cast );
delete base;
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 );
#endif
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( boost::intrusive_ptr<Base>(new Base) ), std::bad_cast );
}
static void test_polymorphic_downcast_fail()
{
Base * base_pointer = new Base;
{
// test raw pointer 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;
}
{
// 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()
{
Base * base = new Base;
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion ); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
delete base;
}
static void test_polymorphic_pointer_downcast_boost_shared_fail()
{
boost::shared_ptr<Base> base (new Base);
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion ); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
}
#ifndef BOOST_NO_CXX11_SMART_PTR
static void test_polymorphic_pointer_downcast_std_shared_fail()
{
std::shared_ptr<Base> base (new Base);
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion ); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
}
#endif
static void test_polymorphic_pointer_downcast_intrusive_fail()
{
boost::intrusive_ptr<Base> base (new Base);
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
}
int main()
{
test_polymorphic_cast();
test_polymorphic_pointer_cast();
test_polymorphic_downcast();
test_polymorphic_pointer_downcast_builtin();
test_polymorphic_pointer_downcast_boost_shared();
test_polymorphic_pointer_downcast_intrusive();
test_polymorphic_cast_fail();
test_polymorphic_pointer_cast_fail();
test_polymorphic_downcast_fail();
test_polymorphic_pointer_downcast_builtin_fail();
test_polymorphic_pointer_downcast_boost_shared_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_fail();
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,7 @@
-- Downloading https://github.com/boostorg/conversion/archive/boost-1.79.0.tar.gz -> boostorg-conversion-boost-1.79.0.tar.gz...
-- Extracting source D:/a/1/s/externals/vcpkg/downloads/boostorg-conversion-boost-1.79.0.tar.gz
-- Using source at D:/a/1/s/externals/vcpkg/buildtrees/boost-conversion/src/ost-1.79.0-f6231651a2.clean
-- Copying headers
-- Copying headers done
-- Installing: D:/a/1/s/externals/vcpkg/packages/boost-conversion_x64-windows/share/boost-conversion/usage
-- Installing: D:/a/1/s/externals/vcpkg/packages/boost-conversion_x64-windows/share/boost-conversion/copyright

View File

@@ -0,0 +1,19 @@
boost-assert a50eed453b8be6c8932fb3d5f8feaf194a2ebeaed7982db4e36e3ba17f3ec107
boost-config 797535e8975ed7cf5bbe11d9f7fe26caa5da8fe819888564758d82a21109fade
boost-core 498aea0b6b68bcfe1ec683e76c2f0d32477dfe9ba958f518980ff806b6faba90
boost-smart-ptr 38f44cf21554a20b78483abc4409c3edd633b78cc519fcf48803a1fe6b53316f
boost-throw-exception 4bb4a0182f0f071c3c1ffd9cbd82fbc3bc7db4a35346f930bbe504e7e3a94e0a
boost-type-traits 74f62124585467fbb6c4fa16015164d11e1a079d6bdb70ec1c3fe7cf65b9a594
boost-typeof aa3e58f01b489bc8672d51c4fbd25562aa3e06fcea0e131b1160d546b2a5f3a7
boost-vcpkg-helpers c81c7b003df356a1a120a7c0c2f5a2ac95f3c33b006a2a5b4c02dcf0c9f3deaa
cmake 3.23.2
features core
portfile.cmake 9227018cef91030d37ce198120f5b8ebe0c0a2e94793f7e213ba652ce67a1bfe
ports.cmake 366c60b768113102408b32ac1d7c7b48ef7d30a477af2a220ecc222d9ffa3166
post_build_checks 2
powershell 7.2.5
triplet x64-windows
triplet_abi 4556164a2cd3dd6f4742101eabb46def7e71b6e5856faa88e5d005aac12a803c-c0600b35e024ce0485ed253ef5419f3686f7257cfb58cb6a24febcb600fc4b4c-27ebd443f77a6c449168adfa6ce8def60cf46e88
vcpkg.json 66b71cc9e5d717fb77b480a64e87e86a90ebb87ba24c0ca40df0124320ba9abe
vcpkg_from_git 0aab20e34e84d52ba4763f009e539bfa8f418c41c918c8cf700156f1a8551a10
vcpkg_from_github b743742296a114ea1b18ae99672e02f142c4eb2bef7f57d36c038bedbfb0502f