Compare commits

..

3 Commits

Author SHA1 Message Date
cd79ba8c8b Remove C++03 from Travis and Appveyor 2019-11-06 03:12:56 +02:00
f3e4ed2481 Use std::function 2019-11-06 03:10:09 +02:00
a7c28f6117 Remove tests that require C++03 to pass 2019-11-06 03:09:54 +02:00
15 changed files with 487 additions and 383 deletions

View File

@ -1,208 +0,0 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.7
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.7
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.8
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.9
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
install: g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
- toolset: clang
compiler: clang++-3.5
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2019
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release

View File

@ -4,7 +4,9 @@
language: cpp
dist: xenial
sudo: false
dist: trusty
branches:
only:
@ -22,9 +24,13 @@ matrix:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc CXXSTD=11
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc CXXSTD=98,0x
env: TOOLSET=gcc CXXSTD=0x
addons:
apt:
packages:
@ -34,7 +40,7 @@ matrix:
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc CXXSTD=03,0x
env: TOOLSET=gcc CXXSTD=0x
addons:
apt:
packages:
@ -44,7 +50,7 @@ matrix:
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc CXXSTD=03,11
env: TOOLSET=gcc CXXSTD=11
addons:
apt:
packages:
@ -54,7 +60,7 @@ matrix:
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc CXXSTD=03,11
env: TOOLSET=gcc CXXSTD=11
addons:
apt:
packages:
@ -63,7 +69,7 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc CXXSTD=03,11
env: TOOLSET=gcc CXXSTD=11
addons:
apt:
packages:
@ -73,7 +79,7 @@ matrix:
- os: linux
compiler: g++-5
env: TOOLSET=gcc CXXSTD=03,11,14,1z
env: TOOLSET=gcc CXXSTD=11,14,1z
addons:
apt:
packages:
@ -83,7 +89,7 @@ matrix:
- os: linux
compiler: g++-6
env: TOOLSET=gcc CXXSTD=03,11,14,1z
env: TOOLSET=gcc CXXSTD=11,14,1z
addons:
apt:
packages:
@ -93,7 +99,7 @@ matrix:
- os: linux
compiler: g++-7
env: TOOLSET=gcc CXXSTD=03,11,14,17
env: TOOLSET=gcc CXXSTD=11,14,17
addons:
apt:
packages:
@ -103,7 +109,7 @@ matrix:
- os: linux
compiler: g++-8
env: TOOLSET=gcc CXXSTD=03,11,14,17,2a
env: TOOLSET=gcc CXXSTD=11,14,17,2a
addons:
apt:
packages:
@ -113,7 +119,7 @@ matrix:
- os: linux
compiler: g++-9
env: TOOLSET=gcc CXXSTD=03,11,14,17,2a
env: TOOLSET=gcc CXXSTD=11,14,17,2a
addons:
apt:
packages:
@ -122,29 +128,30 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
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++-10
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: clang++
env: TOOLSET=clang CXXSTD=11
- os: linux
compiler: /usr/bin/clang++
env: TOOLSET=clang CXXSTD=03,11
env: TOOLSET=clang CXXSTD=11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang CXXSTD=03,11
env: TOOLSET=clang CXXSTD=11
addons:
apt:
packages:
@ -152,171 +159,139 @@ matrix:
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang CXXSTD=03,11,14,1z
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=03,11,14,1z
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=03,11,14,1z
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=03,11,14,1z
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=03,11,14,1z
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=03,11,14,1z
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=03,11,14,1z
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=03,11,14,17,2a
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=03,11,14,17,2a
env: TOOLSET=clang CXXSTD=11,14,17,2a
addons:
apt:
packages:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
- llvm-toolchain-trusty-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
env: TOOLSET=clang CXXSTD=11,14,17,2a
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- llvm-toolchain-trusty-8
- os: linux
dist: bionic
compiler: clang++-9
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
compiler: clang++-8
env: UBSAN=1 TOOLSET=clang CXXSTD=11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-9
- clang-8
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- llvm-toolchain-trusty-8
- os: linux
dist: bionic
compiler: clang++-10
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-10
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-11
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-11
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-12
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-12
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: trusty
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
env: TOOLSET=clang CXXSTD=11,14,1z
addons:
apt:
packages:
- libc++-dev
- os: linux
dist: bionic
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
env: UBSAN=1 TOOLSET=clang CXXSTD=11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
@ -324,22 +299,7 @@ matrix:
- os: osx
compiler: clang++
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
env: CMAKE_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=function ..
- ctest --output-on-failure -R boost_function
- os: linux
env: CMAKE_SUBDIR_TEST=1
script:
- cd libs/function/test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
env: TOOLSET=clang CXXSTD=11,14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true

View File

@ -1,11 +1,12 @@
# Generated by `boostdep --cmake function`
# Copyright 2020 Peter Dimov
# Copyright 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet
project(boost_function VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
cmake_minimum_required(VERSION 3.5)
project(BoostFunction LANGUAGES CXX)
add_library(boost_function INTERFACE)
add_library(Boost::function ALIAS boost_function)
@ -13,22 +14,15 @@ 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
INTERFACE
Boost::assert
Boost::bind
Boost::config
Boost::core
Boost::integer
Boost::preprocessor
Boost::throw_exception
Boost::type_index
Boost::type_traits
Boost::typeof
)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@ -16,7 +16,6 @@ environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
@ -24,30 +23,22 @@ environment:
TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
CXXSTD: 14,17
ADDRMD: 64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 14,17,latest
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
CXXSTD: 11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
CXXSTD: 11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
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: 03,11,14,1z
CXXSTD: 11,14,1z
install:
- set BOOST_BRANCH=develop

View File

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

View File

@ -0,0 +1,12 @@
// Copyright 2019 Peter Dimov
// Use, modification and distribution is subject to the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_FUNCTION_DETAIL_CONFIG_HPP_INCLUDED
#define BOOST_FUNCTION_DETAIL_CONFIG_HPP_INCLUDED
#if !defined(BOOST_FUNCTION_ENABLE_CXX03)
# define BOOST_FUNCTION_ENABLE_CXX03 0
#endif
#endif // #ifndef BOOST_FUNCTION_DETAIL_CONFIG_HPP_INCLUDED

View File

@ -7,6 +7,10 @@
// For more information, see http://www.boost.org
#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
@ -367,3 +371,5 @@
#else
# error Cannot handle Boost.Function objects that accept more than 50 arguments!
#endif
#endif

View File

@ -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;

View File

@ -898,20 +898,11 @@ namespace boost {
{
if (!f.empty()) {
this->vtable = f.vtable;
if (this->has_trivial_copy_and_destroy()) {
if (this->has_trivial_copy_and_destroy())
// Don't operate on storage directly since union type doesn't relax
// strict aliasing rules, despite of having member char type.
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic push
// This warning is technically correct, but we don't want to pay the price for initializing
// just to silence a warning: https://github.com/boostorg/function/issues/27
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# endif
std::memcpy(this->functor.data, f.functor.data, sizeof(boost::detail::function::function_buffer));
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic pop
# endif
} else
else
get_vtable()->base.manager(f.functor, this->functor,
boost::detail::function::clone_functor_tag);
}
@ -996,20 +987,11 @@ namespace boost {
BOOST_TRY {
if (!f.empty()) {
this->vtable = f.vtable;
if (this->has_trivial_copy_and_destroy()) {
if (this->has_trivial_copy_and_destroy())
// Don't operate on storage directly since union type doesn't relax
// strict aliasing rules, despite of having member char type.
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic push
// This warning is technically correct, but we don't want to pay the price for initializing
// just to silence a warning: https://github.com/boostorg/function/issues/27
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# endif
std::memcpy(this->functor.data, f.functor.data, sizeof(this->functor.data));
# if defined(BOOST_GCC) && (BOOST_GCC >= 40700)
# pragma GCC diagnostic pop
# endif
} else
else
get_vtable()->base.manager(f.functor, this->functor,
boost::detail::function::move_functor_tag);
f.vtable = 0;

View File

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

View File

@ -1,11 +0,0 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::function Boost::core Boost::lambda)
endif()

View File

@ -47,8 +47,8 @@ lib mixed_cxxstd : mixed_cxxstd.cpp : <link>shared:<define>MIXED_CXXSTD_DYN_LINK
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 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 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 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 ;
@ -63,8 +63,8 @@ lib return_function : return_function.cpp : <link>shared:<define>RETURN_FUNCTION
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 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 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 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 ;

View File

@ -79,8 +79,10 @@ int main()
function2<int, int, int> f;
f.assign( plus_int<disable_small_object_optimization>(), counting_allocator<int>() );
f.clear();
#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>() );
@ -106,8 +108,10 @@ int main()
dealloc_count = 0;
fv.assign( DoNothing<disable_small_object_optimization>(), counting_allocator<int>() );
fv.clear();
#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>() );

View File

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

View File

@ -9,6 +9,7 @@
#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/workaround.hpp>
#include <functional>
#include <string>
#include <utility>
@ -653,14 +654,14 @@ static void test_empty_ref()
f2();
BOOST_ERROR("Exception didn't throw for reference to empty function.");
}
catch(std::runtime_error const&) {}
catch(boost::bad_function_call const&) {}
f1 = dummy;
try {
f2();
}
catch(std::runtime_error const&) {
catch(boost::bad_function_call const&) {
BOOST_ERROR("Error calling referenced function.");
}
}