Compare commits

...

102 Commits

Author SHA1 Message Date
e467a58fd6 Rework as esp-idf component 2023-11-23 17:17:05 +01:00
16fca8368b Keep -Wmaybe-uninitialized disabled 2022-05-30 20:25:13 +03:00
4cf7c718b8 Merge branch 'gcc12-Wuninitialized' of https://github.com/jngrad/boost-function into feature/issue-42 2022-05-30 19:56:08 +03:00
389f886bc3 Add test for issue #42 2022-05-30 19:36:29 +03:00
abc1bf9b4a Extend GCC 11 workaround to GCC 12 as well 2022-05-30 18:44:07 +03:00
e665d1e9af Disable -Wdeprecated-declarations for GCC 12 2022-05-30 18:18:09 +03:00
f7e42dc08f Update ci.yml 2022-05-30 17:35:22 +03:00
5b4e2797a2 Avoid -Wuninitialized warnings in GCC 12 2022-05-30 16:16:41 +02:00
5e1a4f49aa Remove msvc-14.3 from appveyor.yml (in GHA); use clang-win from 2019 2021-12-17 02:52:13 +02:00
e36de553dd Update README 2021-12-16 06:43:57 +02:00
acaca854c4 More Clang warning suppression 2021-12-16 06:20:42 +02:00
277757befc Disable -Wmaybe-uninitialized in function_template.hpp for GCC 11 2021-12-16 06:18:06 +02:00
61479788b8 Additional Clang warning fixes 2021-12-16 05:25:03 +02:00
e47b6a51e4 Test with warnings=extra, warnings-as-errors=on 2021-12-16 04:59:39 +02:00
bf8898c95f Disable C5243 in function_base.hpp (closes #41) 2021-12-16 04:24:49 +02:00
e0477637eb Add test/cmake_install_test 2021-12-16 03:45:24 +02:00
24dfb4f560 Add CMake tests to ci.yml 2021-12-16 03:41:09 +02:00
a60ee51957 Update ci.yml 2021-12-16 03:40:23 +02:00
6d98696d74 Update .github/workflows 2021-04-19 18:15:28 +03:00
223749287a Add test/CMakeLists.txt 2021-03-19 04:35:28 +02:00
78a03cb7bc Update CMakeLists.txt 2021-03-19 04:35:09 +02:00
bc16eee025 Add CMake tests to .travis.yml 2021-03-19 04:09:27 +02:00
848b0b219d Update .travis.yml 2021-03-19 00:06:53 +02:00
bd979303a2 Update .travis.yml 2021-03-18 04:32:47 +02:00
06357e16d0 Merge branch 'feature/gha' into develop 2021-01-20 00:50:53 +02:00
10ab375aef Merge pull request #40 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 00:46:13 +02:00
37a1fa3f6a Add .github/workflows 2021-01-20 00:38:48 +02:00
a2f088db05 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 17:15:01 -05:00
c197ec934e Update maintainer e-mail 2020-12-12 01:02:38 +02:00
8b1a23033d Add cxxstd=latest to msvc-14.2 2020-11-14 21:41:46 +02:00
fc28657f34 Use address-model=32 for msvc-9.0,10.0,11.0 2020-11-14 21:36:16 +02:00
52c8fd15d1 Update Travis 2020-09-10 17:28:39 +03:00
4841cbf475 Restrict clang-win to 64 bit to avoid mspdbcore.dll error 2020-03-28 05:03:12 +02:00
b07c2efef5 Add msvc-14.2, clang-win to Appveyor 2020-03-28 04:32:38 +02:00
1aa3e8c8d7 Merge pull request #38 from Romain-Geissler-1A/develop
Avoid -Wmaybe-uninitialized warnings in gcc (issue #27).
2020-03-28 03:45:44 +02:00
7c90434317 Avoid -Wmaybe-uninitialized warnings in gcc (issue #27). 2020-03-27 20:57:36 +00:00
8ec9323003 Update .travis.yml 2019-07-25 08:06:10 +03:00
c39ca938a6 Set Travis to Trusty 2019-07-25 07:59:38 +03:00
4b25a75c03 Merge branch 'develop' into develop 2019-04-29 15:05:21 -04:00
5682111fad Whitespace 2019-04-29 13:24:59 -04:00
1694b32e1b Fixing another -Wswitch-enum warning. 2019-04-29 12:29:22 -04:00
eaf2151263 Cosmetic cleanup 2019-04-29 02:47:09 +03:00
d9043b76d6 Changed a switch statement to an if to reduce compiler warnings on more sensitive flags. 2019-04-25 13:16:15 -04:00
2e2c44f070 Switch Appveyor to 2015 image 2019-04-14 18:27:47 +03:00
7f69508eac Add CMakeLists.txt 2019-01-07 00:09:56 +02:00
6d811a2e72 Add test/quick.cpp 2019-01-07 00:02:14 +02:00
3f6b2b6f56 Remove essentials from yml files 2018-12-22 05:17:56 +02:00
439d64d8a8 Update .yml files 2018-12-18 21:48:12 +02:00
3f46081c59 Add mixed cxxstd variants of test_return_function 2018-11-14 00:17:36 +02:00
17716b63f2 Add test_return_function 2018-11-14 00:11:27 +02:00
b6b0568c88 Reinstate appveyor.yml 2018-11-13 23:57:02 +02:00
babdbe500d Merge branch 'feature/more-lwtest' into develop 2018-11-13 22:33:07 +02:00
db39532c45 Update libraries.json 2018-11-13 21:31:36 +02:00
eb09bb6fec Simplify README 2018-11-13 21:30:36 +02:00
ccc66b34d9 Simplify example/Jamfile 2018-11-13 21:21:10 +02:00
e7952cb242 Remove LICENSE 2018-11-13 21:17:49 +02:00
57f4171c77 Remove top-level Jamfile 2018-11-13 21:17:35 +02:00
30f31f894c Merge branch 'develop' into feature/more-lwtest 2018-11-13 21:16:15 +02:00
bfb0e4701e Remove remaining uses of Boost.Test 2018-11-13 19:43:12 +02:00
7b11b52e62 Make function_buffer visible, for UBSan 2018-11-13 19:10:11 +02:00
0a1a33a443 Update toolset name for gcc-4.4 2018-11-13 18:13:50 +02:00
79045752e0 Revert "Added variadic support"
This reverts commit f22fa49e07.
2018-11-13 18:02:22 +02:00
b149dba678 Revert "Forgot to undef BOOST_FUNCTION_NUM_ARGS"
This reverts commit 161f7557e7.
2018-11-13 18:02:05 +02:00
cd91278477 Reinstate .travis.yml 2018-11-13 17:58:58 +02:00
c18d123137 Add test_mixed_cxxstd 2018-11-13 17:54:17 +02:00
3bc2478a95 Disable C++98 example in C++17 2018-11-04 06:53:50 -05:00
af15ab966e Enhance CI with libc++ and VS2017 strict builds 2018-11-04 06:53:50 -05:00
161f7557e7 Forgot to undef BOOST_FUNCTION_NUM_ARGS 2018-11-01 08:40:00 -04:00
f22fa49e07 Added variadic support
Improves `boost/function.hpp` inclusion by 20%.
2018-10-27 21:04:00 -04:00
5f93559650 Prepare for variadic support 2018-10-27 21:04:00 -04:00
5b2acbc175 Add throw/catch test for bad_function_call 2018-10-26 07:41:18 -04:00
755d3c2001 Missing visibility mark on exception type 2018-10-25 08:32:29 -04:00
b07621f2ee Default defaulted functions 2018-10-22 18:34:40 -04:00
df1f33eb00 TST: Do not catch exceptions by value 2018-10-22 18:34:40 -04:00
86f05aa602 Replace boost::forward with static_cast
One dependency less
2018-10-22 18:34:40 -04:00
4230fb2388 Reuse BOOST_FUNCTION_TEMPLATE_ARGS in BOOST_FUNCTION_PARTIAL_SPEC 2018-10-22 18:34:40 -04:00
453860ff9c expand CI jobs for more coverage 2018-10-15 20:27:06 -04:00
0ee9299e5e Merge pull request #22 from boostorg/feature/use-lwtest
Remove dependency on Boost.Test library, simplify test Jamfile
2018-09-24 22:54:16 +03:00
d1a771b6ea Disable -fno-rtti test on g++-4.4/c++0x as <memory> does not compile 2018-09-24 20:30:41 +03:00
27808e2bd5 Simplify test/Jamfile 2018-09-24 19:31:58 +03:00
528afe6b41 Replace Boost.Test use with lwtest 2018-09-24 19:23:58 +03:00
df80a7b29c Merge pull request #20 from glenfe/develop
Drop dependency on MPL
2018-09-22 21:44:30 -04:00
c0d41a880a Drop dependency on MPL 2018-09-22 15:27:54 -04:00
87c978d36e Use LightweightTest and NoExceptionsSupport from Core 2018-09-22 15:27:44 -04:00
d1ad1141f3 Use enable_if from TypeTraits 2018-09-22 15:27:34 -04:00
b1fa00f3b1 Include workaround.hpp from config instead of detail 2018-09-22 15:04:52 -04:00
feea19660b fix broken ci jobs in travis 2018-07-14 20:50:30 +00:00
51145b9d2c Fix appveyor links and badges in readme 2018-06-14 17:01:22 -04:00
251701850a fix coverity scan integration 2018-06-13 18:08:47 +00:00
151ce9492c fix building in boostorg appveyor account 2018-06-03 00:09:23 +00:00
7b4f5520e6 update README 2018-05-29 02:13:35 +00:00
e91b39f94f update to new-style boost-ci scripting 2018-05-29 02:12:39 +00:00
4a83ca8a57 Fix coverity scan badges 2018-05-27 10:17:27 -04:00
2afccba173 Added CI framework
- travis with valgrind, cppcheck, ubsan, codecov, covscan (future)
      - appveyor with MSVC 2010 through 2017, cygwin 32/64, mingw 32/64
      - README, LICENSE, etc.
2018-05-27 10:14:55 -04:00
52fae95412 Merge pull request #16 from joakimtosteberg/fix-aliasing-issue
Use char type directly to avoid invalid aliasing in one more place
2018-04-04 08:48:29 -04:00
9d0acd5195 Use char type directly to avoid invalid aliasing in one more place 2018-04-04 09:37:44 +02:00
0482db3a79 Merge pull request #15 from podusowski/fix-aliasing-issue
use char type directly to avoid invalid aliasing
2018-03-30 23:36:02 -04:00
0ee8e59d0a use char type directly to avoid invalid aliasing 2018-03-16 11:47:23 +01:00
bd9c06bd37 Merge pull request #14 from DanielaE/fix/replace-deprecated-allocator-members
replace members of std::allocate which are deprecated in c++17 by the…
2017-12-18 17:35:14 -05:00
f4f8fb0a16 replace members of std::allocate which are deprecated in c++17 by theirs cousins from std::allocator_traits. 2017-12-17 07:42:28 +01:00
eba48932f0 Skip test_empty_ref on g++ 7 in C++17 mode due to compiler bug 2017-12-17 02:18:11 +02:00
8defd1ea81 Update .travis.yml 2017-12-17 00:14:01 +02:00
38 changed files with 1438 additions and 262 deletions

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

@ -0,0 +1,381 @@
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-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: g++-11-multilib
address-model: 32,64
- toolset: gcc-12
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: g++-12-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: clang-14
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
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 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
export ADDRMD=${{matrix.address-model}}
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: 14,latest
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- 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 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 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 embed-manifest-via=linker
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
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 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
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 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
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 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error

View File

@ -1,21 +1,16 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2016-2019 Peter Dimov
# 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)
language: cpp
sudo: false
python: "2.7"
os:
- linux
- osx
dist: xenial
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
@ -28,12 +23,28 @@ matrix:
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++03
compiler: g++-4.4
env: TOOLSET=gcc CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++11
env: TOOLSET=gcc CXXSTD=03,11
addons:
apt:
packages:
@ -41,9 +52,28 @@ matrix:
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++14
env: TOOLSET=gcc CXXSTD=03,11,14,1z
addons:
apt:
packages:
@ -53,7 +83,7 @@ matrix:
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14
env: TOOLSET=gcc CXXSTD=03,11,14,1z
addons:
apt:
packages:
@ -62,9 +92,8 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++14
env: TOOLSET=gcc CXXSTD=03,11,14,17
addons:
apt:
packages:
@ -73,57 +102,250 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
compiler: g++-8
env: TOOLSET=gcc CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
compiler: g++-9
env: TOOLSET=gcc CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-10
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++14
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++1z
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-7
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- os: linux
dist: bionic
compiler: clang++-9
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-10
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-10
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-11
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-11
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-12
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-12
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: trusty
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: linux
dist: bionic
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
- os: linux
env: CMAKE_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=function ..
- ctest --output-on-failure -R boost_function
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++1z
- os: linux
env: CMAKE_SUBDIR_TEST=1
script:
- cd libs/function/test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/function
- python tools/boostdep/depinst/depinst.py function
@ -132,8 +354,8 @@ install:
script:
- |-
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
- ./b2 libs/function/test toolset=$TOOLSET
echo "using $TOOLSET : : $TRAVIS_COMPILER ;" > ~/user-config.jam
- ./b2 -j3 libs/function/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:

60
CMakeLists.txt Normal file
View File

@ -0,0 +1,60 @@
# Generated by `boostdep --cmake function`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
if(NOT DEFINED IDF_TARGET)
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_function VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_function INTERFACE)
add_library(Boost::function ALIAS boost_function)
target_include_directories(boost_function INTERFACE include)
target_link_libraries(boost_function
INTERFACE
Boost::assert
Boost::bind
Boost::config
Boost::core
Boost::integer
Boost::preprocessor
Boost::throw_exception
Boost::type_index
Boost::type_traits
Boost::typeof
)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()
else()
FILE(GLOB_RECURSE headers include/*.h include/*.hpp)
idf_component_register(
SRCS
${headers}
INCLUDE_DIRS
include
REQUIRES
boost_assert
boost_bind
boost_config
boost_core
boost_integer
boost_preprocessor
boost_throw_exception
boost_type_index
boost_type_traits
boost_typeof
)
endif()

18
README.md Normal file
View File

@ -0,0 +1,18 @@
# Boost.Function, a polymorphic function wrapper
[Boost.Function](http://boost.org/libs/function), part of the
[Boost C++ Libraries](http://boost.org), is the original implementation of the
polymorphic function wrapper `boost::function`, which was eventually accepted
into the C++11 standard as [`std::function`](https://en.cppreference.com/w/cpp/utility/functional/function).
## Currently supported compilers
* g++ 4.8 or later
* clang++ 3.9 or later
* Visual Studio 2005-2022
Tested on [Github Actions](https://github.com/boostorg/function/actions) and [Appveyor](https://ci.appveyor.com/project/pdimov/function/).
## License
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).

66
appveyor.yml Normal file
View File

@ -0,0 +1,66 @@
# Copyright 2016-2019 Peter Dimov
# 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)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: clang-win
CXXSTD: 14,17,latest
ADDRMD: 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-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/boostdep
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\function\
- python tools/boostdep/depinst/depinst.py function
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j3 libs/function/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker

14
example/Jamfile Normal file
View File

@ -0,0 +1,14 @@
# Boost.Function Library example Jamfile
#
# Copyright (c) 2008 James E. King III
#
# 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 ../../config/checks/config : requires ;
import testing ;
run bind1st.cpp : : : [ requires cxx98_binders ] ;
run int_div.cpp ;
run sum_avg.cpp ;

View File

@ -23,7 +23,7 @@
#include <functional> // unary_function, binary_function
#include <boost/preprocessor/iterate.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
// Include the prologue here so that the use of file-level iteration
// in anything that may be included by function_template.hpp doesn't break

View File

@ -26,13 +26,13 @@
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/composite_traits.hpp>
#include <boost/ref.hpp>
#include <boost/mpl/if.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/config/workaround.hpp>
#include <boost/type_traits/alignment_of.hpp>
#ifndef BOOST_NO_SFINAE
# include "boost/utility/enable_if.hpp"
#include <boost/type_traits/enable_if.hpp>
#else
# include "boost/mpl/bool.hpp"
#include <boost/type_traits/integral_constant.hpp>
#endif
#include <boost/function_equal.hpp>
#include <boost/function/function_fwd.hpp>
@ -50,7 +50,7 @@
#endif // __ICL etc
# define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \
typename ::boost::enable_if_c< \
typename ::boost::enable_if_< \
!(::boost::is_integral<Functor>::value), \
Type>::type
@ -86,12 +86,21 @@ namespace boost {
typedef void (*func_ptr_t)();
mutable func_ptr_t func_ptr;
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1929
# pragma warning(push)
# pragma warning(disable: 5243)
#endif
// For bound member pointers
struct bound_memfunc_ptr_t {
void (X::*memfunc_ptr)(int);
void* obj_ptr;
} bound_memfunc_ptr;
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1929
# pragma warning(pop)
#endif
// For references to function objects. We explicitly keep
// track of the cv-qualifiers on the object referenced.
struct obj_ref_t {
@ -101,7 +110,7 @@ namespace boost {
} obj_ref;
};
union function_buffer
union BOOST_SYMBOL_VISIBLE function_buffer
{
// Type-specific union members
mutable function_buffer_members members;
@ -152,15 +161,15 @@ namespace boost {
template<typename F>
class get_function_tag
{
typedef typename mpl::if_c<(is_pointer<F>::value),
typedef typename conditional<(is_pointer<F>::value),
function_ptr_tag,
function_obj_tag>::type ptr_or_obj_tag;
typedef typename mpl::if_c<(is_member_pointer<F>::value),
typedef typename conditional<(is_member_pointer<F>::value),
member_ptr_tag,
ptr_or_obj_tag>::type ptr_or_obj_or_mem_tag;
typedef typename mpl::if_c<(is_reference_wrapper<F>::value),
typedef typename conditional<(is_reference_wrapper<F>::value),
function_obj_ref_tag,
ptr_or_obj_or_mem_tag>::type or_ref_tag;
@ -328,7 +337,7 @@ namespace boost {
// Function objects that fit in the small-object buffer.
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::true_)
functor_manager_operation_type op, true_type)
{
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
}
@ -336,7 +345,7 @@ namespace boost {
// Function objects that require heap allocation
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::false_)
functor_manager_operation_type op, false_type)
{
if (op == clone_functor_tag) {
// Clone the functor
@ -377,7 +386,7 @@ namespace boost {
functor_manager_operation_type op, function_obj_tag)
{
manager(in_buffer, out_buffer, op,
mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
integral_constant<bool, (function_allows_small_object_optimization<functor_type>::value)>());
}
// For member pointers, we use the small-object optimization buffer.
@ -385,7 +394,7 @@ namespace boost {
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, member_ptr_tag)
{
manager(in_buffer, out_buffer, op, mpl::true_());
manager(in_buffer, out_buffer, op, true_type());
}
public:
@ -396,16 +405,12 @@ namespace boost {
functor_manager_operation_type op)
{
typedef typename get_function_tag<functor_type>::type tag_type;
switch (op) {
case get_functor_type_tag:
if (op == get_functor_type_tag) {
out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info();
out_buffer.members.type.const_qualified = false;
out_buffer.members.type.volatile_qualified = false;
return;
default:
} else {
manager(in_buffer, out_buffer, op, tag_type());
return;
}
}
};
@ -427,7 +432,7 @@ namespace boost {
// Function objects that fit in the small-object buffer.
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::true_)
functor_manager_operation_type op, true_type)
{
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
}
@ -435,12 +440,17 @@ namespace boost {
// Function objects that require heap allocation
static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, mpl::false_)
functor_manager_operation_type op, false_type)
{
typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
#if defined(BOOST_NO_CXX11_ALLOCATOR)
typedef typename Allocator::template rebind<functor_wrapper_type>::other
wrapper_allocator_type;
typedef typename wrapper_allocator_type::pointer wrapper_allocator_pointer_type;
#else
using wrapper_allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<functor_wrapper_type>;
using wrapper_allocator_pointer_type = typename std::allocator_traits<wrapper_allocator_type>::pointer;
#endif
if (op == clone_functor_tag) {
// Clone the functor
@ -450,7 +460,11 @@ namespace boost {
static_cast<const functor_wrapper_type*>(in_buffer.members.obj_ptr);
wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*f));
wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
#if defined(BOOST_NO_CXX11_ALLOCATOR)
wrapper_allocator.construct(copy, *f);
#else
std::allocator_traits<wrapper_allocator_type>::construct(wrapper_allocator, copy, *f);
#endif
// Get back to the original pointer type
functor_wrapper_type* new_f = static_cast<functor_wrapper_type*>(copy);
@ -463,7 +477,11 @@ namespace boost {
functor_wrapper_type* victim =
static_cast<functor_wrapper_type*>(in_buffer.members.obj_ptr);
wrapper_allocator_type wrapper_allocator(static_cast<Allocator const &>(*victim));
#if defined(BOOST_NO_CXX11_ALLOCATOR)
wrapper_allocator.destroy(victim);
#else
std::allocator_traits<wrapper_allocator_type>::destroy(wrapper_allocator, victim);
#endif
wrapper_allocator.deallocate(victim,1);
out_buffer.members.obj_ptr = 0;
} else if (op == check_functor_type_tag) {
@ -486,7 +504,7 @@ namespace boost {
functor_manager_operation_type op, function_obj_tag)
{
manager(in_buffer, out_buffer, op,
mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
integral_constant<bool, (function_allows_small_object_optimization<functor_type>::value)>());
}
public:
@ -497,16 +515,12 @@ namespace boost {
functor_manager_operation_type op)
{
typedef typename get_function_tag<functor_type>::type tag_type;
switch (op) {
case get_functor_type_tag:
if (op == get_functor_type_tag) {
out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info();
out_buffer.members.type.const_qualified = false;
out_buffer.members.type.volatile_qualified = false;
return;
default:
} else {
manager(in_buffer, out_buffer, op, tag_type());
return;
}
}
};
@ -517,24 +531,24 @@ namespace boost {
#ifdef BOOST_NO_SFINAE
// These routines perform comparisons between a Boost.Function
// object and an arbitrary function object (when the last
// parameter is mpl::bool_<false>) or against zero (when the
// last parameter is mpl::bool_<true>). They are only necessary
// parameter is false_type) or against zero (when the
// last parameter is true_type). They are only necessary
// for compilers that don't support SFINAE.
template<typename Function, typename Functor>
bool
compare_equal(const Function& f, const Functor&, int, mpl::bool_<true>)
compare_equal(const Function& f, const Functor&, int, true_type)
{ return f.empty(); }
template<typename Function, typename Functor>
bool
compare_not_equal(const Function& f, const Functor&, int,
mpl::bool_<true>)
true_type)
{ return !f.empty(); }
template<typename Function, typename Functor>
bool
compare_equal(const Function& f, const Functor& g, long,
mpl::bool_<false>)
false_type)
{
if (const Functor* fp = f.template target<Functor>())
return function_equal(*fp, g);
@ -544,7 +558,7 @@ namespace boost {
template<typename Function, typename Functor>
bool
compare_equal(const Function& f, const reference_wrapper<Functor>& g,
int, mpl::bool_<false>)
int, false_type)
{
if (const Functor* fp = f.template target<Functor>())
return fp == g.get_pointer();
@ -554,7 +568,7 @@ namespace boost {
template<typename Function, typename Functor>
bool
compare_not_equal(const Function& f, const Functor& g, long,
mpl::bool_<false>)
false_type)
{
if (const Functor* fp = f.template target<Functor>())
return !function_equal(*fp, g);
@ -565,7 +579,7 @@ namespace boost {
bool
compare_not_equal(const Function& f,
const reference_wrapper<Functor>& g, int,
mpl::bool_<false>)
false_type)
{
if (const Functor* fp = f.template target<Functor>())
return fp != g.get_pointer();
@ -697,7 +711,7 @@ public: // should be protected, but GCC 2.95.3 will fail to allow access
* The bad_function_call exception class is thrown when a boost::function
* object is invoked
*/
class bad_function_call : public std::runtime_error
class BOOST_SYMBOL_VISIBLE bad_function_call : public std::runtime_error
{
public:
bad_function_call() : std::runtime_error("call to empty boost::function") {}
@ -737,28 +751,28 @@ inline bool operator!=(detail::function::useless_clear_type*,
template<typename Functor>
inline bool operator==(const function_base& f, Functor g)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
return detail::function::compare_equal(f, g, 0, integral());
}
template<typename Functor>
inline bool operator==(Functor g, const function_base& f)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
return detail::function::compare_equal(f, g, 0, integral());
}
template<typename Functor>
inline bool operator!=(const function_base& f, Functor g)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
return detail::function::compare_not_equal(f, g, 0, integral());
}
template<typename Functor>
inline bool operator!=(Functor g, const function_base& f)
{
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
return detail::function::compare_not_equal(f, g, 0, integral());
}
#else

View File

@ -11,7 +11,7 @@
// Note: this header is a header template and must NOT have multiple-inclusion
// protection.
#include <boost/function/detail/prologue.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/core/no_exceptions_support.hpp>
#if defined(BOOST_MSVC)
# pragma warning( push )
@ -29,8 +29,7 @@
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
# define BOOST_FUNCTION_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, a)
#else
# include <boost/move/utility_core.hpp>
# define BOOST_FUNCTION_ARG(J,I,D) ::boost::forward< BOOST_PP_CAT(T,I) >(BOOST_PP_CAT(a,I))
# define BOOST_FUNCTION_ARG(J,I,D) static_cast<BOOST_PP_CAT(T,I)&&>(BOOST_PP_CAT(a,I))
# define BOOST_FUNCTION_ARGS BOOST_PP_ENUM(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG,BOOST_PP_EMPTY)
#endif
@ -240,7 +239,7 @@ namespace boost {
>
struct BOOST_FUNCTION_GET_FUNCTION_INVOKER
{
typedef typename mpl::if_c<(is_void<R>::value),
typedef typename conditional<(is_void<R>::value),
BOOST_FUNCTION_VOID_FUNCTION_INVOKER<
FunctionPtr,
R BOOST_FUNCTION_COMMA
@ -261,7 +260,7 @@ namespace boost {
>
struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
{
typedef typename mpl::if_c<(is_void<R>::value),
typedef typename conditional<(is_void<R>::value),
BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER<
FunctionObj,
R BOOST_FUNCTION_COMMA
@ -282,7 +281,7 @@ namespace boost {
>
struct BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
{
typedef typename mpl::if_c<(is_void<R>::value),
typedef typename conditional<(is_void<R>::value),
BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER<
FunctionObj,
R BOOST_FUNCTION_COMMA
@ -305,7 +304,7 @@ namespace boost {
>
struct BOOST_FUNCTION_GET_MEMBER_INVOKER
{
typedef typename mpl::if_c<(is_void<R>::value),
typedef typename conditional<(is_void<R>::value),
BOOST_FUNCTION_VOID_MEMBER_INVOKER<
MemberPtr,
R BOOST_FUNCTION_COMMA
@ -350,9 +349,8 @@ namespace boost {
typedef functor_manager<FunctionPtr> manager_type;
};
template<typename FunctionPtr,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
template<typename FunctionPtr, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
@ -385,9 +383,8 @@ namespace boost {
typedef functor_manager<MemberPtr> manager_type;
};
template<typename MemberPtr,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
template<typename MemberPtr, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
@ -420,9 +417,8 @@ namespace boost {
typedef functor_manager<FunctionObj> manager_type;
};
template<typename FunctionObj,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
template<typename FunctionObj, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
@ -454,9 +450,8 @@ namespace boost {
typedef reference_manager<typename RefWrapper::type> manager_type;
};
template<typename RefWrapper,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
typename Allocator>
template<typename RefWrapper, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
@ -567,35 +562,44 @@ namespace boost {
// Assign to a function object using the small object optimization
template<typename FunctionObj>
void
assign_functor(FunctionObj f, function_buffer& functor, mpl::true_) const
assign_functor(FunctionObj f, function_buffer& functor, true_type) const
{
new (reinterpret_cast<void*>(functor.data)) FunctionObj(f);
}
template<typename FunctionObj,typename Allocator>
void
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator, mpl::true_) const
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator, true_type) const
{
assign_functor(f,functor,mpl::true_());
assign_functor(f,functor,true_type());
}
// Assign to a function object allocated on the heap.
template<typename FunctionObj>
void
assign_functor(FunctionObj f, function_buffer& functor, mpl::false_) const
assign_functor(FunctionObj f, function_buffer& functor, false_type) const
{
functor.members.obj_ptr = new FunctionObj(f);
}
template<typename FunctionObj,typename Allocator>
void
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, mpl::false_) const
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, false_type) const
{
typedef functor_wrapper<FunctionObj,Allocator> functor_wrapper_type;
#if defined(BOOST_NO_CXX11_ALLOCATOR)
typedef typename Allocator::template rebind<functor_wrapper_type>::other
wrapper_allocator_type;
typedef typename wrapper_allocator_type::pointer wrapper_allocator_pointer_type;
#else
using wrapper_allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<functor_wrapper_type>;
using wrapper_allocator_pointer_type = typename std::allocator_traits<wrapper_allocator_type>::pointer;
#endif
wrapper_allocator_type wrapper_allocator(a);
wrapper_allocator_pointer_type copy = wrapper_allocator.allocate(1);
#if defined(BOOST_NO_CXX11_ALLOCATOR)
wrapper_allocator.construct(copy, functor_wrapper_type(f,a));
#else
std::allocator_traits<wrapper_allocator_type>::construct(wrapper_allocator, copy, functor_wrapper_type(f,a));
#endif
functor_wrapper_type* new_f = static_cast<functor_wrapper_type*>(copy);
functor.members.obj_ptr = new_f;
}
@ -606,7 +610,7 @@ namespace boost {
{
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
assign_functor(f, functor,
mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
integral_constant<bool, (function_allows_small_object_optimization<FunctionObj>::value)>());
return true;
} else {
return false;
@ -618,7 +622,7 @@ namespace boost {
{
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
assign_functor_a(f, functor, a,
mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
integral_constant<bool, (function_allows_small_object_optimization<FunctionObj>::value)>());
return true;
} else {
return false;
@ -699,14 +703,14 @@ namespace boost {
typedef BOOST_FUNCTION_FUNCTION self_type;
BOOST_FUNCTION_FUNCTION() : function_base() { }
BOOST_DEFAULTED_FUNCTION(BOOST_FUNCTION_FUNCTION(), : function_base() {})
// MSVC chokes if the following two constructors are collapsed into
// one with a default parameter.
template<typename Functor>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f
#ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c<
,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif // BOOST_NO_SFINAE
@ -718,7 +722,7 @@ namespace boost {
template<typename Functor,typename Allocator>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a
#ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c<
,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif // BOOST_NO_SFINAE
@ -767,7 +771,7 @@ namespace boost {
// construct.
template<typename Functor>
#ifndef BOOST_NO_SFINAE
typename boost::enable_if_c<
typename boost::enable_if_<
!(is_integral<Functor>::value),
BOOST_FUNCTION_FUNCTION&>::type
#else
@ -894,9 +898,24 @@ namespace boost {
{
if (!f.empty()) {
this->vtable = f.vtable;
if (this->has_trivial_copy_and_destroy())
this->functor = f.functor;
else
if (this->has_trivial_copy_and_destroy()) {
// Don't operate on storage directly since union type doesn't relax
// strict aliasing rules, despite of having member char type.
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic push
// This warning is technically correct, but we don't want to pay the price for initializing
// just to silence a warning: https://github.com/boostorg/function/issues/27
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# if (BOOST_GCC >= 120000)
// GCC 12 emits a different warning: https://github.com/boostorg/function/issues/42
# pragma GCC diagnostic ignored "-Wuninitialized"
# endif
# endif
std::memcpy(this->functor.data, f.functor.data, sizeof(boost::detail::function::function_buffer));
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic pop
# endif
} else
get_vtable()->base.manager(f.functor, this->functor,
boost::detail::function::clone_functor_tag);
}
@ -944,9 +963,8 @@ namespace boost {
typedef typename boost::detail::function::get_function_tag<Functor>::type tag;
typedef boost::detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker;
typedef typename get_invoker::
template apply_a<Functor, R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS,
Allocator>
template apply_a<Functor, Allocator, R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS>
handler_type;
typedef typename handler_type::invoker_type invoker_type;
@ -982,11 +1000,34 @@ namespace boost {
BOOST_TRY {
if (!f.empty()) {
this->vtable = f.vtable;
if (this->has_trivial_copy_and_destroy())
this->functor = f.functor;
else
if (this->has_trivial_copy_and_destroy()) {
// Don't operate on storage directly since union type doesn't relax
// strict aliasing rules, despite of having member char type.
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic push
// This warning is technically correct, but we don't want to pay the price for initializing
// just to silence a warning: https://github.com/boostorg/function/issues/27
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# if (BOOST_GCC >= 120000)
// GCC 12 emits a different warning: https://github.com/boostorg/function/issues/42
# pragma GCC diagnostic ignored "-Wuninitialized"
# endif
# endif
std::memcpy(this->functor.data, f.functor.data, sizeof(this->functor.data));
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic pop
# endif
} else
#if defined(BOOST_GCC) && (__GNUC__ >= 11)
# pragma GCC diagnostic push
// False positive in GCC 11/12 for empty function objects (function_n_test.cpp:673)
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
get_vtable()->base.manager(f.functor, this->functor,
boost::detail::function::move_functor_tag);
#if defined(BOOST_GCC) && (__GNUC__ >= 11)
# pragma GCC diagnostic pop
#endif
f.vtable = 0;
} else {
clear();
@ -1033,7 +1074,7 @@ template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
#if BOOST_FUNCTION_NUM_ARGS == 0
#define BOOST_FUNCTION_PARTIAL_SPEC R (void)
#else
#define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS,T))
#define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_FUNCTION_TEMPLATE_ARGS)
#endif
template<typename R BOOST_FUNCTION_COMMA
@ -1048,12 +1089,12 @@ class function<BOOST_FUNCTION_PARTIAL_SPEC>
public:
function() : base_type() {}
BOOST_DEFAULTED_FUNCTION(function(), : base_type() {})
template<typename Functor>
function(Functor f
#ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c<
,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif
@ -1064,7 +1105,7 @@ public:
template<typename Functor,typename Allocator>
function(Functor f, Allocator a
#ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c<
,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif
@ -1103,7 +1144,7 @@ public:
template<typename Functor>
#ifndef BOOST_NO_SFINAE
typename boost::enable_if_c<
typename boost::enable_if_<
!(is_integral<Functor>::value),
self_type&>::type
#else

View File

@ -13,6 +13,7 @@
"Programming"
],
"maintainers": [
"Douglas Gregor <dgregor -at- cs.indiana.edu>"
]
"Peter Dimov <pdimov -at- gmail.com>"
],
"cxxstd": "03"
}

11
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,11 @@
# Copyright 2018, 2019 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::function Boost::core Boost::lambda)
endif()

View File

@ -7,69 +7,80 @@
# For more information, see http://www.boost.org/
project
: requirements <toolset>msvc:<asynch-exceptions>on
: source-location $(BOOST_ROOT)
;
# bring in rules for testing
import testing ;
{
project
: default-build
<warnings>extra
: requirements
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
;
test-suite function
:
[ run libs/function/test/function_test.cpp : : : : lib_function_test ]
run function_test.cpp ;
# /usr/include/c++/4.4/bits/shared_ptr.h:146: error: cannot use typeid with -fno-rtti
run function_test.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no : function_test_no_rtti ;
run function_n_test.cpp ;
run allocator_test.cpp ;
run stateless_test.cpp ;
run lambda_test.cpp ;
compile-fail function_test_fail1.cpp ;
compile-fail function_test_fail2.cpp ;
compile function_30.cpp ;
compile function_30_repeat.cpp ;
run function_arith_cxx98.cpp ;
run function_arith_portable.cpp ;
run sum_avg_cxx98.cpp ;
run sum_avg_portable.cpp ;
run mem_fun_cxx98.cpp ;
run mem_fun_portable.cpp ;
run std_bind_cxx98.cpp ;
run std_bind_portable.cpp ;
run function_ref_cxx98.cpp ;
run function_ref_portable.cpp ;
run contains_test.cpp ;
run contains2_test.cpp ;
run nothrow_swap.cpp ;
run rvalues_test.cpp ;
compile function_typeof_test.cpp ;
run result_arg_types_test.cpp ;
[ run libs/function/test/function_test.cpp : : : <rtti>off : lib_function_test_no_rtti ]
lib throw_bad_function_call : throw_bad_function_call.cpp : <link>shared:<define>THROW_BAD_FUNCTION_CALL_DYN_LINK=1 ;
[ run libs/function/test/function_n_test.cpp : : : : ]
run test_bad_function_call.cpp throw_bad_function_call : : : <link>shared : test_bad_function_call_shared ;
run test_bad_function_call.cpp throw_bad_function_call : : : <link>static : test_bad_function_call_static ;
[ run libs/function/test/allocator_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ]
lib mixed_cxxstd : mixed_cxxstd.cpp : <link>shared:<define>MIXED_CXXSTD_DYN_LINK=1 ;
[ run libs/function/test/stateless_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ]
run test_mixed_cxxstd.cpp mixed_cxxstd : : : <link>shared : mixed_cxxstd_shared ;
run test_mixed_cxxstd.cpp mixed_cxxstd : : : <link>static : mixed_cxxstd_static ;
[ run libs/function/test/lambda_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ]
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>98 : : : <link>shared : mixed_cxxstd_shared_98 ;
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>98 : : : <link>static : mixed_cxxstd_static_98 ;
[ compile-fail libs/function/test/function_test_fail1.cpp : : : : ]
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>0x : : : <link>shared : mixed_cxxstd_shared_0x ;
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>0x : : : <link>static : mixed_cxxstd_static_0x ;
[ compile-fail libs/function/test/function_test_fail2.cpp : : : : ]
local check14 = [ check-target-builds mixed_cxxstd/<cxxstd>14 : : <build>no ] ;
[ compile libs/function/test/function_30.cpp : : : : ]
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>14 : : : <link>shared $(check14) : mixed_cxxstd_shared_14 ;
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>14 : : : <link>static $(check14) : mixed_cxxstd_static_14 ;
[ compile libs/function/test/function_30_repeat.cpp : : : : ]
lib return_function : return_function.cpp : <link>shared:<define>RETURN_FUNCTION_DYN_LINK=1 ;
[ run libs/function/test/function_arith_cxx98.cpp : : : : ]
run test_return_function.cpp return_function : : : <link>shared : return_function_shared ;
run test_return_function.cpp return_function : : : <link>static : return_function_static ;
[ run libs/function/test/function_arith_portable.cpp : : : : ]
run test_return_function.cpp return_function/<cxxstd>98 : : : <link>shared : return_function_shared_98 ;
run test_return_function.cpp return_function/<cxxstd>98 : : : <link>static : return_function_static_98 ;
[ run libs/function/test/sum_avg_cxx98.cpp : : : : ]
run test_return_function.cpp return_function/<cxxstd>0x : : : <link>shared : return_function_shared_0x ;
run test_return_function.cpp return_function/<cxxstd>0x : : : <link>static : return_function_static_0x ;
[ run libs/function/test/sum_avg_portable.cpp : : : : ]
run test_return_function.cpp return_function/<cxxstd>14 : : : <link>shared $(check14) : return_function_shared_14 ;
run test_return_function.cpp return_function/<cxxstd>14 : : : <link>static $(check14) : return_function_static_14 ;
[ run libs/function/test/mem_fun_cxx98.cpp : : : : ]
run quick.cpp ;
[ run libs/function/test/mem_fun_portable.cpp : : : : ]
[ run libs/function/test/std_bind_cxx98.cpp : : : : ]
[ run libs/function/test/std_bind_portable.cpp : : : : ]
[ run libs/function/test/function_ref_cxx98.cpp : : : : ]
[ run libs/function/test/function_ref_portable.cpp : : : : ]
[ run libs/function/test/contains_test.cpp : : : : ]
[ run libs/function/test/contains2_test.cpp : : : : ]
[ run libs/function/test/nothrow_swap.cpp : : : : ]
[ run libs/function/test/rvalues_test.cpp : : : : ]
[ compile libs/function/test/function_typeof_test.cpp ]
[ run libs/function/test/result_arg_types_test.cpp ]
;
}
compile issue_42.cpp ;

View File

@ -7,10 +7,10 @@
// For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cassert>
#include <functional>
#include <boost/function.hpp>
using namespace std;
using namespace boost;
@ -74,20 +74,19 @@ struct DoNothing: base
static void do_nothing() {}
int
test_main(int, char*[])
int main()
{
function2<int, int, int> f;
f.assign( plus_int<disable_small_object_optimization>(), counting_allocator<int>() );
f.clear();
BOOST_CHECK(alloc_count == 1);
BOOST_CHECK(dealloc_count == 1);
BOOST_TEST_EQ( alloc_count, 1 );
BOOST_TEST_EQ( dealloc_count, 1 );
alloc_count = 0;
dealloc_count = 0;
f.assign( plus_int<enable_small_object_optimization>(), counting_allocator<int>() );
f.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
BOOST_TEST_EQ( alloc_count, 0 );
BOOST_TEST_EQ( dealloc_count, 0 );
f.assign( plus_int<disable_small_object_optimization>(), std::allocator<int>() );
f.clear();
f.assign( plus_int<enable_small_object_optimization>(), std::allocator<int>() );
@ -97,8 +96,8 @@ test_main(int, char*[])
dealloc_count = 0;
f.assign( &do_minus, counting_allocator<int>() );
f.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
BOOST_TEST_EQ( alloc_count, 0 );
BOOST_TEST_EQ( dealloc_count, 0 );
f.assign( &do_minus, std::allocator<int>() );
f.clear();
@ -107,14 +106,14 @@ test_main(int, char*[])
dealloc_count = 0;
fv.assign( DoNothing<disable_small_object_optimization>(), counting_allocator<int>() );
fv.clear();
BOOST_CHECK(alloc_count == 1);
BOOST_CHECK(dealloc_count == 1);
BOOST_TEST_EQ( alloc_count, 1 );
BOOST_TEST_EQ( dealloc_count, 1 );
alloc_count = 0;
dealloc_count = 0;
fv.assign( DoNothing<enable_small_object_optimization>(), counting_allocator<int>() );
fv.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
BOOST_TEST_EQ( alloc_count, 0 );
BOOST_TEST_EQ( dealloc_count, 0 );
fv.assign( DoNothing<disable_small_object_optimization>(), std::allocator<int>() );
fv.clear();
fv.assign( DoNothing<enable_small_object_optimization>(), std::allocator<int>() );
@ -124,8 +123,8 @@ test_main(int, char*[])
dealloc_count = 0;
fv.assign( &do_nothing, counting_allocator<int>() );
fv.clear();
BOOST_CHECK(alloc_count == 0);
BOOST_CHECK(dealloc_count == 0);
BOOST_TEST_EQ( alloc_count, 0 );
BOOST_TEST_EQ( dealloc_count, 0 );
fv.assign( &do_nothing, std::allocator<int>() );
fv.clear();
@ -133,5 +132,5 @@ test_main(int, char*[])
fv.assign(&do_nothing, std::allocator<int>() );
fv2.assign(fv, std::allocator<int>() );
return 0;
return boost::report_errors();
}

View File

@ -0,0 +1,17 @@
# Copyright 2018, 2019 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_function REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main Boost::function)
enable_testing()
add_test(main main)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -0,0 +1,22 @@
// Copyright 2017, 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/function
#include <boost/function.hpp>
#include <cassert>
#define BOOST_TEST(expr) assert(expr)
#define BOOST_TEST_EQ(x1, x2) assert((x1)==(x2))
int add( int x, int y )
{
return x + y;
}
int main()
{
boost::function<int(int, int)> fn( &add );
BOOST_TEST_EQ( fn( 1, 2 ), 3 );
}

View File

@ -0,0 +1,49 @@
# Copyright 2018, 2019 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
cmake_minimum_required(VERSION 3.5)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/function)
# boost_add_subdir
function(boost_add_subdir name)
add_subdirectory(../../../${name} boostorg/${name})
endfunction()
# primary dependencies
boost_add_subdir(assert)
boost_add_subdir(bind)
boost_add_subdir(config)
boost_add_subdir(core)
boost_add_subdir(integer)
boost_add_subdir(preprocessor)
boost_add_subdir(throw_exception)
boost_add_subdir(type_index)
boost_add_subdir(type_traits)
boost_add_subdir(typeof)
# secondary dependencies
boost_add_subdir(static_assert)
boost_add_subdir(container_hash)
boost_add_subdir(smart_ptr)
boost_add_subdir(detail)
boost_add_subdir(move)
boost_add_subdir(predef)
# --target check
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::function Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -9,7 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
static int forty_two()
{

View File

@ -5,10 +5,12 @@
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/ref.hpp>
#define BOOST_CHECK BOOST_TEST
static int forty_two() { return 42; }
struct Seventeen
@ -225,11 +227,11 @@ static void ref_equal_test()
#endif
}
int test_main(int, char*[])
int main()
{
target_test();
equal_test();
ref_equal_test();
return 0;
return boost::report_errors();
}

View File

@ -7,12 +7,20 @@
// For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wself-assign-overloaded" )
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
# endif
#endif
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
#include <cassert>
#include <string>
#define BOOST_CHECK BOOST_TEST
using namespace boost;
using std::string;
using std::negate;
@ -631,7 +639,7 @@ test_ref()
boost::function2<int, int, int> f(ref(atc));
BOOST_CHECK(f(1, 3) == 4);
}
catch(std::runtime_error e) {
catch(std::runtime_error const&) {
BOOST_ERROR("Nonthrowing constructor threw an exception");
}
}
@ -684,7 +692,7 @@ void test_construct_destroy_count()
BOOST_CHECK(construction_count == destruction_count);
}
int test_main(int, char* [])
int main()
{
test_zero_args();
test_one_arg();
@ -693,5 +701,5 @@ int test_main(int, char* [])
test_member_functions();
test_ref();
test_construct_destroy_count();
return 0;
return boost::report_errors();
}

View File

@ -7,12 +7,20 @@
// For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wself-assign-overloaded" )
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
# endif
#endif
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
#include <string>
#include <utility>
#define BOOST_CHECK BOOST_TEST
using boost::function;
using std::string;
@ -624,11 +632,22 @@ test_ref()
boost::function<int (int, int)> f(boost::ref(atc));
BOOST_CHECK(f(1, 3) == 4);
}
catch(std::runtime_error e) {
catch(std::runtime_error const&) {
BOOST_ERROR("Nonthrowing constructor threw an exception");
}
}
#if BOOST_WORKAROUND(BOOST_GCC, >= 70000 && BOOST_GCC < 80000) && __cplusplus >= 201700
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81311
#pragma message("Skipping test_empty_ref on g++ 7 -std=c++17")
static void test_empty_ref()
{
}
#else
static void dummy() {}
static void test_empty_ref()
@ -640,18 +659,20 @@ static void test_empty_ref()
f2();
BOOST_ERROR("Exception didn't throw for reference to empty function.");
}
catch(std::runtime_error e) {}
catch(std::runtime_error const&) {}
f1 = dummy;
try {
f2();
}
catch(std::runtime_error e) {
catch(std::runtime_error const&) {
BOOST_ERROR("Error calling referenced function.");
}
}
#endif
static void test_exception()
{
@ -660,7 +681,7 @@ static void test_exception()
f(5, 4);
BOOST_CHECK(false);
}
catch(boost::bad_function_call) {
catch(boost::bad_function_call const&) {
// okay
}
}
@ -779,7 +800,7 @@ static void test_move_semantics()
#endif
}
int test_main(int, char* [])
int main()
{
test_zero_args();
test_one_arg();
@ -794,5 +815,5 @@ int test_main(int, char* [])
test_move_semantics<function<void()> >();
test_move_semantics<boost::function0<void> >();
return 0;
return boost::report_errors();
}

View File

@ -7,22 +7,12 @@
// For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
using namespace std;
using namespace boost;
int
test_main(int, char*[])
void test()
{
function0<int> f1;
function0<int> f2;
boost::function0<int> f1;
boost::function0<int> f2;
if (f1 == f2) {
}
BOOST_ERROR("This should not have compiled.");
return 0;
if( f1 == f2 ) {}
}

View File

@ -7,21 +7,12 @@
// For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
using namespace std;
using namespace boost;
static int bad_fn(float f) { return static_cast<int>(f); }
int
test_main(int, char*[])
void test()
{
function0<int> f1;
f1 = bad_fn;
BOOST_ERROR("This should not have compiled.");
return 0;
boost::function0<int> f1;
f1 = bad_fn;
}

21
test/issue_42.cpp Normal file
View File

@ -0,0 +1,21 @@
// Copyright 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// https://github.com/boostorg/function/issues/42
#include <boost/function.hpp>
struct F
{
int operator()( int x ) const { return -x; }
};
struct X
{
boost::function<int(int)> f_;
explicit X( boost::function<int(int)> f ): f_( f ) {}
};
F f2;
X x( f2 ); // -Wuninitialized under GCC 12

View File

@ -7,13 +7,13 @@
// For more information, see http://www.boost.org
#include <boost/function.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <cstdlib>
#include <boost/test/minimal.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/function.hpp>
static unsigned
func_impl(int arg1, bool arg2, double arg3)
@ -22,17 +22,19 @@ func_impl(int arg1, bool arg2, double arg3)
return abs (static_cast<int>((arg2 ? arg1 : 2 * arg1) * arg3));
}
int test_main(int, char*[])
int main()
{
using boost::function;
using namespace boost::lambda;
function <unsigned(bool, double)> f1 = bind(func_impl, 15, _1, _2);
BOOST_TEST_EQ( f1(true, 2.0), 30 );
function <unsigned(double)> f2 = boost::lambda::bind(f1, false, _1);
BOOST_TEST_EQ( f2(2.0), 60 );
function <unsigned()> f3 = boost::lambda::bind(f2, 4.0);
BOOST_TEST_EQ( f3(), 120 );
f3();
return 0;
return boost::report_errors();
}

View File

@ -10,13 +10,13 @@
#include <boost/function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <functional>
struct Y {
Y(int y = 0) : y_(y) {}
bool operator==(const Y& rhs) { return y_ == rhs.y_; }
bool operator==(const Y& rhs) const { return y_ == rhs.y_; }
private:
int y_;
};

View File

@ -10,13 +10,13 @@
#include <boost/function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <functional>
struct Y {
Y(int y = 0) : y_(y) {}
bool operator==(const Y& rhs) { return y_ == rhs.y_; }
bool operator==(const Y& rhs) const { return y_ == rhs.y_; }
private:
int y_;
};

42
test/mixed_cxxstd.cpp Normal file
View File

@ -0,0 +1,42 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/function.hpp>
#include <boost/config.hpp>
#if defined(MIXED_CXXSTD_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
EXPORT void call_fn_1( boost::function<void()> const & fn )
{
fn();
}
EXPORT void call_fn_2( boost::function<void(int)> const & fn )
{
fn( 1 );
}
EXPORT void call_fn_3( boost::function<void(int, int)> const & fn )
{
fn( 1, 2 );
}
EXPORT void call_fn_4( boost::function0<void> const & fn )
{
fn();
}
EXPORT void call_fn_5( boost::function1<void, int> const & fn )
{
fn( 1 );
}
EXPORT void call_fn_6( boost::function2<void, int, int> const & fn )
{
fn( 1, 2 );
}

View File

@ -7,8 +7,10 @@
// For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
struct tried_to_copy { };
@ -40,7 +42,7 @@ struct MaybeThrowOnCopy {
bool MaybeThrowOnCopy::throwOnCopy = false;
int test_main(int, char* [])
int main()
{
boost::function0<int> f;
boost::function0<int> g;
@ -56,5 +58,5 @@ int test_main(int, char* [])
BOOST_CHECK(f() == 2);
BOOST_CHECK(g() == 1);
return 0;
return boost::report_errors();
}

21
test/quick.cpp Normal file
View File

@ -0,0 +1,21 @@
// Copyright 2019 Peter Dimov
// Use, modification and distribution is 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
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
static int f( int x )
{
return x + 1;
}
int main()
{
boost::function<int(int)> fn( f );
BOOST_TEST_EQ( fn( 5 ), 6 );
return boost::report_errors();
}

27
test/return_function.cpp Normal file
View File

@ -0,0 +1,27 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/function.hpp>
#include <boost/config.hpp>
#if defined(RETURN_FUNCTION_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
int f( int x, int y )
{
return x + y;
}
EXPORT boost::function<int(int, int)> get_fn_1()
{
return f;
}
EXPORT boost::function2<int, int, int> get_fn_2()
{
return f;
}

View File

@ -6,12 +6,13 @@
// For more information, see http://www.boost.org
#include <boost/function.hpp>
#include <boost/move/move.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <cstdlib>
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
#include <boost/move/move.hpp>
#define BOOST_CHECK BOOST_TEST
class only_movable {
private:
@ -63,7 +64,7 @@ int three(std::string&&) { return 1; }
std::string&& four(std::string&& s) { return boost::move(s); }
#endif
int test_main(int, char*[])
int main()
{
using boost::function;
@ -102,5 +103,5 @@ int test_main(int, char*[])
BOOST_CHECK(f4(std::string("world")) == "world");
#endif
return 0;
return boost::report_errors();
}

View File

@ -7,16 +7,18 @@
// For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
#include <new>
struct stateless_integer_add {
int operator()(int x, int y) const { return x+y; }
void* operator new(std::size_t)
void* operator new(std::size_t n)
{
throw std::runtime_error("Cannot allocate a stateless_integer_add");
BOOST_ERROR( "stateless_integer_add incorrectly allocated" );
return ::operator new( n );
}
void* operator new(std::size_t, void* p)
@ -24,15 +26,17 @@ struct stateless_integer_add {
return p;
}
void operator delete(void*) throw()
void operator delete(void* p) throw()
{
BOOST_ERROR( "stateless_integer_add incorrectly deallocated" );
return ::operator delete( p );
}
};
int test_main(int, char*[])
int main()
{
boost::function2<int, int, int> f;
f = stateless_integer_add();
return 0;
return boost::report_errors();
}

View File

@ -8,7 +8,16 @@
// For more information, see http://www.boost.org/
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wdeprecated-declarations" )
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
#endif
#if defined(__GNUC__) && __GNUC__ >= 12
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <boost/function.hpp>
#include <iostream>
#include <functional>

View File

@ -8,7 +8,16 @@
// For more information, see http://www.boost.org/
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wdeprecated-declarations" )
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
#endif
#if defined(__GNUC__) && __GNUC__ >= 12
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <boost/function.hpp>
#include <iostream>
#include <functional>

View File

@ -0,0 +1,14 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
void throw_bad_function_call();
int main()
{
BOOST_TEST_THROWS( throw_bad_function_call(), boost::bad_function_call );
return boost::report_errors();
}

View File

@ -0,0 +1,48 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
//
void call_fn_1( boost::function<void()> const & fn );
void call_fn_2( boost::function<void(int)> const & fn );
void call_fn_3( boost::function<void(int, int)> const & fn );
void call_fn_4( boost::function0<void> const & fn );
void call_fn_5( boost::function1<void, int> const & fn );
void call_fn_6( boost::function2<void, int, int> const & fn );
//
static int v;
void f0()
{
v = -1;
}
void f1( int x )
{
v = x;
}
void f2( int x, int y )
{
v = x + y;
}
int main()
{
v = 0; call_fn_1( f0 ); BOOST_TEST_EQ( v, -1 );
v = 0; call_fn_2( f1 ); BOOST_TEST_EQ( v, 1 );
v = 0; call_fn_3( f2 ); BOOST_TEST_EQ( v, 3 );
v = 0; call_fn_4( f0 ); BOOST_TEST_EQ( v, -1 );
v = 0; call_fn_5( f1 ); BOOST_TEST_EQ( v, 1 );
v = 0; call_fn_6( f2 ); BOOST_TEST_EQ( v, 3 );
return boost::report_errors();
}

View File

@ -0,0 +1,21 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
//
boost::function<int(int, int)> get_fn_1();
boost::function2<int, int, int> get_fn_2();
//
int main()
{
BOOST_TEST_EQ( get_fn_1()( 1, 2 ), 3 );
BOOST_TEST_EQ( get_fn_2()( 1, 2 ), 3 );
return boost::report_errors();
}

View File

@ -0,0 +1,17 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/function.hpp>
#include <boost/config.hpp>
#if defined(THROW_BAD_FUNCTION_CALL_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
EXPORT void throw_bad_function_call()
{
throw boost::bad_function_call();
}