mirror of
https://github.com/boostorg/function.git
synced 2026-01-29 07:32:15 +00:00
Compare commits
11 Commits
feature/fu
...
boost-1.69
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f46081c59 | ||
|
|
17716b63f2 | ||
|
|
b6b0568c88 | ||
|
|
babdbe500d | ||
|
|
db39532c45 | ||
|
|
eb09bb6fec | ||
|
|
ccc66b34d9 | ||
|
|
e7952cb242 | ||
|
|
57f4171c77 | ||
|
|
30f31f894c | ||
|
|
bfb0e4701e |
11
Jamfile
11
Jamfile
@@ -1,11 +0,0 @@
|
|||||||
# Boost.Function Library Jamfile
|
|
||||||
#
|
|
||||||
# Copyright (c) 2018 James E. King III
|
|
||||||
#
|
|
||||||
# Use, modification, and distribution are subject to the
|
|
||||||
# Boost Software License, Version 1.0. (See accompanying file
|
|
||||||
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
# please order by name to ease maintenance
|
|
||||||
build-project example ;
|
|
||||||
build-project test ;
|
|
||||||
23
LICENSE
23
LICENSE
@@ -1,23 +0,0 @@
|
|||||||
Boost Software License - Version 1.0 - August 17th, 2003
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person or organization
|
|
||||||
obtaining a copy of the software and accompanying documentation covered by
|
|
||||||
this license (the "Software") to use, reproduce, display, distribute,
|
|
||||||
execute, and transmit the Software, and to prepare derivative works of the
|
|
||||||
Software, and to permit third-parties to whom the Software is furnished to
|
|
||||||
do so, all subject to the following:
|
|
||||||
|
|
||||||
The copyright notices in the Software and this entire statement, including
|
|
||||||
the above license grant, this restriction and the following disclaimer,
|
|
||||||
must be included in all copies of the Software, in whole or in part, and
|
|
||||||
all derivative works of the Software, unless such copies or derivative
|
|
||||||
works are solely in the form of machine-executable object code generated by
|
|
||||||
a source language processor.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
||||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
||||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
DEALINGS IN THE SOFTWARE.
|
|
||||||
40
README.md
40
README.md
@@ -1,34 +1,18 @@
|
|||||||
Function, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), contains a family of class templates that are function object wrappers.
|
# Boost.Function, a polymorphic function wrapper
|
||||||
|
|
||||||
### License
|
[Boost.Function](http://boost.org/libs/function), part of the
|
||||||
|
[Boost C++ Libraries](http://boost.org), is the original implementation of the
|
||||||
|
polymorphic function wrapper `boost::function`, which was eventually accepted
|
||||||
|
into the C++11 standard as [`std::function`](https://en.cppreference.com/w/cpp/utility/functional/function).
|
||||||
|
|
||||||
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
## Currently supported compilers
|
||||||
|
|
||||||
### Properties
|
* g++ 4.4 or later
|
||||||
|
* clang++ 3.3 or later
|
||||||
|
* Visual Studio 2005-2017
|
||||||
|
|
||||||
* C++03
|
Tested on [Travis](https://travis-ci.org/boostorg/function/) and [Appveyor](https://ci.appveyor.com/project/pdimov/function/).
|
||||||
* Header-Only
|
|
||||||
|
|
||||||
### Build Status
|
## License
|
||||||
|
|
||||||
Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
|
|
||||||
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
|
|
||||||
[`master`](https://github.com/boostorg/function/tree/master) | [](https://travis-ci.org/boostorg/function) | [](https://ci.appveyor.com/project/jeking3/function-d036y/branch/master) | [](https://scan.coverity.com/projects/boostorg-function) | [](https://codecov.io/gh/boostorg/function/branch/master)| [](https://pdimov.github.io/boostdep-report/master/function.html) | [](http://www.boost.org/doc/libs/master/doc/html/function.html) | [](http://www.boost.org/development/tests/master/developer/function.html)
|
|
||||||
[`develop`](https://github.com/boostorg/function/tree/develop) | [](https://travis-ci.org/boostorg/function) | [](https://ci.appveyor.com/project/jeking3/function-d036y/branch/develop) | [](https://scan.coverity.com/projects/boostorg-function) | [](https://codecov.io/gh/boostorg/function/branch/develop) | [](https://pdimov.github.io/boostdep-report/develop/function.html) | [](http://www.boost.org/doc/libs/develop/doc/html/function.html) | [](http://www.boost.org/development/tests/develop/developer/function.html)
|
|
||||||
|
|
||||||
### Directories
|
|
||||||
|
|
||||||
| Name | Purpose |
|
|
||||||
| ----------- | ------------------------------ |
|
|
||||||
| `doc` | documentation |
|
|
||||||
| `example` | examples |
|
|
||||||
| `include` | headers |
|
|
||||||
| `test` | unit tests |
|
|
||||||
|
|
||||||
### More information
|
|
||||||
|
|
||||||
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-function)
|
|
||||||
* [Report bugs](https://github.com/boostorg/function/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
|
|
||||||
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
|
||||||
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[function]` tag at the beginning of the subject line.
|
|
||||||
|
|
||||||
|
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
|
||||||
|
|||||||
139
appveyor.yml
139
appveyor.yml
@@ -1,126 +1,63 @@
|
|||||||
# Copyright 2016, 2017 Peter Dimov
|
# Copyright 2016-2018 Peter Dimov
|
||||||
# Copyright (C) 2017, 2018 James E. King III
|
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#
|
|
||||||
# Generic Appveyor build script for boostorg repositories
|
|
||||||
# See: https://github.com/jeking3/boost-ci/
|
|
||||||
#
|
|
||||||
# Instructions for customizing this script for your library:
|
|
||||||
#
|
|
||||||
# 1. Customize the compilers and language levels you want.
|
|
||||||
# 2. If you have move than include/, src/, test/, example/, examples/,
|
|
||||||
# benchmark/ or tools/ directories, set the environment variable DEPINST.
|
|
||||||
# For example if your build uses code in "bench/" and "fog/" directories:
|
|
||||||
# - DEPINST: --include bench --include fog
|
|
||||||
# 3. Enable pull request builds in your boostorg/<library> account.
|
|
||||||
#
|
|
||||||
# That's it - the script will do everything else for you.
|
|
||||||
#
|
|
||||||
|
|
||||||
version: 1.0.{build}-{branch}
|
version: 1.0.{build}-{branch}
|
||||||
|
|
||||||
shallow_clone: true
|
shallow_clone: true
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- develop
|
|
||||||
- master
|
- master
|
||||||
|
- develop
|
||||||
matrix:
|
- /feature\/.*/
|
||||||
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
|
|
||||||
allow_failures:
|
|
||||||
- MAYFAIL: true
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
global:
|
|
||||||
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
|
||||||
# to use the default for a given environment, comment it out; recommend you build debug and release however:
|
|
||||||
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
|
|
||||||
# libraries that care about this exercise it in their Jamfiles...
|
|
||||||
# B2_ADDRESS_MODEL: address-model=64,32
|
|
||||||
# B2_LINK: link=shared,static
|
|
||||||
# B2_THREADING: threading=multi,single
|
|
||||||
B2_VARIANT: variant=release,debug
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
- FLAVOR: Visual Studio 2017 C++2a Strict
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||||
TOOLSET: msvc-14.1
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
B2_ADDRESS_MODEL: address-model=64
|
|
||||||
CXXFLAGS: cxxflags=-permissive-
|
|
||||||
CXXSTD: latest # 2a
|
|
||||||
|
|
||||||
- FLAVOR: Visual Studio 2017 C++17
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
TOOLSET: msvc-14.1
|
|
||||||
B2_ADDRESS_MODEL: address-model=64
|
|
||||||
CXXSTD: 17
|
|
||||||
|
|
||||||
- FLAVOR: Visual Studio 2017 C++14 (Default)
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
TOOLSET: msvc-14.1
|
|
||||||
B2_ADDRESS_MODEL: address-model=64,32
|
|
||||||
|
|
||||||
- FLAVOR: Visual Studio 2015 C++14 (Default)
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
|
||||||
TOOLSET: msvc-14.0
|
TOOLSET: msvc-14.0
|
||||||
B2_ADDRESS_MODEL: address-model=64,32
|
ADDRMD: 32,64
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
- FLAVOR: Visual Studio 2010, 2012, 2013
|
TOOLSET: msvc-14.1
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
CXXSTD: 14,17
|
||||||
TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
|
ADDRMD: 32,64
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||||
- FLAVOR: cygwin (32-bit)
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
ADDPATH: C:\cygwin\bin;
|
ADDPATH: C:\cygwin\bin;
|
||||||
B2_ADDRESS_MODEL: address-model=32
|
|
||||||
CXXSTD: 03,11
|
|
||||||
# https://github.com/boostorg/test/issues/144
|
|
||||||
DEFINES: define=_POSIX_C_SOURCE=200112L
|
|
||||||
THREADING: threadapi=pthread
|
|
||||||
TOOLSET: gcc
|
TOOLSET: gcc
|
||||||
|
CXXSTD: 03,11,14,1z
|
||||||
- FLAVOR: cygwin (64-bit)
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
ADDPATH: C:\cygwin64\bin;
|
ADDPATH: C:\cygwin64\bin;
|
||||||
B2_ADDRESS_MODEL: address-model=64
|
|
||||||
CXXSTD: 11,17
|
|
||||||
# https://github.com/boostorg/test/issues/144
|
|
||||||
DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
|
|
||||||
THREADING: threadapi=pthread
|
|
||||||
TOOLSET: gcc
|
TOOLSET: gcc
|
||||||
|
CXXSTD: 03,11,14,1z
|
||||||
- FLAVOR: mingw32
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
ADDPATH: C:\mingw\bin;
|
||||||
ARCH: i686
|
TOOLSET: gcc
|
||||||
B2_ADDRESS_MODEL: address-model=32
|
CXXSTD: 03,11,14,1z
|
||||||
CXXSTD: 03,11
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||||
SCRIPT: ci\appveyor\mingw.bat
|
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||||
|
TOOLSET: gcc
|
||||||
- FLAVOR: mingw64
|
CXXSTD: 03,11,14,1z
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
ARCH: x86_64
|
|
||||||
B2_ADDRESS_MODEL: address-model=64
|
|
||||||
CXXSTD: 11,17
|
|
||||||
DEFINES: define=__USE_ISOC99
|
|
||||||
SCRIPT: ci\appveyor\mingw.bat
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
- set BOOST_BRANCH=develop
|
||||||
- git clone https://github.com/jeking3/boost-ci.git C:\boost-ci
|
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||||
- xcopy /s /e /q /i C:\boost-ci\ci .\ci
|
- cd ..
|
||||||
- ci\appveyor\install.bat
|
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
- cd boost-root
|
||||||
|
- git submodule update --init tools/build
|
||||||
|
- git submodule update --init libs/config
|
||||||
|
- git submodule update --init tools/boostdep
|
||||||
|
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\function
|
||||||
|
- python tools/boostdep/depinst/depinst.py function
|
||||||
|
- cmd /c bootstrap
|
||||||
|
- b2 -d0 headers
|
||||||
|
|
||||||
build: off
|
build: off
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
|
|
||||||
- PATH=%ADDPATH%%PATH%
|
- PATH=%ADDPATH%%PATH%
|
||||||
# The definition of TOOLCXX omits CXXSTD= if it was not defined above
|
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||||
- IF NOT DEFINED CXXSTD (SET TOOLCXX=toolset=%TOOLSET%) ELSE (SET TOOLCXX=toolset=%TOOLSET% cxxstd=%CXXSTD%)
|
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||||
# Echo the complete build command to the build log
|
- b2 -j3 libs/function/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||||
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %TOOLCXX% %CXXFLAGS% %DEFINES% %THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
|
||||||
# Now go build...
|
|
||||||
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %TOOLCXX% %CXXFLAGS% %DEFINES% %THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
|
|
||||||
|
|||||||
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 ;
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# Boost.Function Library example Jamfile
|
|
||||||
#
|
|
||||||
# Copyright (c) 2008 James E. King III
|
|
||||||
#
|
|
||||||
# Distributed under the Boost Software License, Version 1.0. (See accompany-
|
|
||||||
# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
import ../../config/checks/config : requires ;
|
|
||||||
import os ;
|
|
||||||
import testing ;
|
|
||||||
|
|
||||||
project
|
|
||||||
: requirements
|
|
||||||
;
|
|
||||||
|
|
||||||
test-suite "function-examples"
|
|
||||||
: [ run bind1st.cpp : : : [ requires cxx98_binders ] ]
|
|
||||||
[ run int_div.cpp ]
|
|
||||||
[ run sum_avg.cpp ]
|
|
||||||
;
|
|
||||||
|
|
||||||
@@ -13,6 +13,6 @@
|
|||||||
"Programming"
|
"Programming"
|
||||||
],
|
],
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
"Douglas Gregor <dgregor -at- cs.indiana.edu>"
|
"Peter Dimov <pdimov -at- pdimov.com>"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,3 +57,17 @@ local check14 = [ check-target-builds mixed_cxxstd/<cxxstd>14 : : <build>no ] ;
|
|||||||
|
|
||||||
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>shared $(check14) : mixed_cxxstd_shared_14 ;
|
||||||
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>14 : : : <link>static $(check14) : mixed_cxxstd_static_14 ;
|
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>14 : : : <link>static $(check14) : mixed_cxxstd_static_14 ;
|
||||||
|
|
||||||
|
lib return_function : return_function.cpp : <link>shared:<define>RETURN_FUNCTION_DYN_LINK=1 ;
|
||||||
|
|
||||||
|
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>0x : : : <link>shared : return_function_shared_0x ;
|
||||||
|
run test_return_function.cpp return_function/<cxxstd>0x : : : <link>static : return_function_static_0x ;
|
||||||
|
|
||||||
|
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 ;
|
||||||
|
|||||||
@@ -5,10 +5,12 @@
|
|||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/test/minimal.hpp>
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
|
|
||||||
|
#define BOOST_CHECK BOOST_TEST
|
||||||
|
|
||||||
static int forty_two() { return 42; }
|
static int forty_two() { return 42; }
|
||||||
|
|
||||||
struct Seventeen
|
struct Seventeen
|
||||||
@@ -225,11 +227,11 @@ static void ref_equal_test()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_main(int, char*[])
|
int main()
|
||||||
{
|
{
|
||||||
target_test();
|
target_test();
|
||||||
equal_test();
|
equal_test();
|
||||||
ref_equal_test();
|
ref_equal_test();
|
||||||
|
|
||||||
return 0;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
#include <boost/test/minimal.hpp>
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#define BOOST_CHECK BOOST_TEST
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::negate;
|
using std::negate;
|
||||||
@@ -684,7 +686,7 @@ void test_construct_destroy_count()
|
|||||||
BOOST_CHECK(construction_count == destruction_count);
|
BOOST_CHECK(construction_count == destruction_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_main(int, char* [])
|
int main()
|
||||||
{
|
{
|
||||||
test_zero_args();
|
test_zero_args();
|
||||||
test_one_arg();
|
test_one_arg();
|
||||||
@@ -693,5 +695,5 @@ int test_main(int, char* [])
|
|||||||
test_member_functions();
|
test_member_functions();
|
||||||
test_ref();
|
test_ref();
|
||||||
test_construct_destroy_count();
|
test_construct_destroy_count();
|
||||||
return 0;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
#include <boost/test/minimal.hpp>
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#define BOOST_CHECK BOOST_TEST
|
||||||
|
|
||||||
using boost::function;
|
using boost::function;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
@@ -792,7 +794,7 @@ static void test_move_semantics()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_main(int, char* [])
|
int main()
|
||||||
{
|
{
|
||||||
test_zero_args();
|
test_zero_args();
|
||||||
test_one_arg();
|
test_one_arg();
|
||||||
@@ -807,5 +809,5 @@ int test_main(int, char* [])
|
|||||||
test_move_semantics<function<void()> >();
|
test_move_semantics<function<void()> >();
|
||||||
test_move_semantics<boost::function0<void> >();
|
test_move_semantics<boost::function0<void> >();
|
||||||
|
|
||||||
return 0;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,22 +7,12 @@
|
|||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
#include <boost/test/minimal.hpp>
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
using namespace std;
|
void test()
|
||||||
using namespace boost;
|
|
||||||
|
|
||||||
int
|
|
||||||
test_main(int, char*[])
|
|
||||||
{
|
{
|
||||||
function0<int> f1;
|
boost::function0<int> f1;
|
||||||
function0<int> f2;
|
boost::function0<int> f2;
|
||||||
|
|
||||||
if (f1 == f2) {
|
if( f1 == f2 ) {}
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_ERROR("This should not have compiled.");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,21 +7,12 @@
|
|||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
#include <boost/test/minimal.hpp>
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace boost;
|
|
||||||
|
|
||||||
static int bad_fn(float f) { return static_cast<int>(f); }
|
static int bad_fn(float f) { return static_cast<int>(f); }
|
||||||
|
|
||||||
int
|
void test()
|
||||||
test_main(int, char*[])
|
|
||||||
{
|
{
|
||||||
function0<int> f1;
|
boost::function0<int> f1;
|
||||||
f1 = bad_fn;
|
f1 = bad_fn;
|
||||||
|
|
||||||
BOOST_ERROR("This should not have compiled.");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
// For more information, see http://www.boost.org
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
#include <boost/test/minimal.hpp>
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
#define BOOST_CHECK BOOST_TEST
|
||||||
|
|
||||||
struct tried_to_copy { };
|
struct tried_to_copy { };
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ struct MaybeThrowOnCopy {
|
|||||||
|
|
||||||
bool MaybeThrowOnCopy::throwOnCopy = false;
|
bool MaybeThrowOnCopy::throwOnCopy = false;
|
||||||
|
|
||||||
int test_main(int, char* [])
|
int main()
|
||||||
{
|
{
|
||||||
boost::function0<int> f;
|
boost::function0<int> f;
|
||||||
boost::function0<int> g;
|
boost::function0<int> g;
|
||||||
@@ -56,5 +58,5 @@ int test_main(int, char* [])
|
|||||||
BOOST_CHECK(f() == 2);
|
BOOST_CHECK(f() == 2);
|
||||||
BOOST_CHECK(g() == 1);
|
BOOST_CHECK(g() == 1);
|
||||||
|
|
||||||
return 0;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
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
|
// For more information, see http://www.boost.org
|
||||||
|
|
||||||
|
#include <boost/function.hpp>
|
||||||
|
#include <boost/move/move.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <boost/test/minimal.hpp>
|
#define BOOST_CHECK BOOST_TEST
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <boost/move/move.hpp>
|
|
||||||
|
|
||||||
class only_movable {
|
class only_movable {
|
||||||
private:
|
private:
|
||||||
@@ -63,7 +64,7 @@ int three(std::string&&) { return 1; }
|
|||||||
std::string&& four(std::string&& s) { return boost::move(s); }
|
std::string&& four(std::string&& s) { return boost::move(s); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int test_main(int, char*[])
|
int main()
|
||||||
{
|
{
|
||||||
using boost::function;
|
using boost::function;
|
||||||
|
|
||||||
@@ -102,5 +103,5 @@ int test_main(int, char*[])
|
|||||||
BOOST_CHECK(f4(std::string("world")) == "world");
|
BOOST_CHECK(f4(std::string("world")) == "world");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user