forked from boostorg/function
Compare commits
81 Commits
boost-1.64
...
feature/us
Author | SHA1 | Date | |
---|---|---|---|
cd79ba8c8b | |||
f3e4ed2481 | |||
a7c28f6117 | |||
8ec9323003 | |||
c39ca938a6 | |||
4b25a75c03 | |||
5682111fad | |||
1694b32e1b | |||
eaf2151263 | |||
d9043b76d6 | |||
2e2c44f070 | |||
7f69508eac | |||
6d811a2e72 | |||
3f6b2b6f56 | |||
439d64d8a8 | |||
3f46081c59 | |||
17716b63f2 | |||
b6b0568c88 | |||
babdbe500d | |||
db39532c45 | |||
eb09bb6fec | |||
ccc66b34d9 | |||
e7952cb242 | |||
57f4171c77 | |||
30f31f894c | |||
bfb0e4701e | |||
7b11b52e62 | |||
0a1a33a443 | |||
79045752e0 | |||
b149dba678 | |||
cd91278477 | |||
c18d123137 | |||
3bc2478a95 | |||
af15ab966e | |||
161f7557e7 | |||
f22fa49e07 | |||
5f93559650 | |||
5b2acbc175 | |||
755d3c2001 | |||
b07621f2ee | |||
df1f33eb00 | |||
86f05aa602 | |||
4230fb2388 | |||
453860ff9c | |||
0ee9299e5e | |||
d1a771b6ea | |||
27808e2bd5 | |||
528afe6b41 | |||
df80a7b29c | |||
c0d41a880a | |||
87c978d36e | |||
d1ad1141f3 | |||
b1fa00f3b1 | |||
feea19660b | |||
51145b9d2c | |||
251701850a | |||
151ce9492c | |||
7b4f5520e6 | |||
e91b39f94f | |||
4a83ca8a57 | |||
2afccba173 | |||
52fae95412 | |||
9d0acd5195 | |||
0482db3a79 | |||
0ee8e59d0a | |||
bd9c06bd37 | |||
f4f8fb0a16 | |||
eba48932f0 | |||
8defd1ea81 | |||
9c1285514f | |||
c257d432e9 | |||
1938737ee7 | |||
9096849ef0 | |||
d6cff3991d | |||
b84891ba9d | |||
01b81da059 | |||
a76403e102 | |||
44a68454aa | |||
0707a60115 | |||
dd04707209 | |||
471f6244e4 |
341
.travis.yml
341
.travis.yml
@ -1,4 +1,4 @@
|
||||
# Copyright 2016 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)
|
||||
|
||||
@ -6,63 +6,316 @@ language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
dist: trusty
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc CXXSTD=11
|
||||
|
||||
- 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:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
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:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=11
|
||||
|
||||
- os: linux
|
||||
compiler: /usr/bin/clang++
|
||||
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:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang CXXSTD=11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
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 $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 init libs/algorithm
|
||||
- git submodule init libs/align
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/bind
|
||||
- git submodule init libs/chrono
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/detail
|
||||
- git submodule init libs/exception
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/io
|
||||
- git submodule init libs/iterator
|
||||
- git submodule init libs/lambda
|
||||
- git submodule init libs/move
|
||||
- git submodule init libs/mpl
|
||||
- git submodule init libs/numeric/conversion
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/range
|
||||
- git submodule init libs/ratio
|
||||
- git submodule init libs/rational
|
||||
- git submodule init libs/smart_ptr
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/system
|
||||
- git submodule init libs/optional
|
||||
- git submodule init libs/test
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/timer
|
||||
- git submodule init libs/tuple
|
||||
- git submodule init libs/type_index
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/typeof
|
||||
- git submodule init libs/utility
|
||||
- git submodule init libs/winapi
|
||||
- git submodule init tools/build
|
||||
- git submodule update
|
||||
- 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:
|
||||
- TOOLSET=gcc,clang
|
||||
- if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi
|
||||
- ./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:
|
||||
|
28
CMakeLists.txt
Normal file
28
CMakeLists.txt
Normal 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
|
||||
)
|
18
README.md
Normal file
18
README.md
Normal 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.4 or later
|
||||
* clang++ 3.3 or later
|
||||
* Visual Studio 2005-2017
|
||||
|
||||
Tested on [Travis](https://travis-ci.org/boostorg/function/) 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).
|
61
appveyor.yml
Normal file
61
appveyor.yml
Normal file
@ -0,0 +1,61 @@
|
||||
# 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
|
||||
- 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 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 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: 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
|
14
example/Jamfile
Normal file
14
example/Jamfile
Normal 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 ;
|
@ -10,15 +10,379 @@
|
||||
// William Kempf, Jesse Jones and Karl Nelson were all very helpful in the
|
||||
// design of this library.
|
||||
|
||||
#include <functional> // unary_function, binary_function
|
||||
#include <boost/function/detail/config.hpp>
|
||||
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
#include <boost/detail/workaround.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
|
||||
# define BOOST_FUNCTION_MAX_ARGS 10
|
||||
#endif // BOOST_FUNCTION_MAX_ARGS
|
||||
|
||||
#if !defined(BOOST_FUNCTION_MAX_ARGS_DEFINED) || (BOOST_FUNCTION_MAX_ARGS_DEFINED != BOOST_FUNCTION_MAX_ARGS)
|
||||
|
||||
#if !defined(BOOST_FUNCTION_MAX_ARGS_DEFINED)
|
||||
#define BOOST_FUNCTION_MAX_ARGS_DEFINED 0
|
||||
#endif
|
||||
|
||||
#include <functional> // unary_function, binary_function
|
||||
|
||||
#include <boost/preprocessor/iterate.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
|
||||
#include <boost/function/detail/prologue.hpp>
|
||||
@ -64,3 +428,7 @@
|
||||
# include BOOST_PP_ITERATE()
|
||||
# undef BOOST_PP_ITERATION_PARAMS_1
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_FUNCTION_MAX_ARGS_DEFINED) || (BOOST_FUNCTION_MAX_ARGS_DEFINED != BOOST_FUNCTION_MAX_ARGS)
|
||||
|
||||
#endif
|
||||
|
12
include/boost/function/detail/config.hpp
Normal file
12
include/boost/function/detail/config.hpp
Normal 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
|
@ -27,6 +27,8 @@ for($on_arg = 0; $on_arg <= $max_args; ++$on_arg) {
|
||||
print OUT "#elif";
|
||||
}
|
||||
print OUT " BOOST_FUNCTION_NUM_ARGS == $on_arg\n";
|
||||
print OUT "# undef BOOST_FUNCTION_MAX_ARGS_DEFINED\n";
|
||||
print OUT "# define BOOST_FUNCTION_MAX_ARGS_DEFINED $on_arg\n";
|
||||
print OUT "# ifndef BOOST_FUNCTION_$on_arg\n";
|
||||
print OUT "# define BOOST_FUNCTION_$on_arg\n";
|
||||
print OUT "# include <boost/function/function_template.hpp>\n";
|
||||
|
@ -7,257 +7,363 @@
|
||||
|
||||
// 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
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 0
|
||||
# ifndef BOOST_FUNCTION_0
|
||||
# define BOOST_FUNCTION_0
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 1
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 1
|
||||
# ifndef BOOST_FUNCTION_1
|
||||
# define BOOST_FUNCTION_1
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 2
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 2
|
||||
# ifndef BOOST_FUNCTION_2
|
||||
# define BOOST_FUNCTION_2
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 3
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 3
|
||||
# ifndef BOOST_FUNCTION_3
|
||||
# define BOOST_FUNCTION_3
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 4
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 4
|
||||
# ifndef BOOST_FUNCTION_4
|
||||
# define BOOST_FUNCTION_4
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 5
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 5
|
||||
# ifndef BOOST_FUNCTION_5
|
||||
# define BOOST_FUNCTION_5
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 6
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 6
|
||||
# ifndef BOOST_FUNCTION_6
|
||||
# define BOOST_FUNCTION_6
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 7
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 7
|
||||
# ifndef BOOST_FUNCTION_7
|
||||
# define BOOST_FUNCTION_7
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 8
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 8
|
||||
# ifndef BOOST_FUNCTION_8
|
||||
# define BOOST_FUNCTION_8
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 9
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 9
|
||||
# ifndef BOOST_FUNCTION_9
|
||||
# define BOOST_FUNCTION_9
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 10
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 10
|
||||
# ifndef BOOST_FUNCTION_10
|
||||
# define BOOST_FUNCTION_10
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 11
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 11
|
||||
# ifndef BOOST_FUNCTION_11
|
||||
# define BOOST_FUNCTION_11
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 12
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 12
|
||||
# ifndef BOOST_FUNCTION_12
|
||||
# define BOOST_FUNCTION_12
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 13
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 13
|
||||
# ifndef BOOST_FUNCTION_13
|
||||
# define BOOST_FUNCTION_13
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 14
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 14
|
||||
# ifndef BOOST_FUNCTION_14
|
||||
# define BOOST_FUNCTION_14
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 15
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 15
|
||||
# ifndef BOOST_FUNCTION_15
|
||||
# define BOOST_FUNCTION_15
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 16
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 16
|
||||
# ifndef BOOST_FUNCTION_16
|
||||
# define BOOST_FUNCTION_16
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 17
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 17
|
||||
# ifndef BOOST_FUNCTION_17
|
||||
# define BOOST_FUNCTION_17
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 18
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 18
|
||||
# ifndef BOOST_FUNCTION_18
|
||||
# define BOOST_FUNCTION_18
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 19
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 19
|
||||
# ifndef BOOST_FUNCTION_19
|
||||
# define BOOST_FUNCTION_19
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 20
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 20
|
||||
# ifndef BOOST_FUNCTION_20
|
||||
# define BOOST_FUNCTION_20
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 21
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 21
|
||||
# ifndef BOOST_FUNCTION_21
|
||||
# define BOOST_FUNCTION_21
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 22
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 22
|
||||
# ifndef BOOST_FUNCTION_22
|
||||
# define BOOST_FUNCTION_22
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 23
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 23
|
||||
# ifndef BOOST_FUNCTION_23
|
||||
# define BOOST_FUNCTION_23
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 24
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 24
|
||||
# ifndef BOOST_FUNCTION_24
|
||||
# define BOOST_FUNCTION_24
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 25
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 25
|
||||
# ifndef BOOST_FUNCTION_25
|
||||
# define BOOST_FUNCTION_25
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 26
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 26
|
||||
# ifndef BOOST_FUNCTION_26
|
||||
# define BOOST_FUNCTION_26
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 27
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 27
|
||||
# ifndef BOOST_FUNCTION_27
|
||||
# define BOOST_FUNCTION_27
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 28
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 28
|
||||
# ifndef BOOST_FUNCTION_28
|
||||
# define BOOST_FUNCTION_28
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 29
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 29
|
||||
# ifndef BOOST_FUNCTION_29
|
||||
# define BOOST_FUNCTION_29
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 30
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 30
|
||||
# ifndef BOOST_FUNCTION_30
|
||||
# define BOOST_FUNCTION_30
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 31
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 31
|
||||
# ifndef BOOST_FUNCTION_31
|
||||
# define BOOST_FUNCTION_31
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 32
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 32
|
||||
# ifndef BOOST_FUNCTION_32
|
||||
# define BOOST_FUNCTION_32
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 33
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 33
|
||||
# ifndef BOOST_FUNCTION_33
|
||||
# define BOOST_FUNCTION_33
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 34
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 34
|
||||
# ifndef BOOST_FUNCTION_34
|
||||
# define BOOST_FUNCTION_34
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 35
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 35
|
||||
# ifndef BOOST_FUNCTION_35
|
||||
# define BOOST_FUNCTION_35
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 36
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 36
|
||||
# ifndef BOOST_FUNCTION_36
|
||||
# define BOOST_FUNCTION_36
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 37
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 37
|
||||
# ifndef BOOST_FUNCTION_37
|
||||
# define BOOST_FUNCTION_37
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 38
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 38
|
||||
# ifndef BOOST_FUNCTION_38
|
||||
# define BOOST_FUNCTION_38
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 39
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 39
|
||||
# ifndef BOOST_FUNCTION_39
|
||||
# define BOOST_FUNCTION_39
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 40
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 40
|
||||
# ifndef BOOST_FUNCTION_40
|
||||
# define BOOST_FUNCTION_40
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 41
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 41
|
||||
# ifndef BOOST_FUNCTION_41
|
||||
# define BOOST_FUNCTION_41
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 42
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 42
|
||||
# ifndef BOOST_FUNCTION_42
|
||||
# define BOOST_FUNCTION_42
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 43
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 43
|
||||
# ifndef BOOST_FUNCTION_43
|
||||
# define BOOST_FUNCTION_43
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 44
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 44
|
||||
# ifndef BOOST_FUNCTION_44
|
||||
# define BOOST_FUNCTION_44
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 45
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 45
|
||||
# ifndef BOOST_FUNCTION_45
|
||||
# define BOOST_FUNCTION_45
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 46
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 46
|
||||
# ifndef BOOST_FUNCTION_46
|
||||
# define BOOST_FUNCTION_46
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 47
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 47
|
||||
# ifndef BOOST_FUNCTION_47
|
||||
# define BOOST_FUNCTION_47
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 48
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 48
|
||||
# ifndef BOOST_FUNCTION_48
|
||||
# define BOOST_FUNCTION_48
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 49
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 49
|
||||
# ifndef BOOST_FUNCTION_49
|
||||
# define BOOST_FUNCTION_49
|
||||
# include <boost/function/function_template.hpp>
|
||||
# endif
|
||||
#elif BOOST_FUNCTION_NUM_ARGS == 50
|
||||
# undef BOOST_FUNCTION_MAX_ARGS_DEFINED
|
||||
# define BOOST_FUNCTION_MAX_ARGS_DEFINED 50
|
||||
# ifndef BOOST_FUNCTION_50
|
||||
# define BOOST_FUNCTION_50
|
||||
# include <boost/function/function_template.hpp>
|
||||
@ -265,3 +371,5 @@
|
||||
#else
|
||||
# error Cannot handle Boost.Function objects that accept more than 50 arguments!
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -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
|
||||
|
||||
@ -101,7 +101,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 +152,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 +328,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 +336,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 +377,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 +385,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 +396,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 +423,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 +431,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 +451,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 +468,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 +495,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 +506,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 +522,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 +549,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 +559,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 +570,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();
|
||||
@ -689,15 +694,22 @@ public: // should be protected, but GCC 2.95.3 will fail to allow access
|
||||
mutable detail::function::function_buffer functor;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CLANG)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#endif
|
||||
/**
|
||||
* 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") {}
|
||||
};
|
||||
#if defined(BOOST_CLANG)
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
inline bool operator==(const function_base& f,
|
||||
@ -730,28 +742,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
|
||||
|
@ -9,6 +9,7 @@
|
||||
#ifndef BOOST_FUNCTION_FWD_HPP
|
||||
#define BOOST_FUNCTION_FWD_HPP
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/function/detail/config.hpp>
|
||||
|
||||
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 && !defined(BOOST_STRICT_CONFIG)
|
||||
// Work around a compiler bug.
|
||||
@ -24,9 +25,22 @@ namespace boost { namespace python { namespace objects {
|
||||
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
|
||||
#endif
|
||||
|
||||
#if !BOOST_FUNCTION_ENABLE_CXX03
|
||||
# include <functional>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
#if BOOST_FUNCTION_ENABLE_CXX03
|
||||
|
||||
class bad_function_call;
|
||||
|
||||
#else
|
||||
|
||||
using std::bad_function_call;
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)
|
||||
// Preferred syntax
|
||||
template<typename Signature> class function;
|
||||
|
@ -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
|
||||
@ -895,7 +899,9 @@ namespace boost {
|
||||
if (!f.empty()) {
|
||||
this->vtable = f.vtable;
|
||||
if (this->has_trivial_copy_and_destroy())
|
||||
this->functor = f.functor;
|
||||
// Don't operate on storage directly since union type doesn't relax
|
||||
// strict aliasing rules, despite of having member char type.
|
||||
std::memcpy(this->functor.data, f.functor.data, sizeof(boost::detail::function::function_buffer));
|
||||
else
|
||||
get_vtable()->base.manager(f.functor, this->functor,
|
||||
boost::detail::function::clone_functor_tag);
|
||||
@ -944,9 +950,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;
|
||||
@ -983,7 +988,9 @@ namespace boost {
|
||||
if (!f.empty()) {
|
||||
this->vtable = f.vtable;
|
||||
if (this->has_trivial_copy_and_destroy())
|
||||
this->functor = f.functor;
|
||||
// Don't operate on storage directly since union type doesn't relax
|
||||
// strict aliasing rules, despite of having member char type.
|
||||
std::memcpy(this->functor.data, f.functor.data, sizeof(this->functor.data));
|
||||
else
|
||||
get_vtable()->base.manager(f.functor, this->functor,
|
||||
boost::detail::function::move_functor_tag);
|
||||
@ -1033,7 +1040,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 +1055,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 +1071,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 +1110,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
|
||||
|
@ -13,6 +13,6 @@
|
||||
"Programming"
|
||||
],
|
||||
"maintainers": [
|
||||
"Douglas Gregor <dgregor -at- cs.indiana.edu>"
|
||||
"Peter Dimov <pdimov -at- pdimov.com>"
|
||||
]
|
||||
}
|
||||
|
@ -7,67 +7,69 @@
|
||||
|
||||
# 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 ;
|
||||
|
||||
{
|
||||
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
|
||||
:
|
||||
[ run libs/function/test/function_test.cpp : : : : lib_function_test ]
|
||||
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 : : : <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 ;
|
||||
|
||||
[ 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 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 ]
|
||||
;
|
||||
}
|
||||
|
||||
run quick.cpp ;
|
||||
|
@ -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,21 @@ 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);
|
||||
#if BOOST_FUNCTION_ENABLE_CXX03
|
||||
BOOST_TEST_EQ( alloc_count, 1 );
|
||||
BOOST_TEST_EQ( dealloc_count, 1 );
|
||||
#endif
|
||||
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 +98,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 +108,16 @@ 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);
|
||||
#if BOOST_FUNCTION_ENABLE_CXX03
|
||||
BOOST_TEST_EQ( alloc_count, 1 );
|
||||
BOOST_TEST_EQ( dealloc_count, 1 );
|
||||
#endif
|
||||
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 +127,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 +136,5 @@ test_main(int, char*[])
|
||||
fv.assign(&do_nothing, std::allocator<int>() );
|
||||
fv2.assign(fv, std::allocator<int>() );
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
49
test/cmake_subdir_test/CMakeLists.txt
Normal file
49
test/cmake_subdir_test/CMakeLists.txt
Normal 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>)
|
@ -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()
|
||||
{
|
||||
|
@ -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
|
||||
@ -94,7 +96,7 @@ static void target_test()
|
||||
BOOST_CHECK(!f.target<int (*)()>());
|
||||
BOOST_CHECK(f.target<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<volatile 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();
|
||||
}
|
||||
|
35
test/function_30_repeat.cpp
Normal file
35
test/function_30_repeat.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
// Boost.Function library
|
||||
|
||||
// Copyright Douglas Gregor 2002-2003. 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)
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
// Make sure we don't try to redefine function2
|
||||
#include <boost/function/function2.hpp>
|
||||
|
||||
// Define all Boost.Function class templates up to 30 arguments
|
||||
#define BOOST_FUNCTION_MAX_ARGS 20
|
||||
#include <boost/function.hpp>
|
||||
#undef BOOST_FUNCTION_MAX_ARGS
|
||||
#define BOOST_FUNCTION_MAX_ARGS 40
|
||||
#include <boost/function.hpp>
|
||||
#undef BOOST_FUNCTION_MAX_ARGS
|
||||
#define BOOST_FUNCTION_MAX_ARGS 25
|
||||
#include <boost/function.hpp>
|
||||
#undef BOOST_FUNCTION_MAX_ARGS
|
||||
#define BOOST_FUNCTION_MAX_ARGS 30
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::function0<float> f0;
|
||||
|
||||
boost::function30<float, int, int, int, int, int, int, int, int, int, int,
|
||||
int, int, int, int, int, int, int, int, int, int,
|
||||
int, int, int, int, int, int, int, int, int, int> f30;
|
||||
return 0;
|
||||
}
|
@ -7,12 +7,14 @@
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#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 +633,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 +686,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 +695,5 @@ int test_main(int, char* [])
|
||||
test_member_functions();
|
||||
test_ref();
|
||||
test_construct_destroy_count();
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -7,12 +7,15 @@
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#define BOOST_CHECK BOOST_TEST
|
||||
|
||||
using boost::function;
|
||||
using std::string;
|
||||
|
||||
@ -624,11 +627,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 +654,20 @@ static void test_empty_ref()
|
||||
f2();
|
||||
BOOST_ERROR("Exception didn't throw for reference to empty function.");
|
||||
}
|
||||
catch(std::runtime_error e) {}
|
||||
catch(boost::bad_function_call const&) {}
|
||||
|
||||
f1 = dummy;
|
||||
|
||||
try {
|
||||
f2();
|
||||
}
|
||||
catch(std::runtime_error e) {
|
||||
catch(boost::bad_function_call const&) {
|
||||
BOOST_ERROR("Error calling referenced function.");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void test_exception()
|
||||
{
|
||||
@ -660,7 +676,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 +795,7 @@ static void test_move_semantics()
|
||||
#endif
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
int main()
|
||||
{
|
||||
test_zero_args();
|
||||
test_one_arg();
|
||||
@ -794,5 +810,5 @@ int test_main(int, char* [])
|
||||
test_move_semantics<function<void()> >();
|
||||
test_move_semantics<boost::function0<void> >();
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -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 ) {}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
|
||||
|
42
test/mixed_cxxstd.cpp
Normal file
42
test/mixed_cxxstd.cpp
Normal 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 );
|
||||
}
|
@ -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
21
test/quick.cpp
Normal 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
27
test/return_function.cpp
Normal 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;
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -20,11 +20,12 @@ int X::foo(int x) { return -x; }
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef BOOST_NO_CXX98_BINDERS
|
||||
boost::function<int (int)> f;
|
||||
X x;
|
||||
f = std::bind1st(
|
||||
std::mem_fun(&X::foo), &x);
|
||||
f(5); // Call x.foo(5)
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,11 +20,12 @@ int X::foo(int x) { return -x; }
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef BOOST_NO_CXX98_BINDERS
|
||||
boost::function1<int, int> f;
|
||||
X x;
|
||||
f = std::bind1st(
|
||||
std::mem_fun(&X::foo), &x);
|
||||
f(5); // Call x.foo(5)
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
14
test/test_bad_function_call.cpp
Normal file
14
test/test_bad_function_call.cpp
Normal 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();
|
||||
}
|
48
test/test_mixed_cxxstd.cpp
Normal file
48
test/test_mixed_cxxstd.cpp
Normal 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();
|
||||
}
|
21
test/test_return_function.cpp
Normal file
21
test/test_return_function.cpp
Normal 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();
|
||||
}
|
17
test/throw_bad_function_call.cpp
Normal file
17
test/throw_bad_function_call.cpp
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user