Compare commits

...

53 Commits

Author SHA1 Message Date
cd79ba8c8b Remove C++03 from Travis and Appveyor 2019-11-06 03:12:56 +02:00
f3e4ed2481 Use std::function 2019-11-06 03:10:09 +02:00
a7c28f6117 Remove tests that require C++03 to pass 2019-11-06 03:09:54 +02: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
37 changed files with 1192 additions and 463 deletions

View File

@ -1,162 +1,322 @@
# Copyright 2016 Peter Dimov # Copyright 2016-2019 Peter Dimov
# Copyright 2017, 2018 James E. King III
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Travis CI build script for boostorg repositories
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have move than include/, src/, test/, example/, examples/, or
# tools/ directories, modify your Travis CI project and add the environment
# variable DEPINST. For example if your build uses code in "bench/" and
# "fog/" directories, then set DEPINST to the following:
# --include bench --include fog
# 3. If you want to enable Coverity Scan, you need to provide the environment
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
# your github settings.
# 4. Enable pull request builds in your boostorg/<library> account.
# 5. Change the default C++ version in ci/travis/*.sh (search for CXXSTD) if needed.
#
# That's it - the scripts will do everything else for you.
sudo: false
dist: trusty
language: cpp language: cpp
env: sudo: false
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however..
# - B2_ADDRESS_MODEL=address-model=64,32
# - B2_LINK=link=shared,static
# - B2_THREADING=threading=multi,single
- B2_VARIANT=variant=release,debug
install: dist: trusty
- git clone https://github.com/jeking3/boost-ci.git boost-ci
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
- source ci/travis/install.sh
addons:
apt:
packages:
- binutils-gold
- gdb
- libc6-dbg
branches: branches:
only: only:
- develop
- master - master
- develop
script: - /feature\/.*/
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/build.sh env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
jobs:
include: include:
#################### Jobs to run on every pull request ####################
- os: linux - os: linux
env: compiler: g++
- COMMENT="C++03" env: TOOLSET=gcc CXXSTD=11
- TOOLSET=gcc,gcc-7,clang
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc CXXSTD=0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc CXXSTD=0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc CXXSTD=11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc CXXSTD=11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc CXXSTD=11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc CXXSTD=11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc CXXSTD=11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-7
env: TOOLSET=gcc CXXSTD=11,14,17
addons: addons:
apt: apt:
packages: packages:
- g++-7 - g++-7
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- os: linux - os: linux
env: compiler: g++-8
- COMMENT="C++11" env: TOOLSET=gcc CXXSTD=11,14,17,2a
- TOOLSET=gcc,gcc-7,clang addons:
- CXXSTD=11 apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc CXXSTD=11,14,17,2a
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-7
env: UBSAN=1 TOOLSET=gcc CXXSTD=11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons: addons:
apt: apt:
packages: packages:
- g++-7 - g++-7
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- os: linux - os: linux
env: compiler: clang++
- COMMENT=valgrind env: TOOLSET=clang CXXSTD=11
- TOOLSET=clang
- B2_VARIANT=variant=debug - os: linux
- TESTFLAGS=testing.launcher=valgrind compiler: /usr/bin/clang++
- VALGRIND_OPTS=--error-exitcode=1 env: TOOLSET=clang CXXSTD=11
addons:
apt:
packages:
- clang-3.3
- os: linux
compiler: /usr/bin/clang++
env: TOOLSET=clang CXXSTD=11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang CXXSTD=11,14,1z
addons: addons:
apt: apt:
packages: packages:
- clang-5.0 - clang-5.0
- libstdc++-7-dev
- valgrind
sources: sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0 - llvm-toolchain-trusty-5.0
- ubuntu-toolchain-r-test
- os: linux - os: linux
env: compiler: clang++-6.0
- COMMENT=cppcheck env: TOOLSET=clang CXXSTD=11,14,17,2a
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/cppcheck.sh
- os: linux
env:
- COMMENT=UBSAN
- B2_VARIANT=variant=debug
- TOOLSET=gcc-7
- CXXFLAGS="cxxflags=-fno-omit-frame-pointer cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined"
- LINKFLAGS="linkflags=-fsanitize=undefined linkflags=-fno-sanitize-recover=undefined linkflags=-fuse-ld=gold"
- UBSAN_OPTIONS=print_stacktrace=1
addons: addons:
apt: apt:
packages: packages:
- g++-7 - clang-6.0
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux - os: linux
env: compiler: clang++-7
- COMMENT=CodeCov env: TOOLSET=clang CXXSTD=11,14,17,2a
- TOOLSET=gcc-7
addons: addons:
apt: apt:
packages: packages:
- gcc-7 - clang-7
- g++-7
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
script: - llvm-toolchain-trusty-7
- pushd /tmp && git clone https://github.com/linux-test-project/lcov.git && export PATH=/tmp/lcov/bin:$PATH && which lcov && lcov --version && popd
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/codecov.sh
# does not work with sources install shell yet: see
# https://travis-ci.org/jeking3/tokenizer/jobs/384903189
# for a typical failure
# - os: osx
# osx_image: xcode9
# env:
# - TOOLSET=clang
# - CXXSTD=03,11
#################### Jobs to run on pushes to master, develop ###################
# Coverity Scan
- os: linux - os: linux
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push)) compiler: clang++-8
env: env: TOOLSET=clang CXXSTD=11,14,17,2a
- COMMENT="Coverity Scan" addons:
- TOOLSET=gcc apt:
script: packages:
- cd $BOOST_ROOT/libs/$SELF - clang-8
- ci/travis/coverity.sh sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
- os: linux
compiler: clang++-8
env: UBSAN=1 TOOLSET=clang CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
- os: linux
compiler: clang++-libc++
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- libc++-dev
- os: linux
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang CXXSTD=11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: osx
compiler: clang++
env: TOOLSET=clang CXXSTD=11,14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/function
- python tools/boostdep/depinst/depinst.py function
- ./bootstrap.sh
- ./b2 headers
script:
- |-
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: notifications:
email: email:
false on_success: always

28
CMakeLists.txt Normal file
View File

@ -0,0 +1,28 @@
# Copyright 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
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet
cmake_minimum_required(VERSION 3.5)
project(BoostFunction 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
)

11
Jamfile
View File

@ -1,11 +0,0 @@
# Boost.Function Library Jamfile
#
# Copyright (c) 2018 James E. King III
#
# 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)
# please order by name to ease maintenance
build-project example ;
build-project test ;

23
LICENSE
View File

@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -1,34 +1,18 @@
Function, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), contains a family of class templates that are function object wrappers. # Boost.Function, a polymorphic function wrapper
### License [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).
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). ## Currently supported compilers
### Properties * g++ 4.4 or later
* clang++ 3.3 or later
* Visual Studio 2005-2017
* C++03 Tested on [Travis](https://travis-ci.org/boostorg/function/) and [Appveyor](https://ci.appveyor.com/project/pdimov/function/).
* Header-Only
### Build Status ## License
Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
[`master`](https://github.com/boostorg/function/tree/master) | [![Build Status](https://travis-ci.org/boostorg/function.svg?branch=master)](https://travis-ci.org/boostorg/function) | [![Build status](https://ci.appveyor.com/api/projects/status/7tgx4ac44fikr87d/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/function-d036y/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15843/badge.svg)](https://scan.coverity.com/projects/boostorg-function) | [![codecov](https://codecov.io/gh/boostorg/function/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/function/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/function.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/function.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/function.html)
[`develop`](https://github.com/boostorg/function/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/function.svg?branch=develop)](https://travis-ci.org/boostorg/function) | [![Build status](https://ci.appveyor.com/api/projects/status/7tgx4ac44fikr87d/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/function-d036y/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15843/badge.svg)](https://scan.coverity.com/projects/boostorg-function) | [![codecov](https://codecov.io/gh/boostorg/function/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/function/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/function.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/function.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/function.html)
### Directories
| Name | Purpose |
| ----------- | ------------------------------ |
| `doc` | documentation |
| `example` | examples |
| `include` | headers |
| `test` | unit tests |
### More information
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-function)
* [Report bugs](https://github.com/boostorg/function/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[function]` tag at the beginning of the subject line.
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).

View File

@ -1,5 +1,4 @@
# Copyright 2016, 2017 Peter Dimov # Copyright 2016-2019 Peter Dimov
# Copyright (C) 2017, 2018 James E. King III
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -9,73 +8,54 @@ shallow_clone: true
branches: branches:
only: only:
- develop
- master - master
- develop
matrix: - /feature\/.*/
allow_failures:
- MAYFAIL: true
environment: environment:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however..
# on Windows it is important to exercise all the possibilities, especially shared vs static
# B2_ADDRESS_MODEL: address-model=64,32
# B2_LINK: link=shared,static
# B2_THREADING: threading=multi,single
B2_VARIANT: variant=release,debug
CXXSTD: 03
matrix: matrix:
- FLAVOR: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
- 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 TOOLSET: msvc-14.1
B2_ADDRESS_MODEL: address-model=64,32 CXXSTD: 14,17
- FLAVOR: Visual Studio 2015 ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
B2_ADDRESS_MODEL: address-model=64,32
- FLAVOR: Visual Studio 2010, 2012, 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
- FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin; ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: address-model=32
# https://github.com/boostorg/test/issues/144
DEFINES: define=_POSIX_C_SOURCE=200112L
THREADING: threadapi=pthread
TOOLSET: gcc TOOLSET: gcc
- FLAVOR: cygwin (64-bit) CXXSTD: 11,14,1z
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin; ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: address-model=64
# https://github.com/boostorg/test/issues/144
DEFINES: define=_POSIX_C_SOURCE=200112L
THREADING: threadapi=pthread
TOOLSET: gcc TOOLSET: gcc
- FLAVOR: mingw32 CXXSTD: 11,14,1z
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ARCH: i686 ADDPATH: C:\mingw\bin;
B2_ADDRESS_MODEL: address-model=32 TOOLSET: gcc
SCRIPT: ci\appveyor\mingw.bat CXXSTD: 11,14,1z
- FLAVOR: mingw64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
ARCH: x86_64 TOOLSET: gcc
B2_ADDRESS_MODEL: address-model=64 CXXSTD: 11,14,1z
SCRIPT: ci\appveyor\mingw.bat
install: install:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_% - set BOOST_BRANCH=develop
- git clone https://github.com/jeking3/boost-ci.git C:\boost-ci - if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- xcopy /s /e /q /i C:\boost-ci\ci .\ci - cd ..
- ci\appveyor\install.bat - 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 build: off
test_script: test_script:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- PATH=%ADDPATH%%PATH% - PATH=%ADDPATH%%PATH%
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF% toolset=%TOOLSET% cxxstd=%CXXSTD% %CXXFLAGS% %DEFINES% %THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3) - 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

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

@ -1,20 +0,0 @@
# Boost.Function Library example Jamfile
#
# Copyright (c) 2008 James E. King III
#
# Distributed under the Boost Software License, Version 1.0. (See accompany-
# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import os ;
import testing ;
project
: requirements
;
test-suite "function-examples"
: [ run bind1st.cpp ]
[ run int_div.cpp ]
[ run sum_avg.cpp ]
;

View File

@ -10,6 +10,364 @@
// William Kempf, Jesse Jones and Karl Nelson were all very helpful in the // William Kempf, Jesse Jones and Karl Nelson were all very helpful in the
// design of this library. // design of this library.
#include <boost/function/detail/config.hpp>
#if !BOOST_FUNCTION_ENABLE_CXX03
#ifndef BOOST_FUNCTION_HPP_INCLUDED
#define BOOST_FUNCTION_HPP_INCLUDED
#include <boost/ref.hpp>
#include <boost/function_equal.hpp>
#include <functional>
#include <type_traits>
namespace boost
{
#define BOOST_FUNCTION_TARGET_FIX(x)
using std::bad_function_call;
template<class S> class function: public std::function<S>
{
public:
function() = default;
function(function const&) = default;
function(function&&) = default;
using std::function<S>::function;
template<class T> function( boost::reference_wrapper<T> rt ): std::function<S>( std::ref( rt.get() ) )
{
}
function& operator=( function const& r ) = default;
function& operator=( function&& r ) = default;
template<class S2> function& operator=( function<S2> const& r )
{
std::function<S>::operator=( static_cast< std::function<S2> const& >( r ) );
return *this;
}
template<class S2> function& operator=( function<S2>&& r )
{
std::function<S>::operator=( static_cast< std::function<S2>&& >( r ) );
return *this;
}
template<class F, class E = typename std::enable_if< !std::is_integral<F>::value && !std::is_same<F, function>::value >::type > function& operator=( F f )
{
std::function<S>::operator=( std::move( f ) );
return *this;
}
function& operator=( std::nullptr_t f )
{
std::function<S>::operator=( f );
return *this;
}
template<class T> function& operator=( boost::reference_wrapper<T> rt )
{
std::function<S>::operator=( std::ref( rt.get() ) );
return *this;
}
bool empty() const noexcept
{
return ! *this;
}
void clear()
{
*this = nullptr;
}
template<class F, class A> void assign( F f, A )
{
this->operator=( std::move( f ) );
}
template<class F> F * target() noexcept
{
if( F * p = std::function<S>::template target<F>() )
{
return p;
}
if( std::reference_wrapper<F> * p = std::function<S>::template target< std::reference_wrapper<F> >() )
{
return std::addressof( p->get() );
}
return nullptr;
}
template<class F> F const * target() const noexcept
{
if( F const * p = std::function<S>::template target<F>() )
{
return p;
}
if( std::reference_wrapper<F> const * p = std::function<S>::template target< std::reference_wrapper<F> >() )
{
return std::addressof( p->get() );
}
return nullptr;
}
template<class F> bool contains( F const& f ) const noexcept
{
if( F const * fp = this->template target<F>() )
{
return function_equal( *fp, f );
}
else
{
return false;
}
}
};
template<class S, class F, class E = typename std::enable_if< !std::is_integral<F>::value && !std::is_same<F, std::nullptr_t>::value>::type> inline bool operator==( function<S> const & g, F f )
{
return g.contains( f );
}
template<class S, class F, class E = typename std::enable_if< !std::is_integral<F>::value && !std::is_same<F, std::nullptr_t>::value>::type> inline bool operator!=( function<S> const & g, F f )
{
return !g.contains( f );
}
template<class S, class F> inline bool operator==( function<S> const & g, boost::reference_wrapper<F> rf )
{
return g.template target<F>() == std::addressof( rf.get() );
}
template<class S, class F> inline bool operator!=( function<S> const & g, boost::reference_wrapper<F> rf )
{
return g.template target<F>() != std::addressof( rf.get() );
}
template<class S, class F, class E = typename std::enable_if< !std::is_integral<F>::value && !std::is_same<F, std::nullptr_t>::value>::type> inline bool operator==( F f, function<S> const & g )
{
return g.contains( f );
}
template<class S, class F, class E = typename std::enable_if< !std::is_integral<F>::value && !std::is_same<F, std::nullptr_t>::value>::type> inline bool operator!=( F f, function<S> const & g )
{
return !g.contains( f );
}
template<class S, class F> inline bool operator==( boost::reference_wrapper<F> rf, function<S> const & g )
{
return g.template target<F>() == std::addressof( rf.get() );
}
template<class S, class F> inline bool operator!=( boost::reference_wrapper<F> rf, function<S> const & g )
{
return g.template target<F>() != std::addressof( rf.get() );
}
namespace detail
{
template<class T1, class T2> struct is_similar
{
BOOST_STATIC_CONSTANT( bool, value = false );
};
template<template<class...> class L, class... T1, class... T2> struct is_similar< L<T1...>, L<T2...> >
{
BOOST_STATIC_CONSTANT( bool, value = true );
};
} // namespace detail
#define BOOST_FUNCTION_N_COMMON \
\
using base_type::base_type;\
\
template<class F, class E = typename std::enable_if< !std::is_integral<F>::value && !detail::is_similar<F, this_type>::value >::type > this_type& operator=( F f )\
{\
base_type::operator=( std::move( f ) );\
return *this;\
}\
\
this_type& operator=( std::nullptr_t f )\
{\
base_type::operator=( f );\
return *this;\
}\
\
template<class S2> this_type& operator=( boost::function<S2> const& r )\
{\
base_type::operator=( r );\
return *this;\
}\
\
template<class S2> this_type& operator=( boost::function<S2>&& r )\
{\
base_type::operator=( std::move( r ) );\
return *this;\
}
template<typename R> class function0: public function<R()>
{
private:
typedef function0 this_type;
typedef function<R()> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1> class function1: public function<R(T1)>
{
private:
typedef function1 this_type;
typedef function<R(T1)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2> class function2: public function<R(T1, T2)>
{
private:
typedef function2 this_type;
typedef function<R(T1, T2)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3> class function3: public function<R(T1, T2, T3)>
{
private:
typedef function3 this_type;
typedef function<R(T1, T2, T3)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3, typename T4> class function4: public function<R(T1, T2, T3, T4)>
{
private:
typedef function4 this_type;
typedef function<R(T1, T2, T3, T4)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3, typename T4, typename T5> class function5: public function<R(T1, T2, T3, T4, T5)>
{
private:
typedef function5 this_type;
typedef function<R(T1, T2, T3, T4, T5)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> class function6: public function<R(T1, T2, T3, T4, T5, T6)>
{
private:
typedef function6 this_type;
typedef function<R(T1, T2, T3, T4, T5, T6)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> class function7: public function<R(T1, T2, T3, T4, T5, T6, T7)>
{
private:
typedef function7 this_type;
typedef function<R(T1, T2, T3, T4, T5, T6, T7)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> class function8: public function<R(T1, T2, T3, T4, T5, T6, T7, T8)>
{
private:
typedef function8 this_type;
typedef function<R(T1, T2, T3, T4, T5, T6, T7, T8)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> class function9: public function<R(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
{
private:
typedef function9 this_type;
typedef function<R(T1, T2, T3, T4, T5, T6, T7, T8, T9)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> class function10: public function<R(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
{
private:
typedef function10 this_type;
typedef function<R(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
template<typename R, typename... A> class function30: public function<R(A...)>
{
private:
typedef function30 this_type;
typedef function<R(A...)> base_type;
public:
BOOST_FUNCTION_N_COMMON
};
} // namespace boost
#endif // #ifndef BOOST_FUNCTION_HPP_INCLUDED
#else
#ifndef BOOST_FUNCTION_MAX_ARGS #ifndef BOOST_FUNCTION_MAX_ARGS
# define BOOST_FUNCTION_MAX_ARGS 10 # define BOOST_FUNCTION_MAX_ARGS 10
#endif // BOOST_FUNCTION_MAX_ARGS #endif // BOOST_FUNCTION_MAX_ARGS
@ -23,7 +381,7 @@
#include <functional> // unary_function, binary_function #include <functional> // unary_function, binary_function
#include <boost/preprocessor/iterate.hpp> #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 // 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 // in anything that may be included by function_template.hpp doesn't break
@ -72,3 +430,5 @@
#endif #endif
#endif // !defined(BOOST_FUNCTION_MAX_ARGS_DEFINED) || (BOOST_FUNCTION_MAX_ARGS_DEFINED != BOOST_FUNCTION_MAX_ARGS) #endif // !defined(BOOST_FUNCTION_MAX_ARGS_DEFINED) || (BOOST_FUNCTION_MAX_ARGS_DEFINED != BOOST_FUNCTION_MAX_ARGS)
#endif

View File

@ -0,0 +1,12 @@
// 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
#ifndef BOOST_FUNCTION_DETAIL_CONFIG_HPP_INCLUDED
#define BOOST_FUNCTION_DETAIL_CONFIG_HPP_INCLUDED
#if !defined(BOOST_FUNCTION_ENABLE_CXX03)
# define BOOST_FUNCTION_ENABLE_CXX03 0
#endif
#endif // #ifndef BOOST_FUNCTION_DETAIL_CONFIG_HPP_INCLUDED

View File

@ -7,6 +7,10 @@
// For more information, see http://www.boost.org // For more information, see http://www.boost.org
#include <boost/function/detail/config.hpp>
#if BOOST_FUNCTION_ENABLE_CXX03
#if BOOST_FUNCTION_NUM_ARGS == 0 #if BOOST_FUNCTION_NUM_ARGS == 0
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED # undef BOOST_FUNCTION_MAX_ARGS_DEFINED
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 0 # define BOOST_FUNCTION_MAX_ARGS_DEFINED 0
@ -367,3 +371,5 @@
#else #else
# error Cannot handle Boost.Function objects that accept more than 50 arguments! # error Cannot handle Boost.Function objects that accept more than 50 arguments!
#endif #endif
#endif

View File

@ -26,13 +26,13 @@
#include <boost/type_traits/is_volatile.hpp> #include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/composite_traits.hpp> #include <boost/type_traits/composite_traits.hpp>
#include <boost/ref.hpp> #include <boost/ref.hpp>
#include <boost/mpl/if.hpp> #include <boost/type_traits/conditional.hpp>
#include <boost/detail/workaround.hpp> #include <boost/config/workaround.hpp>
#include <boost/type_traits/alignment_of.hpp> #include <boost/type_traits/alignment_of.hpp>
#ifndef BOOST_NO_SFINAE #ifndef BOOST_NO_SFINAE
# include "boost/utility/enable_if.hpp" #include <boost/type_traits/enable_if.hpp>
#else #else
# include "boost/mpl/bool.hpp" #include <boost/type_traits/integral_constant.hpp>
#endif #endif
#include <boost/function_equal.hpp> #include <boost/function_equal.hpp>
#include <boost/function/function_fwd.hpp> #include <boost/function/function_fwd.hpp>
@ -50,7 +50,7 @@
#endif // __ICL etc #endif // __ICL etc
# define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \ # define BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor,Type) \
typename ::boost::enable_if_c< \ typename ::boost::enable_if_< \
!(::boost::is_integral<Functor>::value), \ !(::boost::is_integral<Functor>::value), \
Type>::type Type>::type
@ -101,7 +101,7 @@ namespace boost {
} obj_ref; } obj_ref;
}; };
union function_buffer union BOOST_SYMBOL_VISIBLE function_buffer
{ {
// Type-specific union members // Type-specific union members
mutable function_buffer_members members; mutable function_buffer_members members;
@ -152,15 +152,15 @@ namespace boost {
template<typename F> template<typename F>
class get_function_tag class get_function_tag
{ {
typedef typename mpl::if_c<(is_pointer<F>::value), typedef typename conditional<(is_pointer<F>::value),
function_ptr_tag, function_ptr_tag,
function_obj_tag>::type ptr_or_obj_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, member_ptr_tag,
ptr_or_obj_tag>::type ptr_or_obj_or_mem_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, function_obj_ref_tag,
ptr_or_obj_or_mem_tag>::type or_ref_tag; ptr_or_obj_or_mem_tag>::type or_ref_tag;
@ -328,7 +328,7 @@ namespace boost {
// Function objects that fit in the small-object buffer. // Function objects that fit in the small-object buffer.
static inline void static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer, 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); functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
} }
@ -336,7 +336,7 @@ namespace boost {
// Function objects that require heap allocation // Function objects that require heap allocation
static inline void static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer, 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) { if (op == clone_functor_tag) {
// Clone the functor // Clone the functor
@ -377,7 +377,7 @@ namespace boost {
functor_manager_operation_type op, function_obj_tag) functor_manager_operation_type op, function_obj_tag)
{ {
manager(in_buffer, out_buffer, op, 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. // For member pointers, we use the small-object optimization buffer.
@ -385,7 +385,7 @@ namespace boost {
manager(const function_buffer& in_buffer, function_buffer& out_buffer, manager(const function_buffer& in_buffer, function_buffer& out_buffer,
functor_manager_operation_type op, member_ptr_tag) 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: public:
@ -396,16 +396,12 @@ namespace boost {
functor_manager_operation_type op) functor_manager_operation_type op)
{ {
typedef typename get_function_tag<functor_type>::type tag_type; typedef typename get_function_tag<functor_type>::type tag_type;
switch (op) { if (op == get_functor_type_tag) {
case get_functor_type_tag:
out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info(); out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info();
out_buffer.members.type.const_qualified = false; out_buffer.members.type.const_qualified = false;
out_buffer.members.type.volatile_qualified = false; out_buffer.members.type.volatile_qualified = false;
return; } else {
default:
manager(in_buffer, out_buffer, op, tag_type()); manager(in_buffer, out_buffer, op, tag_type());
return;
} }
} }
}; };
@ -427,7 +423,7 @@ namespace boost {
// Function objects that fit in the small-object buffer. // Function objects that fit in the small-object buffer.
static inline void static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer, 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); functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
} }
@ -435,7 +431,7 @@ namespace boost {
// Function objects that require heap allocation // Function objects that require heap allocation
static inline void static inline void
manager(const function_buffer& in_buffer, function_buffer& out_buffer, 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; typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
#if defined(BOOST_NO_CXX11_ALLOCATOR) #if defined(BOOST_NO_CXX11_ALLOCATOR)
@ -499,7 +495,7 @@ namespace boost {
functor_manager_operation_type op, function_obj_tag) functor_manager_operation_type op, function_obj_tag)
{ {
manager(in_buffer, out_buffer, op, 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: public:
@ -510,16 +506,12 @@ namespace boost {
functor_manager_operation_type op) functor_manager_operation_type op)
{ {
typedef typename get_function_tag<functor_type>::type tag_type; typedef typename get_function_tag<functor_type>::type tag_type;
switch (op) { if (op == get_functor_type_tag) {
case get_functor_type_tag:
out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info(); out_buffer.members.type.type = &boost::typeindex::type_id<functor_type>().type_info();
out_buffer.members.type.const_qualified = false; out_buffer.members.type.const_qualified = false;
out_buffer.members.type.volatile_qualified = false; out_buffer.members.type.volatile_qualified = false;
return; } else {
default:
manager(in_buffer, out_buffer, op, tag_type()); manager(in_buffer, out_buffer, op, tag_type());
return;
} }
} }
}; };
@ -530,24 +522,24 @@ namespace boost {
#ifdef BOOST_NO_SFINAE #ifdef BOOST_NO_SFINAE
// These routines perform comparisons between a Boost.Function // These routines perform comparisons between a Boost.Function
// object and an arbitrary function object (when the last // object and an arbitrary function object (when the last
// parameter is mpl::bool_<false>) or against zero (when the // parameter is false_type) or against zero (when the
// last parameter is mpl::bool_<true>). They are only necessary // last parameter is true_type). They are only necessary
// for compilers that don't support SFINAE. // for compilers that don't support SFINAE.
template<typename Function, typename Functor> template<typename Function, typename Functor>
bool 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(); } { return f.empty(); }
template<typename Function, typename Functor> template<typename Function, typename Functor>
bool bool
compare_not_equal(const Function& f, const Functor&, int, compare_not_equal(const Function& f, const Functor&, int,
mpl::bool_<true>) true_type)
{ return !f.empty(); } { return !f.empty(); }
template<typename Function, typename Functor> template<typename Function, typename Functor>
bool bool
compare_equal(const Function& f, const Functor& g, long, compare_equal(const Function& f, const Functor& g, long,
mpl::bool_<false>) false_type)
{ {
if (const Functor* fp = f.template target<Functor>()) if (const Functor* fp = f.template target<Functor>())
return function_equal(*fp, g); return function_equal(*fp, g);
@ -557,7 +549,7 @@ namespace boost {
template<typename Function, typename Functor> template<typename Function, typename Functor>
bool bool
compare_equal(const Function& f, const reference_wrapper<Functor>& g, 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>()) if (const Functor* fp = f.template target<Functor>())
return fp == g.get_pointer(); return fp == g.get_pointer();
@ -567,7 +559,7 @@ namespace boost {
template<typename Function, typename Functor> template<typename Function, typename Functor>
bool bool
compare_not_equal(const Function& f, const Functor& g, long, compare_not_equal(const Function& f, const Functor& g, long,
mpl::bool_<false>) false_type)
{ {
if (const Functor* fp = f.template target<Functor>()) if (const Functor* fp = f.template target<Functor>())
return !function_equal(*fp, g); return !function_equal(*fp, g);
@ -578,7 +570,7 @@ namespace boost {
bool bool
compare_not_equal(const Function& f, compare_not_equal(const Function& f,
const reference_wrapper<Functor>& g, int, const reference_wrapper<Functor>& g, int,
mpl::bool_<false>) false_type)
{ {
if (const Functor* fp = f.template target<Functor>()) if (const Functor* fp = f.template target<Functor>())
return fp != g.get_pointer(); return fp != g.get_pointer();
@ -710,7 +702,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 * The bad_function_call exception class is thrown when a boost::function
* object is invoked * object is invoked
*/ */
class bad_function_call : public std::runtime_error class BOOST_SYMBOL_VISIBLE bad_function_call : public std::runtime_error
{ {
public: public:
bad_function_call() : std::runtime_error("call to empty boost::function") {} bad_function_call() : std::runtime_error("call to empty boost::function") {}
@ -750,28 +742,28 @@ inline bool operator!=(detail::function::useless_clear_type*,
template<typename Functor> template<typename Functor>
inline bool operator==(const function_base& f, Functor g) 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()); return detail::function::compare_equal(f, g, 0, integral());
} }
template<typename Functor> template<typename Functor>
inline bool operator==(Functor g, const function_base& f) 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()); return detail::function::compare_equal(f, g, 0, integral());
} }
template<typename Functor> template<typename Functor>
inline bool operator!=(const function_base& f, Functor g) 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()); return detail::function::compare_not_equal(f, g, 0, integral());
} }
template<typename Functor> template<typename Functor>
inline bool operator!=(Functor g, const function_base& f) 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()); return detail::function::compare_not_equal(f, g, 0, integral());
} }
#else #else

View File

@ -9,6 +9,7 @@
#ifndef BOOST_FUNCTION_FWD_HPP #ifndef BOOST_FUNCTION_FWD_HPP
#define BOOST_FUNCTION_FWD_HPP #define BOOST_FUNCTION_FWD_HPP
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/function/detail/config.hpp>
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 && !defined(BOOST_STRICT_CONFIG) #if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 && !defined(BOOST_STRICT_CONFIG)
// Work around a compiler bug. // Work around a compiler bug.
@ -24,9 +25,22 @@ namespace boost { namespace python { namespace objects {
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX # define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
#endif #endif
#if !BOOST_FUNCTION_ENABLE_CXX03
# include <functional>
#endif
namespace boost { namespace boost {
#if BOOST_FUNCTION_ENABLE_CXX03
class bad_function_call; class bad_function_call;
#else
using std::bad_function_call;
#endif
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX) #if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
// Preferred syntax // Preferred syntax
template<typename Signature> class function; template<typename Signature> class function;

View File

@ -11,7 +11,7 @@
// Note: this header is a header template and must NOT have multiple-inclusion // Note: this header is a header template and must NOT have multiple-inclusion
// protection. // protection.
#include <boost/function/detail/prologue.hpp> #include <boost/function/detail/prologue.hpp>
#include <boost/detail/no_exceptions_support.hpp> #include <boost/core/no_exceptions_support.hpp>
#if defined(BOOST_MSVC) #if defined(BOOST_MSVC)
# pragma warning( push ) # pragma warning( push )
@ -29,8 +29,7 @@
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
# define BOOST_FUNCTION_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, a) # define BOOST_FUNCTION_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, a)
#else #else
# include <boost/move/utility_core.hpp> # define BOOST_FUNCTION_ARG(J,I,D) static_cast<BOOST_PP_CAT(T,I)&&>(BOOST_PP_CAT(a,I))
# define BOOST_FUNCTION_ARG(J,I,D) ::boost::forward< 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) # define BOOST_FUNCTION_ARGS BOOST_PP_ENUM(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG,BOOST_PP_EMPTY)
#endif #endif
@ -240,7 +239,7 @@ namespace boost {
> >
struct BOOST_FUNCTION_GET_FUNCTION_INVOKER 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< BOOST_FUNCTION_VOID_FUNCTION_INVOKER<
FunctionPtr, FunctionPtr,
R BOOST_FUNCTION_COMMA R BOOST_FUNCTION_COMMA
@ -261,7 +260,7 @@ namespace boost {
> >
struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER 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< BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER<
FunctionObj, FunctionObj,
R BOOST_FUNCTION_COMMA R BOOST_FUNCTION_COMMA
@ -282,7 +281,7 @@ namespace boost {
> >
struct BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER 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< BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER<
FunctionObj, FunctionObj,
R BOOST_FUNCTION_COMMA R BOOST_FUNCTION_COMMA
@ -305,7 +304,7 @@ namespace boost {
> >
struct BOOST_FUNCTION_GET_MEMBER_INVOKER 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< BOOST_FUNCTION_VOID_MEMBER_INVOKER<
MemberPtr, MemberPtr,
R BOOST_FUNCTION_COMMA R BOOST_FUNCTION_COMMA
@ -350,9 +349,8 @@ namespace boost {
typedef functor_manager<FunctionPtr> manager_type; typedef functor_manager<FunctionPtr> manager_type;
}; };
template<typename FunctionPtr, template<typename FunctionPtr, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS, typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
typename Allocator>
struct apply_a struct apply_a
{ {
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER< typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
@ -385,9 +383,8 @@ namespace boost {
typedef functor_manager<MemberPtr> manager_type; typedef functor_manager<MemberPtr> manager_type;
}; };
template<typename MemberPtr, template<typename MemberPtr, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS, typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
typename Allocator>
struct apply_a struct apply_a
{ {
typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER< typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
@ -420,9 +417,8 @@ namespace boost {
typedef functor_manager<FunctionObj> manager_type; typedef functor_manager<FunctionObj> manager_type;
}; };
template<typename FunctionObj, template<typename FunctionObj, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS, typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
typename Allocator>
struct apply_a struct apply_a
{ {
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
@ -454,9 +450,8 @@ namespace boost {
typedef reference_manager<typename RefWrapper::type> manager_type; typedef reference_manager<typename RefWrapper::type> manager_type;
}; };
template<typename RefWrapper, template<typename RefWrapper, typename Allocator,
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS, typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
typename Allocator>
struct apply_a struct apply_a
{ {
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER< typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
@ -567,27 +562,27 @@ namespace boost {
// Assign to a function object using the small object optimization // Assign to a function object using the small object optimization
template<typename FunctionObj> template<typename FunctionObj>
void 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); new (reinterpret_cast<void*>(functor.data)) FunctionObj(f);
} }
template<typename FunctionObj,typename Allocator> template<typename FunctionObj,typename Allocator>
void 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. // Assign to a function object allocated on the heap.
template<typename FunctionObj> template<typename FunctionObj>
void 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); functor.members.obj_ptr = new FunctionObj(f);
} }
template<typename FunctionObj,typename Allocator> template<typename FunctionObj,typename Allocator>
void 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; typedef functor_wrapper<FunctionObj,Allocator> functor_wrapper_type;
#if defined(BOOST_NO_CXX11_ALLOCATOR) #if defined(BOOST_NO_CXX11_ALLOCATOR)
@ -615,7 +610,7 @@ namespace boost {
{ {
if (!boost::detail::function::has_empty_target(boost::addressof(f))) { if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
assign_functor(f, functor, 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; return true;
} else { } else {
return false; return false;
@ -627,7 +622,7 @@ namespace boost {
{ {
if (!boost::detail::function::has_empty_target(boost::addressof(f))) { if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
assign_functor_a(f, functor, a, 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; return true;
} else { } else {
return false; return false;
@ -708,14 +703,14 @@ namespace boost {
typedef BOOST_FUNCTION_FUNCTION self_type; 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 // MSVC chokes if the following two constructors are collapsed into
// one with a default parameter. // one with a default parameter.
template<typename Functor> template<typename Functor>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f
#ifndef BOOST_NO_SFINAE #ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c< ,typename boost::enable_if_<
!(is_integral<Functor>::value), !(is_integral<Functor>::value),
int>::type = 0 int>::type = 0
#endif // BOOST_NO_SFINAE #endif // BOOST_NO_SFINAE
@ -727,7 +722,7 @@ namespace boost {
template<typename Functor,typename Allocator> template<typename Functor,typename Allocator>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a
#ifndef BOOST_NO_SFINAE #ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c< ,typename boost::enable_if_<
!(is_integral<Functor>::value), !(is_integral<Functor>::value),
int>::type = 0 int>::type = 0
#endif // BOOST_NO_SFINAE #endif // BOOST_NO_SFINAE
@ -776,7 +771,7 @@ namespace boost {
// construct. // construct.
template<typename Functor> template<typename Functor>
#ifndef BOOST_NO_SFINAE #ifndef BOOST_NO_SFINAE
typename boost::enable_if_c< typename boost::enable_if_<
!(is_integral<Functor>::value), !(is_integral<Functor>::value),
BOOST_FUNCTION_FUNCTION&>::type BOOST_FUNCTION_FUNCTION&>::type
#else #else
@ -955,9 +950,8 @@ namespace boost {
typedef typename boost::detail::function::get_function_tag<Functor>::type tag; typedef typename boost::detail::function::get_function_tag<Functor>::type tag;
typedef boost::detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker; typedef boost::detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker;
typedef typename get_invoker:: typedef typename get_invoker::
template apply_a<Functor, R BOOST_FUNCTION_COMMA template apply_a<Functor, Allocator, R BOOST_FUNCTION_COMMA
BOOST_FUNCTION_TEMPLATE_ARGS, BOOST_FUNCTION_TEMPLATE_ARGS>
Allocator>
handler_type; handler_type;
typedef typename handler_type::invoker_type invoker_type; typedef typename handler_type::invoker_type invoker_type;
@ -1046,7 +1040,7 @@ template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
#if BOOST_FUNCTION_NUM_ARGS == 0 #if BOOST_FUNCTION_NUM_ARGS == 0
#define BOOST_FUNCTION_PARTIAL_SPEC R (void) #define BOOST_FUNCTION_PARTIAL_SPEC R (void)
#else #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 #endif
template<typename R BOOST_FUNCTION_COMMA template<typename R BOOST_FUNCTION_COMMA
@ -1061,12 +1055,12 @@ class function<BOOST_FUNCTION_PARTIAL_SPEC>
public: public:
function() : base_type() {} BOOST_DEFAULTED_FUNCTION(function(), : base_type() {})
template<typename Functor> template<typename Functor>
function(Functor f function(Functor f
#ifndef BOOST_NO_SFINAE #ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c< ,typename boost::enable_if_<
!(is_integral<Functor>::value), !(is_integral<Functor>::value),
int>::type = 0 int>::type = 0
#endif #endif
@ -1077,7 +1071,7 @@ public:
template<typename Functor,typename Allocator> template<typename Functor,typename Allocator>
function(Functor f, Allocator a function(Functor f, Allocator a
#ifndef BOOST_NO_SFINAE #ifndef BOOST_NO_SFINAE
,typename boost::enable_if_c< ,typename boost::enable_if_<
!(is_integral<Functor>::value), !(is_integral<Functor>::value),
int>::type = 0 int>::type = 0
#endif #endif
@ -1116,7 +1110,7 @@ public:
template<typename Functor> template<typename Functor>
#ifndef BOOST_NO_SFINAE #ifndef BOOST_NO_SFINAE
typename boost::enable_if_c< typename boost::enable_if_<
!(is_integral<Functor>::value), !(is_integral<Functor>::value),
self_type&>::type self_type&>::type
#else #else

View File

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

View File

@ -7,69 +7,69 @@
# For more information, see http://www.boost.org/ # 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 ; import testing ;
{ 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 ;
test-suite function 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_test.cpp : : : : lib_function_test ]
[ run libs/function/test/function_test.cpp : : : <rtti>off : lib_function_test_no_rtti ] 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/function_n_test.cpp : : : : ] lib mixed_cxxstd : mixed_cxxstd.cpp : <link>shared:<define>MIXED_CXXSTD_DYN_LINK=1 ;
[ run libs/function/test/allocator_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/stateless_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 ;
[ run libs/function/test/lambda_test.cpp ../../../libs/test/build//boost_test_exec_monitor : : : : ] 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_fail1.cpp : : : : ] local check14 = [ check-target-builds mixed_cxxstd/<cxxstd>14 : : <build>no ] ;
[ compile-fail libs/function/test/function_test_fail2.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.cpp : : : : ] lib return_function : return_function.cpp : <link>shared:<define>RETURN_FUNCTION_DYN_LINK=1 ;
[ compile libs/function/test/function_30_repeat.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_cxx98.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/function_arith_portable.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_cxx98.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/sum_avg_portable.cpp : : : : ] run quick.cpp ;
[ run libs/function/test/mem_fun_cxx98.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 ]
;
}

View File

@ -7,10 +7,10 @@
// For more information, see http://www.boost.org // 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 <cassert>
#include <functional> #include <functional>
#include <boost/function.hpp>
using namespace std; using namespace std;
using namespace boost; using namespace boost;
@ -74,20 +74,21 @@ struct DoNothing: base
static void do_nothing() {} static void do_nothing() {}
int int main()
test_main(int, char*[])
{ {
function2<int, int, int> f; function2<int, int, int> f;
f.assign( plus_int<disable_small_object_optimization>(), counting_allocator<int>() ); f.assign( plus_int<disable_small_object_optimization>(), counting_allocator<int>() );
f.clear(); f.clear();
BOOST_CHECK(alloc_count == 1); #if BOOST_FUNCTION_ENABLE_CXX03
BOOST_CHECK(dealloc_count == 1); BOOST_TEST_EQ( alloc_count, 1 );
BOOST_TEST_EQ( dealloc_count, 1 );
#endif
alloc_count = 0; alloc_count = 0;
dealloc_count = 0; dealloc_count = 0;
f.assign( plus_int<enable_small_object_optimization>(), counting_allocator<int>() ); f.assign( plus_int<enable_small_object_optimization>(), counting_allocator<int>() );
f.clear(); f.clear();
BOOST_CHECK(alloc_count == 0); BOOST_TEST_EQ( alloc_count, 0 );
BOOST_CHECK(dealloc_count == 0); BOOST_TEST_EQ( dealloc_count, 0 );
f.assign( plus_int<disable_small_object_optimization>(), std::allocator<int>() ); f.assign( plus_int<disable_small_object_optimization>(), std::allocator<int>() );
f.clear(); f.clear();
f.assign( plus_int<enable_small_object_optimization>(), std::allocator<int>() ); f.assign( plus_int<enable_small_object_optimization>(), std::allocator<int>() );
@ -97,8 +98,8 @@ test_main(int, char*[])
dealloc_count = 0; dealloc_count = 0;
f.assign( &do_minus, counting_allocator<int>() ); f.assign( &do_minus, counting_allocator<int>() );
f.clear(); f.clear();
BOOST_CHECK(alloc_count == 0); BOOST_TEST_EQ( alloc_count, 0 );
BOOST_CHECK(dealloc_count == 0); BOOST_TEST_EQ( dealloc_count, 0 );
f.assign( &do_minus, std::allocator<int>() ); f.assign( &do_minus, std::allocator<int>() );
f.clear(); f.clear();
@ -107,14 +108,16 @@ test_main(int, char*[])
dealloc_count = 0; dealloc_count = 0;
fv.assign( DoNothing<disable_small_object_optimization>(), counting_allocator<int>() ); fv.assign( DoNothing<disable_small_object_optimization>(), counting_allocator<int>() );
fv.clear(); fv.clear();
BOOST_CHECK(alloc_count == 1); #if BOOST_FUNCTION_ENABLE_CXX03
BOOST_CHECK(dealloc_count == 1); BOOST_TEST_EQ( alloc_count, 1 );
BOOST_TEST_EQ( dealloc_count, 1 );
#endif
alloc_count = 0; alloc_count = 0;
dealloc_count = 0; dealloc_count = 0;
fv.assign( DoNothing<enable_small_object_optimization>(), counting_allocator<int>() ); fv.assign( DoNothing<enable_small_object_optimization>(), counting_allocator<int>() );
fv.clear(); fv.clear();
BOOST_CHECK(alloc_count == 0); BOOST_TEST_EQ( alloc_count, 0 );
BOOST_CHECK(dealloc_count == 0); BOOST_TEST_EQ( dealloc_count, 0 );
fv.assign( DoNothing<disable_small_object_optimization>(), std::allocator<int>() ); fv.assign( DoNothing<disable_small_object_optimization>(), std::allocator<int>() );
fv.clear(); fv.clear();
fv.assign( DoNothing<enable_small_object_optimization>(), std::allocator<int>() ); fv.assign( DoNothing<enable_small_object_optimization>(), std::allocator<int>() );
@ -124,8 +127,8 @@ test_main(int, char*[])
dealloc_count = 0; dealloc_count = 0;
fv.assign( &do_nothing, counting_allocator<int>() ); fv.assign( &do_nothing, counting_allocator<int>() );
fv.clear(); fv.clear();
BOOST_CHECK(alloc_count == 0); BOOST_TEST_EQ( alloc_count, 0 );
BOOST_CHECK(dealloc_count == 0); BOOST_TEST_EQ( dealloc_count, 0 );
fv.assign( &do_nothing, std::allocator<int>() ); fv.assign( &do_nothing, std::allocator<int>() );
fv.clear(); fv.clear();
@ -133,5 +136,5 @@ test_main(int, char*[])
fv.assign(&do_nothing, std::allocator<int>() ); fv.assign(&do_nothing, std::allocator<int>() );
fv2.assign(fv, std::allocator<int>() ); fv2.assign(fv, std::allocator<int>() );
return 0; return boost::report_errors();
} }

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) // http://www.boost.org/LICENSE_1_0.txt)
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/detail/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
static int forty_two() static int forty_two()
{ {

View File

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

View File

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

View File

@ -7,12 +7,15 @@
// For more information, see http://www.boost.org // For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/workaround.hpp>
#include <functional> #include <functional>
#include <string> #include <string>
#include <utility> #include <utility>
#define BOOST_CHECK BOOST_TEST
using boost::function; using boost::function;
using std::string; using std::string;
@ -624,7 +627,7 @@ test_ref()
boost::function<int (int, int)> f(boost::ref(atc)); boost::function<int (int, int)> f(boost::ref(atc));
BOOST_CHECK(f(1, 3) == 4); BOOST_CHECK(f(1, 3) == 4);
} }
catch(std::runtime_error e) { catch(std::runtime_error const&) {
BOOST_ERROR("Nonthrowing constructor threw an exception"); BOOST_ERROR("Nonthrowing constructor threw an exception");
} }
} }
@ -651,14 +654,14 @@ static void test_empty_ref()
f2(); f2();
BOOST_ERROR("Exception didn't throw for reference to empty function."); BOOST_ERROR("Exception didn't throw for reference to empty function.");
} }
catch(std::runtime_error e) {} catch(boost::bad_function_call const&) {}
f1 = dummy; f1 = dummy;
try { try {
f2(); f2();
} }
catch(std::runtime_error e) { catch(boost::bad_function_call const&) {
BOOST_ERROR("Error calling referenced function."); BOOST_ERROR("Error calling referenced function.");
} }
} }
@ -673,7 +676,7 @@ static void test_exception()
f(5, 4); f(5, 4);
BOOST_CHECK(false); BOOST_CHECK(false);
} }
catch(boost::bad_function_call) { catch(boost::bad_function_call const&) {
// okay // okay
} }
} }
@ -792,7 +795,7 @@ static void test_move_semantics()
#endif #endif
} }
int test_main(int, char* []) int main()
{ {
test_zero_args(); test_zero_args();
test_one_arg(); test_one_arg();
@ -807,5 +810,5 @@ int test_main(int, char* [])
test_move_semantics<function<void()> >(); test_move_semantics<function<void()> >();
test_move_semantics<boost::function0<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 // For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
using namespace std; void test()
using namespace boost;
int
test_main(int, char*[])
{ {
function0<int> f1; boost::function0<int> f1;
function0<int> f2; boost::function0<int> f2;
if (f1 == f2) { if( f1 == f2 ) {}
}
BOOST_ERROR("This should not have compiled.");
return 0;
} }

View File

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

View File

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

View File

@ -10,7 +10,7 @@
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/detail/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <iostream> #include <iostream>
#include <functional> #include <functional>

View File

@ -10,7 +10,7 @@
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/detail/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <iostream> #include <iostream>
#include <functional> #include <functional>

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 // For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#define BOOST_CHECK BOOST_TEST
struct tried_to_copy { }; struct tried_to_copy { };
@ -40,7 +42,7 @@ struct MaybeThrowOnCopy {
bool MaybeThrowOnCopy::throwOnCopy = false; bool MaybeThrowOnCopy::throwOnCopy = false;
int test_main(int, char* []) int main()
{ {
boost::function0<int> f; boost::function0<int> f;
boost::function0<int> g; boost::function0<int> g;
@ -56,5 +58,5 @@ int test_main(int, char* [])
BOOST_CHECK(f() == 2); BOOST_CHECK(f() == 2);
BOOST_CHECK(g() == 1); 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 // 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 <iostream>
#include <cstdlib> #include <cstdlib>
#include <boost/test/minimal.hpp> #define BOOST_CHECK BOOST_TEST
#include <boost/function.hpp>
#include <boost/move/move.hpp>
class only_movable { class only_movable {
private: private:
@ -63,7 +64,7 @@ int three(std::string&&) { return 1; }
std::string&& four(std::string&& s) { return boost::move(s); } std::string&& four(std::string&& s) { return boost::move(s); }
#endif #endif
int test_main(int, char*[]) int main()
{ {
using boost::function; using boost::function;
@ -102,5 +103,5 @@ int test_main(int, char*[])
BOOST_CHECK(f4(std::string("world")) == "world"); BOOST_CHECK(f4(std::string("world")) == "world");
#endif #endif
return 0; return boost::report_errors();
} }

View File

@ -7,16 +7,18 @@
// For more information, see http://www.boost.org // For more information, see http://www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept> #include <stdexcept>
#include <new>
struct stateless_integer_add { struct stateless_integer_add {
int operator()(int x, int y) const { return x+y; } 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) void* operator new(std::size_t, void* p)
@ -24,15 +26,17 @@ struct stateless_integer_add {
return p; 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; boost::function2<int, int, int> f;
f = stateless_integer_add(); f = stateless_integer_add();
return 0; return boost::report_errors();
} }

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();
}