Compare commits

...

10 Commits

Author SHA1 Message Date
Andrey Semashev
6538609cf5 Trim trailing spaces. 2023-06-05 16:06:33 +03:00
Andrey Semashev
02e1c566f7 Copy boost::timer to tests since the original is deprecated and giving errors.
We're not using Boost.Timer v2 components to avoid linking tests with its
separately compiled binary. The legacy boost::timer is fine for the test
purposes.
2023-06-05 16:03:18 +03:00
Andrey Semashev
b35192723c Add clang-16 CI jobs, switch to clang-15 from stock Ubuntu repos. 2023-06-05 03:21:51 +03:00
Andrey Semashev
e1f75be395 Updated to GHA checkout@v3 to avoid deprecation warnings. 2022-10-18 17:58:37 +03:00
Andrey Semashev
fae4c2dacc GitHub Actions config update.
- Added gcc-12 and clang-13 through 15 jobs.
- Added C++23 testing for gcc and clang on Linux.
- Updated clang version for UBSAN job.
- Updated Ubuntu version for clang jobs to avoid having to use external APT
  repository.
- Updated python package installation for compatibility with Ubuntu 22.04.
2022-09-10 01:45:30 +03:00
Andrey Semashev
665cdbc94c Switched gcc-9 to ubuntu-20.04 GHA CI image. 2022-08-14 17:55:06 +03:00
Andrey Semashev
df9ea43b66 Replaced ubuntu-18.04 GHA CI images with containers.
Also use ubuntu-latest image for jobs that are running in a container.
2022-08-14 14:12:49 +03:00
Andrey Semashev
0376be4112 Switch to macos-11 GHA image as macos-10.15 is deprecated. 2022-08-12 16:02:38 +03:00
Andrey Semashev
c82f2ec688 Added VS2022 and clang-win jobs and C++20 and C++latest jobs to AppVeyor CI. 2022-06-06 03:04:12 +03:00
Andrey Semashev
9780d8338f Removed Python tests.
All Python-related functionality, including tests, were moved to a separate
parameter_python submodule.
2021-12-08 18:27:27 +03:00
20 changed files with 192 additions and 368 deletions

View File

@@ -1,4 +1,4 @@
# Copyright 2021 Andrey Semashev
# Copyright 2021-2022 Andrey Semashev
#
# 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)
@@ -35,7 +35,7 @@ jobs:
# Linux, gcc
- toolset: gcc-4.4
cxxstd: "98,0x"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.4
@@ -43,7 +43,7 @@ jobs:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.6
cxxstd: "03,0x"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.6
@@ -51,45 +51,49 @@ jobs:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.7
cxxstd: "03,11"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.7
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
os: ubuntu-20.04
install:
- g++-9
- toolset: gcc-10
@@ -98,87 +102,94 @@ jobs:
install:
- g++-10
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
cxxstd: "03,11,14,17,20,23"
os: ubuntu-22.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-12
cxxstd: "03,11,14,17,20,23"
os: ubuntu-22.04
install:
- g++-12
- name: UBSAN
toolset: gcc-11
cxxstd: "03,11,14,17,20"
cxxstd: "03,11,14,17,20,23"
ubsan: 1
build_variant: debug
os: ubuntu-20.04
os: ubuntu-22.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
# Linux, clang
- toolset: clang
compiler: clang++-3.5
cxxstd: "03,11"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "03,11,14"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "03,11,14"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "03,11,14"
os: ubuntu-20.04
os: ubuntu-latest
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-7
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
os: ubuntu-latest
container: ubuntu:18.04
install:
- clang-8
- g++-7
@@ -198,42 +209,74 @@ jobs:
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
os: ubuntu-22.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-12
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
compiler: clang++-13
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
- clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-16
sources:
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
source_keys:
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install:
- clang-16
- libc++-16-dev
- libc++abi-16-dev
sources:
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
source_keys:
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
- name: UBSAN
toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
compiler: clang++-15
cxxstd: "03,11,14,17,20,2b"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
ubsan: 1
build_variant: debug
os: ubuntu-20.04
os: ubuntu-22.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
- clang-15
- libc++-15-dev
- libc++abi-15-dev
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
os: macos-11
timeout-minutes: 60
runs-on: ${{matrix.os}}
@@ -253,12 +296,18 @@ jobs:
if [ -f "/etc/debian_version" ]
then
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ python python3 libpython-dev libpython3-dev perl git cmake
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
then
PYTHON_PACKAGE="python-is-python3"
else
PYTHON_PACKAGE="python"
fi
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake
fi
fi
git config --global pack.threads 0
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install packages
if: matrix.install

View File

@@ -1,6 +1,6 @@
# Copyright 2017 Edward Diener
# Copyright 2017 Cromwell D. Enage
# Copyright 2021 Andrey Semashev
# Copyright 2021-2022 Andrey Semashev
# 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)
@@ -23,17 +23,17 @@ environment:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- ARGS: toolset=msvc-14.1 address-model=32,64 cxxstd=14,17,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- ARGS: toolset=msvc-14.2 address-model=32,64 cxxstd=14,17,latest
- ARGS: toolset=msvc-14.2 address-model=32,64 cxxstd=14,17,20,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- ARGS: toolset=msvc-14.3 address-model=32,64 cxxstd=14,17,20,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
- ARGS: toolset=clang-win address-model=32,64 cxxstd=14,17,latest
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- ARGS: toolset=gcc address-model=32 cxxstd=03,11,14,1z
PATH: C:\cygwin\bin;%PATH%
# Cygwin does not have python headers installed, the compiler picks up Win32 headers in C:\Python27\Include and fails
BOOST_PARAMETER_TEST_WITHOUT_PYTHON_TESTS: 1
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- ARGS: toolset=gcc address-model=64 cxxstd=03,11,14,1z
PATH: C:\cygwin64\bin;%PATH%
# Cygwin64 does not have python headers installed, the compiler picks up Win32 headers in C:\Python27\Include and fails
BOOST_PARAMETER_TEST_WITHOUT_PYTHON_TESTS: 1
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- ARGS: toolset=gcc address-model=32 cxxstd=03,11 linkflags=-Wl,-allow-multiple-definition
PATH: C:\MinGW\bin;%PATH%
@@ -60,12 +60,11 @@ install:
- git submodule init tools/boost_install
- git submodule init libs/headers
- git submodule init libs/config
- git submodule init libs/parameter_python
- git submodule update --jobs %GIT_FETCH_JOBS%
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\parameter
- python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" parameter
- cmd /c bootstrap
- b2 headers
- b2 -d0 headers
build: off

View File

@@ -10,7 +10,7 @@
#include <boost/parameter/aux_/tagged_argument.hpp>
#include <boost/parameter/config.hpp>
namespace boost { namespace parameter { namespace aux {
namespace boost { namespace parameter { namespace aux {
template <
typename Keyword
@@ -34,7 +34,7 @@ namespace boost { namespace parameter { namespace aux {
#include <boost/mpl/bool.hpp>
namespace boost { namespace parameter { namespace aux {
namespace boost { namespace parameter { namespace aux {
template <typename Keyword, typename ActualArg>
struct tag_ref<Keyword,ActualArg,::boost::mpl::false_>

View File

@@ -34,7 +34,7 @@ namespace boost { namespace parameter { namespace aux {
));
#endif
typedef int type;
};
};
}}} // namespace boost::parameter::aux
#endif // include guard

View File

@@ -51,7 +51,7 @@
::boost::parameter::aux::item< \
BOOST_PP_CAT(PS, n), BOOST_PP_CAT(A, n)
#define BOOST_PARAMETER_close_list(z, n, text) >
#define BOOST_PARAMETER_close_list(z, n, text) >
#define BOOST_PARAMETER_arg_list(n) \
::boost::parameter::aux::make_arg_list< \

View File

@@ -19,7 +19,7 @@
#include <boost/mp11/utility.hpp>
#include <type_traits>
namespace boost { namespace parameter { namespace aux {
namespace boost { namespace parameter { namespace aux {
template <typename Keyword, typename Arg>
struct tag_if_lvalue_reference
@@ -75,7 +75,7 @@ namespace boost { namespace parameter { namespace aux {
#include <boost/type_traits/is_lvalue_reference.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace parameter { namespace aux {
namespace boost { namespace parameter { namespace aux {
template <typename Keyword, typename ActualArg>
struct tag
@@ -119,7 +119,7 @@ namespace boost { namespace parameter { namespace aux {
#else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
namespace boost { namespace parameter { namespace aux {
namespace boost { namespace parameter { namespace aux {
template <
typename Keyword
@@ -142,7 +142,7 @@ namespace boost { namespace parameter { namespace aux {
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost { namespace parameter { namespace aux {
namespace boost { namespace parameter { namespace aux {
template <typename Keyword, typename Arg>
struct tag<Keyword,Arg,::boost::mpl::false_>

View File

@@ -121,7 +121,7 @@ namespace boost { namespace parameter { namespace aux {
typedef boost::mpl::bool_<
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
is_cv_reference_wrapper::
#endif
#endif
value> type;
};

View File

@@ -6,7 +6,7 @@
#ifndef BOOST_PARAMETER_VOID_050329_HPP
#define BOOST_PARAMETER_VOID_050329_HPP
namespace boost { namespace parameter {
namespace boost { namespace parameter {
// A placemarker for "no argument passed."
// MAINTAINER NOTE: Do not make this into a metafunction

View File

@@ -24,7 +24,7 @@
#include <boost/type_traits/is_same.hpp>
#endif
namespace boost { namespace parameter {
namespace boost { namespace parameter {
// A metafunction that, given an argument pack, returns the reference type
// of the parameter identified by the given keyword. If no such parameter
@@ -100,7 +100,7 @@ namespace boost { namespace parameter {
#include <boost/parameter/aux_/is_placeholder.hpp>
namespace boost { namespace parameter {
namespace boost { namespace parameter {
template <
typename Parameters
@@ -132,7 +132,7 @@ namespace boost { namespace parameter {
#include <boost/parameter/aux_/result_of0.hpp>
namespace boost { namespace parameter {
namespace boost { namespace parameter {
// A metafunction that, given an argument pack, returns the reference type
// of the parameter identified by the given keyword. If no such parameter

View File

@@ -26,7 +26,7 @@
/**/
#else
#define BOOST_PARAMETER_MATCH_DEFAULTS(ArgTypes)
#endif
#endif
#include <boost/parameter/aux_/preprocessor/seq_enum.hpp>

View File

@@ -24,7 +24,7 @@
#include <boost/type_traits/is_array.hpp>
#endif
namespace boost { namespace parameter {
namespace boost { namespace parameter {
template <typename Tag, typename T>
struct template_keyword : ::boost::parameter::aux::template_keyword_base

View File

@@ -24,7 +24,7 @@
#include <boost/type_traits/is_same.hpp>
#endif
namespace boost { namespace parameter {
namespace boost { namespace parameter {
// A metafunction that, given an argument pack, returns the value type
// of the parameter identified by the given keyword. If no such parameter
@@ -100,7 +100,7 @@ namespace boost { namespace parameter {
#include <boost/parameter/aux_/is_placeholder.hpp>
namespace boost { namespace parameter {
namespace boost { namespace parameter {
template <
typename Parameters
@@ -132,7 +132,7 @@ namespace boost { namespace parameter {
#include <boost/parameter/aux_/result_of0.hpp>
namespace boost { namespace parameter {
namespace boost { namespace parameter {
// A metafunction that, given an argument pack, returns the value type
// of the parameter identified by the given keyword. If no such parameter

View File

@@ -5,6 +5,8 @@
# NOTE: CMake support for Boost.Parameter is currently experimental at best
# and the interface is likely to change in the future
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
# TODO: Also process literate tests
file(GLOB test_files *.cpp)
@@ -12,7 +14,7 @@ file(GLOB test_files *.cpp)
# special requirements
# TODO: enable more tests
list(FILTER test_files EXCLUDE REGEX
efficiency|deduced_unmatched_arg|python_test|duplicates)
efficiency|deduced_unmatched_arg|duplicates)
# Attach all our tests to the `tests` target, to enable
# `cmake --build . --target tests`

View File

@@ -13,10 +13,9 @@ project boost/parameter
:
default-build
<warnings>off
<include>.
;
import python ;
alias parameter_standard_tests
:
[ run maybe.cpp : : : : : <preserve-target-tests>off ]
@@ -493,76 +492,6 @@ alias parameter_literate_tests
]
;
if ! [ os.environ BOOST_PARAMETER_TEST_WITHOUT_PYTHON_TESTS ]
{
alias parameter_python_test
:
:
# Python fails for clang on linux with cxxstd set to 14
<target-os>linux
<toolset>clang
<cxxstd>14
;
alias parameter_python_test
:
:
# Python fails for clang on linux with cxxstd set to 1z
<target-os>linux
<toolset>clang
<cxxstd>1z
;
alias parameter_python_test
:
:
# Python fails for xcode 8.3.0 on osx
# so we turn off this test for this compiler completely for now
<target-os>darwin
# TODO: Differentiate by xcode version or by clang version
;
alias parameter_python_test
:
:
# Python fails for mingw compilers with cxxstd set to 11 or higher
# because of a Python header problem
# so we turn off this test for this compiler completely
<target-os>windows
<toolset>gcc
<address-model>32
;
alias parameter_python_test
:
:
# Python fails for clang-linux compilers with cxxstd set to 11 or higher
# because of a Python header problem
# so we turn off this test for this compiler completely
<target-os>windows
<toolset>clang-linux
<address-model>32
;
alias parameter_python_test
:
:
# Python fails for windows compilers with 64-bit addressing set
# because of a Python header problem
<target-os>windows
<address-model>64
;
alias parameter_python_test
:
[ bpl-test python_test ]
;
}
else
{
alias parameter_python_test ;
}
alias parameter_macros_eval_category
:
:
@@ -950,6 +879,5 @@ test-suite "parameter"
parameter_preprocessor_eval_cat_fail
parameter_standard_tests
parameter_literate_tests
parameter_python_test
parameter_vendor_specific_fail_tests
;

View File

@@ -91,14 +91,14 @@ namespace test {
BOOST_PARAMETER_FUN(int, f, 1, 4, f_parameters)
#else
BOOST_PARAMETER_FUN(void, f, 1, 4, f_parameters)
#endif
#endif
{
BOOST_TEST_EQ(p[test::_w][0], p[test::_x | -1]);
BOOST_TEST_EQ(p[test::_w][1], p[test::_y | -2]);
BOOST_TEST_EQ(p[test::_w][2], p[test::_z | -3]);
#if defined(BOOST_NO_VOID_RETURNS)
return 0;
#endif
#endif
}
} // namespace test

View File

@@ -5,8 +5,8 @@
#include <boost/parameter/name.hpp>
#include <boost/config/workaround.hpp>
#include <boost/timer.hpp>
#include <iostream>
#include "timer.hpp"
namespace test {
@@ -40,7 +40,7 @@ namespace test {
// or other processes and even device hardware interrupts may
// interfere by causing caches to be flushed.
// Accumulator function object with plain C++ interface
// Accumulator function object with plain C++ interface
template <typename T>
struct plain_weight_running_total
{
@@ -147,7 +147,7 @@ namespace test {
test::hammer<Accumulator>(x, repeats);
// Now start a timer.
boost::timer time;
test::timer time;
test::hammer<Accumulator>(x, repeats); // This time, we'll measure.
return time.elapsed();
}
@@ -163,7 +163,7 @@ int main()
{
repeats *= 10;
boost::timer time;
test::timer time;
test::hammer<test::plain_weight_running_total<double> >(.1, repeats);
test::hammer<test::named_param_weight_running_total<double> >(
@@ -172,7 +172,7 @@ int main()
measured = time.elapsed();
}
std::cout
<< "plain time: "
<< test::measure<test::plain_weight_running_total<double> >(

View File

@@ -99,7 +99,7 @@ namespace test {
return 1;
}
struct X
struct X
{
X(int x_ = -1) : x(x_)
{

View File

@@ -1,172 +0,0 @@
// Copyright Daniel Wallin 2006. 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 <math.h>
#include <boost/python.hpp>
#include <boost/parameter/preprocessor.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/python.hpp>
#include <boost/utility/enable_if.hpp>
namespace test {
BOOST_PARAMETER_KEYWORD(tags, x)
BOOST_PARAMETER_KEYWORD(tags, y)
BOOST_PARAMETER_KEYWORD(tags, z)
struct Xbase
{
// We need the disable_if part for VC7.1/8.0.
template <class Args>
Xbase(
Args const& args
, typename boost::disable_if<
boost::is_base_and_derived<Xbase, Args>
>::type* = 0
)
: value(std::string(args[x | "foo"]) + args[y | "bar"])
{}
std::string value;
};
struct X : Xbase
{
BOOST_PARAMETER_CONSTRUCTOR(X, (Xbase), tags,
(optional
(x, *)
(y, *)
)
)
BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f, tags,
(required
(x, *)
(y, *)
)
(optional
(z, *)
)
)
{
return args[x] + args[y] + args[z | 0];
}
BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((std::string), g, tags,
(optional
(x, *)
(y, *)
)
)
{
return std::string(args[x | "foo"]) + args[y | "bar"];
}
BOOST_PARAMETER_MEMBER_FUNCTION((X&), h, tags,
(optional (x, *, "") (y, *, ""))
)
{
return *this;
}
template <class A0>
X& operator()(A0 const& a0)
{
return *this;
}
};
} // namespace test
struct f_fwd
{
template <class R, class T, class A0, class A1, class A2>
R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1, A2 const& a2)
{
return self.f(a0,a1,a2);
}
};
struct g_fwd
{
template <class R, class T, class A0, class A1>
R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1)
{
return self.g(a0,a1);
}
};
struct h_fwd
{
template <class R, class T>
R operator()(boost::type<R>, T& self)
{
return self.h();
}
template <class R, class T, class A0>
R operator()(boost::type<R>, T& self, A0 const& a0)
{
return self.h(a0);
}
template <class R, class T, class A0, class A1>
R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1)
{
return self.h(a0,a1);
}
};
BOOST_PYTHON_MODULE(python_test_ext)
{
namespace mpl = boost::mpl;
using namespace test;
using namespace boost::python;
class_<X>("X")
.def(
boost::parameter::python::init<
mpl::vector<
tags::x*(std::string), tags::y*(std::string)
>
>()
)
.def(
"f"
, boost::parameter::python::function<
f_fwd
, mpl::vector<
int, tags::x(int), tags::y(int), tags::z*(int)
>
>()
)
.def(
"g"
, boost::parameter::python::function<
g_fwd
, mpl::vector<
std::string, tags::x*(std::string), tags::y*(std::string)
>
>()
)
.def(
"h"
, boost::parameter::python::function<
h_fwd
, mpl::vector<
X&, tags::x**(std::string), tags::y**(std::string)
>
>()
, return_arg<>()
)
.def(
boost::parameter::python::call<
mpl::vector<
X&, tags::x(int)
>
>() [ return_arg<>() ]
)
.def_readonly("value", &X::value);
}

View File

@@ -1,41 +0,0 @@
# Copyright Daniel Wallin 2006. 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)
'''
>>> from python_test_ext import X
>>> x = X(y = 'baz')
>>> x.value
'foobaz'
>>> x.f(1,2)
3
>>> x.f(1,2,3)
6
>>> x.f(1,2, z = 3)
6
>>> x.f(z = 3, y = 2, x = 1)
6
>>> x.g()
'foobar'
>>> x.g(y = "baz")
'foobaz'
>>> x.g(x = "baz")
'bazbar'
>>> x.g(y = "foo", x = "bar")
'barfoo'
>>> y = x.h(x = "bar", y = "foo")
>>> assert x == y
>>> y = x(0)
>>> assert x == y
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, python_test
return doctest.testmod(python_test)
if __name__ == '__main__':
import sys
sys.exit(run()[0])

59
test/timer.hpp Normal file
View File

@@ -0,0 +1,59 @@
// Copyright Andrey Semashev 2023.
//
// 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)
// This file is a copy of boost/timer.hpp from Boost.Timer v1, which
// was deprecated and slated for removal. We are not using Boost.Timer v2
// components to avoid having to link with its binary.
//
// See http://www.boost.org/libs/timer for documentation.
#ifndef BOOST_PARAMETER_TEST_TIMER_HPP
#define BOOST_PARAMETER_TEST_TIMER_HPP
#include <ctime>
#include <limits>
namespace test {
// timer -------------------------------------------------------------------//
// A timer object measures elapsed time.
// It is recommended that implementations measure wall clock rather than CPU
// time since the intended use is performance measurement on systems where
// total elapsed time is more important than just process or CPU time.
// Warnings: The maximum measurable elapsed time may well be only 596.5+ hours
// due to implementation limitations. The accuracy of timings depends on the
// accuracy of timing information provided by the underlying platform, and
// this varies a great deal from platform to platform.
class timer
{
public:
timer() { _start_time = std::clock(); } // postcondition: elapsed()==0
void restart() { _start_time = std::clock(); } // post: elapsed()==0
double elapsed() const // return elapsed time in seconds
{ return double(std::clock() - _start_time) / CLOCKS_PER_SEC; }
double elapsed_max() const // return estimated maximum value for elapsed()
// Portability warning: elapsed_max() may return too high a value on systems
// where std::clock_t overflows or resets at surprising values.
{
return (double((std::numeric_limits<std::clock_t>::max)())
- double(_start_time)) / double(CLOCKS_PER_SEC);
}
double elapsed_min() const // return minimum value for elapsed()
{ return double(1)/double(CLOCKS_PER_SEC); }
private:
std::clock_t _start_time;
}; // timer
} // namespace test
#endif // BOOST_PARAMETER_TEST_TIMER_HPP