2
0
mirror of https://github.com/boostorg/lambda2.git synced 2026-01-19 16:22:20 +00:00

Compare commits

...

70 Commits

Author SHA1 Message Date
Peter Dimov
dddfec6085 Update ci.yml 2025-06-28 08:26:42 +03:00
Peter Dimov
a13c743c4b Update version 2025-06-28 08:08:43 +03:00
Peter Dimov
865eb98c9c Update ci.yml 2024-12-13 22:38:40 +02:00
Peter Dimov
8466c546e5 Apply Node20 workaround 2024-12-13 22:36:00 +02:00
Peter Dimov
6ebe42d4ac Update ci.yml 2024-12-13 22:35:11 +02:00
Peter Dimov
cb2e51eb84 Update version 2024-12-13 22:33:25 +02:00
Peter Dimov
f1d863c6b2 Add VERBATIM to add_custom_target 2024-08-27 14:07:08 +03:00
Peter Dimov
3fb266bf57 Update build.jam, test/Jamfile 2024-08-27 13:59:28 +03:00
Rene Rivera
3d7778f2a9 Sync from upstream. 2024-08-17 09:06:33 -05:00
Peter Dimov
97f43720a1 Update ci.yml 2024-08-17 11:53:49 +03:00
Peter Dimov
3a982bf019 Update version 2024-08-17 04:22:04 +03:00
Rene Rivera
a03806e4ec Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:24 -05:00
Rene Rivera
53bbeac521 Update copyright dates. 2024-07-20 22:52:05 -05:00
Rene Rivera
ad47d9ed4f Change all <source> references to <library>. 2024-07-20 19:40:17 -05:00
Rene Rivera
d1fa581326 Bump B2 require to 5.2 2024-06-14 11:33:55 -05:00
Rene Rivera
19d484e707 Add requires-b2 check to top-level build file. 2024-05-05 09:00:01 -05:00
Rene Rivera
a50009a44f Sync from upstream. 2024-04-20 15:34:26 -05:00
Peter Dimov
4118a318ca Update version 2024-04-18 12:08:17 +03:00
Peter Dimov
94a56766bb Revert "Update doc/Jamfile"
This reverts commit 863cdf2e96.
2024-04-16 22:35:22 +03:00
Peter Dimov
863cdf2e96 Update doc/Jamfile 2024-04-16 22:19:00 +03:00
Rene Rivera
7958b78d45 Make the library modular usable. 2024-03-11 08:38:17 -05:00
Peter Dimov
a17ffc25d3 Update ci.yml 2023-12-19 16:29:43 +02:00
Peter Dimov
2c8de60398 Update version 2023-12-19 13:21:24 +02:00
Peter Dimov
62815a69bf Update ci.yml 2023-08-13 01:00:21 +03:00
Peter Dimov
247f6b7b58 Update version 2023-08-12 23:47:37 +03:00
Peter Dimov
2935343723 Update ci.yml 2023-04-15 18:19:30 +03:00
Peter Dimov
8ac931161b Update version 2023-04-15 15:20:39 +03:00
Peter Dimov
3ba6ab955e Update version 2022-12-15 17:55:58 +02:00
Peter Dimov
4b68743cf0 Add gcc-12, clang-13, clang-14 to ci.yml 2022-08-15 19:55:55 +03:00
Peter Dimov
3f43588316 Regenerate CMakeLists.txt 2022-08-15 19:32:30 +03:00
Peter Dimov
20420e134f Add 'cxxstd' to meta/libraries.json 2022-08-15 19:32:03 +03:00
Peter Dimov
7824b74a27 Add CMake tests to ci.yml 2022-08-15 19:22:35 +03:00
Peter Dimov
d72468479f Change macos-10.15 to macos-11 in ci.yml 2022-08-15 19:08:24 +03:00
Peter Dimov
b55fdcb9fa Update version 2022-08-14 18:45:43 +03:00
Peter Dimov
fd1a3e4543 Remove msvc-14.1 from GHA, add clang-win 2022-04-14 16:15:13 +03:00
Peter Dimov
8c6c1166c4 Update ci.yml 2022-04-14 14:21:41 +03:00
Peter Dimov
c618d6902b Re-enable VS2017 2022-04-14 14:02:35 +03:00
Peter Dimov
ae42ebda76 Update version 2022-04-14 13:41:49 +03:00
Peter Dimov
3ccd5c251b Add msvc-14.0 to GHA 2021-12-09 04:11:57 +02:00
Peter Dimov
132db3b09a Update version 2021-12-09 04:10:29 +02:00
Peter Dimov
253aef863f Enable syntax highlighting 2021-10-28 23:13:48 +03:00
Peter Dimov
a593616a98 Add msvc-14.3 to ci.yml 2021-10-28 23:13:17 +03:00
Peter Dimov
2ff3fef3d1 Update documentation 2021-10-18 21:33:52 +03:00
Peter Dimov
0572e42219 Work around libc++ issue (again.) 2021-10-18 21:20:14 +03:00
Peter Dimov
7c39436198 Add first, second function objects. Fixes #5. 2021-10-18 20:57:25 +03:00
Peter Dimov
f8b3099259 Fix placeholder types in the synopsis 2021-09-05 19:01:20 +03:00
Peter Dimov
a666ac4fb6 Update revision history 2021-09-05 18:46:17 +03:00
Peter Dimov
d57e7e1618 Document operator->* 2021-09-05 07:05:49 +03:00
Peter Dimov
d7a1fccc89 Work around libc++ issue (https://bugs.llvm.org/show_bug.cgi?id=51753) 2021-09-05 06:54:38 +03:00
Peter Dimov
0c1898100a Add operator->* 2021-09-05 05:26:32 +03:00
Peter Dimov
e6a538a98e Remove superfluous backslashes 2021-09-05 05:26:15 +03:00
Peter Dimov
08b40af530 Fix stream detection in op<<, op>> 2021-09-05 03:06:33 +03:00
Peter Dimov
d6389b60f5 Update tests with std::ref(is), std::ref(os) 2021-09-05 03:01:31 +03:00
Peter Dimov
f2ab3ade7c Update documentation 2021-09-05 02:53:33 +03:00
Peter Dimov
e2251ab450 Special-case streams in operator<< and operator>> 2021-09-05 01:50:37 +03:00
Peter Dimov
3a06c98e8d Update README 2021-09-05 01:19:08 +03:00
Peter Dimov
8b08326f6e Remove ubuntu-16.04 jobs from ci.yml 2021-09-05 01:18:52 +03:00
Peter Dimov
b9cc0aa5d1 Update README 2021-09-05 01:11:26 +03:00
Peter Dimov
58c947fcf9 Update version 2021-08-17 15:13:06 +03:00
Peter Dimov
9e2e0a31b3 Update copyright 2021-07-11 16:52:18 +03:00
Peter Dimov
93c67a57c8 Update reference 2021-07-11 16:51:40 +03:00
Peter Dimov
3bf3ce3a9e Update copyright 2021-07-11 16:28:39 +03:00
Peter Dimov
51b9448ae7 Update doc/.gitignore 2021-07-11 16:27:09 +03:00
Peter Dimov
a064c3ae83 Remove doc/html/lambda2.html 2021-07-11 16:25:58 +03:00
Peter Dimov
a329989b1e Update overview 2021-07-11 16:25:08 +03:00
Peter Dimov
f3a3810be4 Add compound assignment operators 2021-06-27 18:41:35 +03:00
Peter Dimov
04367ac3e5 Add operator[] to placeholders 2021-06-27 17:05:54 +03:00
Peter Dimov
07c965a088 Add operator() to placeholders 2021-06-27 12:16:17 +03:00
Peter Dimov
bfc742d854 Add operator++, operator-- 2021-06-27 11:30:02 +03:00
Peter Dimov
a01d4473ab Rename BOOST_LAMBDA2_PREFIX_FN to BOOST_LAMBDA2_UNARY_FN 2021-06-27 11:22:06 +03:00
25 changed files with 1224 additions and 1133 deletions

View File

@@ -17,121 +17,195 @@ jobs:
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
container: ubuntu:18.04
os: ubuntu-latest
install: g++-5
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
container: ubuntu:18.04
os: ubuntu-latest
install: g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-7
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
container: ubuntu:20.04
os: ubuntu-latest
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-10
- toolset: gcc-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-11
- toolset: clang
compiler: clang++-3.5
cxxstd: "03,11"
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
os: ubuntu-22.04
- toolset: gcc-12
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: g++-12
- toolset: gcc-13
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: g++-13
- toolset: gcc-14
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: g++-14
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-16.04
container: ubuntu:18.04
os: ubuntu-latest
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-16.04
container: ubuntu:18.04
os: ubuntu-latest
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-16.04
container: ubuntu:18.04
os: ubuntu-latest
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-12
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
compiler: clang++-13
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-17
- toolset: clang
compiler: clang++-18
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
- toolset: clang
compiler: clang++-19
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.10
os: ubuntu-latest
install: clang-19
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-13
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-14
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-15
runs-on: ${{matrix.os}}
container:
image: ${{matrix.container}}
volumes:
- /node20217:/node20217:rw,rshared
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python3 git g++ curl xz-utils
- name: Install nodejs20glibc2.17
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
run: |
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
ldd /__e/node20/bin/node
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
@@ -151,7 +225,7 @@ jobs:
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
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
@@ -170,23 +244,31 @@ jobs:
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"
- toolset: msvc-14.0
cxxstd: "14,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
@@ -214,4 +296,346 @@ jobs:
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error
windows-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
- os: windows-2025
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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%
- name: Use library with add_subdirectory (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use library with add_subdirectory (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
- os: windows-2025
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- name: Install (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Debug
- name: Install (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Release
- name: Use the installed library (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use the installed library (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
- os: windows-2025
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
- name: Build tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Debug
- name: Run tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Debug
- name: Build tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Release
- name: Run tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Release

View File

@@ -1,9 +1,9 @@
# Generated by `boostdep --cmake lambda2`
# Copyright 2020 Peter Dimov
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
cmake_minimum_required(VERSION 3.8...3.20)
project(boost_lambda2 VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
@@ -12,9 +12,10 @@ add_library(Boost::lambda2 ALIAS boost_lambda2)
target_include_directories(boost_lambda2 INTERFACE include)
target_compile_features(boost_lambda2 INTERFACE cxx_std_14)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@@ -5,15 +5,15 @@ described in [this post](https://pdimov.github.io/blog/2020/07/22/a-c14-lambda-l
It has no dependencies and consists of a [single header](include/boost/lambda2/lambda2.hpp).
See [the documentation](https://www.boost.org/doc/libs/develop/libs/lambda2/) for more information.
See [the documentation](https://www.boost.org/libs/lambda2/) for more information.
## Supported Compilers
* g++ 5 or later with `-std=c++14` or above
* clang++ 3.5 or later with `-std=c++14` or above
* clang++ 3.9 or later with `-std=c++14` or above
* Visual Studio 2015, 2017, 2019
Tested on [Travis](https://travis-ci.org/github/pdimov/lambda2/) and
Tested on [Github Actions](https://github.com/boostorg/lambda2/actions) and
[Appveyor](https://ci.appveyor.com/project/pdimov/lambda2).
## License

16
build.jam Normal file
View File

@@ -0,0 +1,16 @@
# Copyright 2023-2024 René Ferdinand Rivera Morell
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
require-b2 5.2 ;
project /boost/lambda2 ;
explicit
[ alias boost_lambda2 : : : : <include>include <library>$(boost_dependencies) ]
[ alias all : boost_lambda2 test ]
;
call-if : boost-library lambda2
;

1
doc/.gitignore vendored
View File

@@ -1 +1,2 @@
/pdf/
/html/

File diff suppressed because it is too large Load Diff

View File

@@ -9,11 +9,15 @@ Peter Dimov
:toc: left
:toclevels: 4
:idprefix:
:listing-caption: Code Example
:docinfo: private-footer
:source-highlighter: rouge
:source-language: c++
:leveloffset: +1
include::lambda2/overview.adoc[]
include::lambda2/changelog.adoc[]
include::lambda2/reference.adoc[]
include::lambda2/copyright.adoc[]

View File

@@ -0,0 +1,16 @@
////
Copyright 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#changelog]
# Revision History
:idprefix:
## Changes in 1.78.0
* Added special cases in `operator<<` and `operator>>` when
the first argument is a stream, to allow `std::cout << _1`.
* Added `operator\->*`.
* Added `first`, `second`.

View File

@@ -8,5 +8,5 @@ https://www.boost.org/LICENSE_1_0.txt
# Copyright and License
:idprefix:
This documentation is copyright 2020 Peter Dimov and is distributed under
This documentation is copyright 2020, 2021 Peter Dimov and is distributed under
the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

View File

@@ -1,5 +1,5 @@
////
Copyright 2020 Peter Dimov
Copyright 2020, 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
@@ -12,16 +12,18 @@ https://www.boost.org/LICENSE_1_0.txt
This is a simple, but functional, {cpp}14 lambda library. It takes
advantage of the fact that the standard `<functional>` header already
provides placeholders `_1`, `_2`, `_3`, and so on, for use with
`std::bind`, and function objects such as `std::plus`, `std::greater`,
`std::logical_not`, and `std::bit_xor`, corresponding to arithmetic,
relational, logical and bitwise operators.
provides `std::bind` customization points (`is_placeholder`,
`is_bind_expression`), and function objects such as `std::plus`,
`std::greater`, `std::logical_not`, and `std::bit_xor`, corresponding
to arithmetic, relational, logical and bitwise operators.
This allows the library to provide a minimal implementation that
still lets expressions such as `_1 + 5`, `_1 % 2 == 0`, `_1 > _2`,
or `_1 == ' ' || _1 == '\t'` to be composed and used as function
objects.
For example, `_1 + 5` is implemented as `std::bind(std::plus<>, _1, 5)`.
These "lambda" expressions can also be freely combined with `std::bind`.
For example, `std::bind( f, _1 ) == std::bind( g, _1 )` and
`std::bind( f, _1 + _2 )` both work and have the expected behavior.
@@ -64,8 +66,8 @@ None. A single, self-contained header.
## Supported Compilers
* GCC 5 or later with `-std=c++14` or above
* Clang 3.5 or later with `-std=c++14` or above
* Clang 3.9 or later with `-std=c++14` or above
* Visual Studio 2015, 2017, 2019
Tested on https://travis-ci.org/github/pdimov/lambda2[Travis] and
Tested on https://github.com/boostorg/lambda2/actions[Github Actions] and
https://ci.appveyor.com/project/pdimov/lambda2[Appveyor].

View File

@@ -1,5 +1,5 @@
////
Copyright 2020 Peter Dimov
Copyright 2020, 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
@@ -16,6 +16,22 @@ https://www.boost.org/LICENSE_1_0.txt
namespace boost {
namespace lambda2 {
// placeholders
template<int I> struct lambda2_arg;
inline constexpr lambda2_arg<1> _1{};
inline constexpr lambda2_arg<2> _2{};
inline constexpr lambda2_arg<3> _3{};
inline constexpr lambda2_arg<4> _4{};
inline constexpr lambda2_arg<5> _5{};
inline constexpr lambda2_arg<6> _6{};
inline constexpr lambda2_arg<7> _7{};
inline constexpr lambda2_arg<8> _8{};
inline constexpr lambda2_arg<9> _9{};
// arithmetic operators
template<class A, class B> auto operator+( A && a, B && b );
template<class A, class B> auto operator-( A && a, B && b );
template<class A, class B> auto operator*( A && a, B && b );
@@ -23,6 +39,8 @@ template<class A, class B> auto operator/( A && a, B && b );
template<class A, class B> auto operator%( A && a, B && b );
template<class A> auto operator-( A && a );
// relational operators
template<class A, class B> auto operator==( A && a, B && b );
template<class A, class B> auto operator!=( A && a, B && b );
template<class A, class B> auto operator>( A && a, B && b );
@@ -30,19 +48,93 @@ template<class A, class B> auto operator<( A && a, B && b );
template<class A, class B> auto operator>=( A && a, B && b );
template<class A, class B> auto operator<=( A && a, B && b );
// logical operators
template<class A, class B> auto operator&&( A && a, B && b );
template<class A, class B> auto operator||( A && a, B && b );
template<class A> auto operator!( A && a );
// bitwise operators
template<class A, class B> auto operator&( A && a, B && b );
template<class A, class B> auto operator|( A && a, B && b );
template<class A, class B> auto operator^( A && a, B && b );
template<class A> auto operator~( A && a );
template<class A, class B> auto operator<<( A && a, B && b );
template<class A, class B> auto operator>>( A && a, B && b );
// additional unary operators
template<class A> auto operator+( A && a );
template<class A> auto operator*( A && a );
template<class A> auto operator++( A && a );
template<class A> auto operator--( A && a );
template<class A> auto operator++( A && a, int );
template<class A> auto operator--( A && a, int );
// compound assignment operators
template<class A, class B> auto operator+=( A && a, B && b );
template<class A, class B> auto operator-=( A && a, B && b );
template<class A, class B> auto operator*=( A && a, B && b );
template<class A, class B> auto operator/=( A && a, B && b );
template<class A, class B> auto operator%=( A && a, B && b );
template<class A, class B> auto operator&=( A && a, B && b );
template<class A, class B> auto operator|=( A && a, B && b );
template<class A, class B> auto operator^=( A && a, B && b );
template<class A, class B> auto operator<<=( A && a, B && b );
template<class A, class B> auto operator>>=( A && a, B && b );
// additional binary operators
template<class A, class B> auto operator->*( A && a, B && b );
// projections
inline constexpr /unspecified/ first{};
inline constexpr /unspecified/ second{};
} // namespace lambda2
} // namespace boost
```
### Placeholders
```
template<int I> struct lambda2_arg
{
template<class... A> decltype(auto) operator()( A&&... a ) const noexcept;
template<class T> auto operator[]( T&& t ) const;
};
```
`lambda2_arg<I>` is the type of the library-provided placeholders `_I`. The
standard customization point `std::is_placeholder` is specialized for it,
enabling the use of Lambda2's placeholders with `std::bind`.
The placeholders define `operator()`, which permits their direct use as
function objects. E.g. `_1(x, y)` returns `x`.
`operator[]` is also defined to allow expressions like `_1[x]` or `_1[_2]`.
```
template<class... A> decltype(auto) operator()( A&&... a ) const noexcept;
```
[none]
* {blank}
+
Returns: :: `std::get<std::size_t{I-1}>( std::tuple<A&&...>( std::forward<A>(a)... ) );`
```
template<class T> auto operator[]( T&& t ) const;
```
[none]
* {blank}
+
Returns: :: `std::bind( fn, *this, std::forward<T>(t) );`, where `fn` is
a function object such that `fn(x, y)` returns `x[y]`.
### Common Requirements
All operators defined in the subsequent sections only participate in
@@ -214,3 +306,130 @@ template<class A> auto operator~( A && a );
+
Returns: ::
`std::bind( std::bit_not<>(), std::forward<A>(a) );`
```
template<class A, class B> auto operator<<( A && a, B && b );
```
[none]
* {blank}
+
Returns: :: `std::bind( fn, std::forward<A>(a), std::forward<B>(b) );`,
where `fn` is a function object such that `fn(x, y)` returns `x << y`.
```
template<class A, class B> auto operator>>( A && a, B && b );
```
[none]
* {blank}
+
Returns: :: `std::bind( fn, std::forward<A>(a), std::forward<B>(b) );`,
where `fn` is a function object such that `fn(x, y)` returns `x >> y`.
### Additional Unary Operators
```
template<class A> auto operator+( A && a );
```
[none]
* {blank}
+
Returns: ::
`std::bind( fn, std::forward<A>(a) );`, where `fn` is a function object
such that `fn(x)` returns `+x`.
```
template<class A> auto operator*( A && a );
```
[none]
* {blank}
+
Returns: ::
`std::bind( fn, std::forward<A>(a) );`, where `fn` is a function object
such that `fn(x)` returns `*x`.
```
template<class A> auto operator++( A && a );
```
[none]
* {blank}
+
Returns: ::
`std::bind( fn, std::forward<A>(a) );`, where `fn` is a function object
such that `fn(x)` returns `++x`.
```
template<class A> auto operator--( A && a );
```
[none]
* {blank}
+
Returns: ::
`std::bind( fn, std::forward<A>(a) );`, where `fn` is a function object
such that `fn(x)` returns `--x`.
```
template<class A> auto operator++( A && a, int );
```
[none]
* {blank}
+
Returns: ::
`std::bind( fn, std::forward<A>(a) );`, where `fn` is a function object
such that `fn(x)` returns `x++`.
```
template<class A> auto operator--( A && a, int );
```
[none]
* {blank}
+
Returns: ::
`std::bind( fn, std::forward<A>(a) );`, where `fn` is a function object
such that `fn(x)` returns `x--`.
### Compound Assignment Operators
```
template<class A, class B> auto operator@=( A && a, B && b );
```
[none]
* {blank}
+
Returns: :: `std::bind( fn, std::forward<A>(a), std::forward<B>(b) );`,
where `fn` is a function object such that `fn(x, y)` returns `x @= y`.
### Additional Binary Operators
```
template<class A, class B> auto operator->*( A && a, B && b );
```
[none]
* {blank}
+
Returns: :: `std::bind( std::forward<B>(b), std::forward<A>(a) );`
Notes: :: This operator is intended to be used with "projection" function
objects such as member pointers or member functions taking zero arguments,
as in `_1\->*&X::m` or `_1\->*&X::f`.
### Projections
```
inline constexpr /unspecified/ first{};
```
A function object such that `first(x)` returns `std::get<0>(x)`.
```
inline constexpr /unspecified/ second{};
```
A function object such that `second(x)` returns `std::get<1>(x)`.
.Using first and second to print out a map
```
void print( std::map<int, std::string> const & m )
{
using namespace boost::lambda2;
std::for_each( m.begin(), m.end(), std::cout << _1->*first << ": " << _1->*second << '\n' );
}
```

View File

@@ -1,27 +1,60 @@
#ifndef BOOST_LAMBDA2_LAMBDA2_HPP_INCLUDED
#define BOOST_LAMBDA2_LAMBDA2_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Copyright 2020, 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <functional>
#include <type_traits>
#include <utility>
#include <tuple>
#include <cstddef>
#include <iosfwd>
// Same format as BOOST_VERSION:
// major * 100000 + minor * 100 + patch
#define BOOST_LAMBDA2_VERSION 107700
#define BOOST_LAMBDA2_VERSION 108900
namespace boost
{
namespace lambda2
{
namespace lambda2_detail
{
struct subscript
{
template<class T1, class T2> decltype(auto) operator()(T1&& t1, T2&& t2) const
{
return std::forward<T1>(t1)[ std::forward<T2>(t2) ];
}
};
template<int I> struct get
{
template<class T> decltype(auto) operator()( T&& t ) const
{
return std::get<I>( std::forward<T>(t) );
}
};
} // namespace lambda2_detail
// placeholders
template<int I> struct lambda2_arg
{
template<class... A> decltype(auto) operator()( A&&... a ) const noexcept
{
return std::get<std::size_t{I-1}>( std::tuple<A&&...>( std::forward<A>(a)... ) );
}
template<class T> auto operator[]( T&& t ) const
{
return std::bind( lambda2_detail::subscript(), *this, std::forward<T>( t ) );
}
};
#if defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L
@@ -40,6 +73,11 @@ BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<7> _7{};
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<8> _8{};
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<9> _9{};
// first, second
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_detail::get<0> first{};
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_detail::get<1> second{};
#undef BOOST_LAMBDA2_INLINE_VAR
} // namespace lambda2
@@ -64,7 +102,7 @@ namespace lambda2_detail
// additional function objects
#define BOOST_LAMBDA2_PREFIX_FN(op, fn) \
#define BOOST_LAMBDA2_UNARY_FN(op, fn) \
struct fn \
{ \
template<class T> decltype(auto) operator()(T&& t) const \
@@ -94,8 +132,25 @@ namespace lambda2_detail
BOOST_LAMBDA2_BINARY_FN(<<, left_shift)
BOOST_LAMBDA2_BINARY_FN(>>, right_shift)
BOOST_LAMBDA2_PREFIX_FN(+, unary_plus)
BOOST_LAMBDA2_PREFIX_FN(*, dereference)
BOOST_LAMBDA2_UNARY_FN(+, unary_plus)
BOOST_LAMBDA2_UNARY_FN(*, dereference)
BOOST_LAMBDA2_UNARY_FN(++, increment)
BOOST_LAMBDA2_UNARY_FN(--, decrement)
BOOST_LAMBDA2_POSTFIX_FN(++, postfix_increment)
BOOST_LAMBDA2_POSTFIX_FN(--, postfix_decrement)
BOOST_LAMBDA2_BINARY_FN(+=, plus_equal)
BOOST_LAMBDA2_BINARY_FN(-=, minus_equal)
BOOST_LAMBDA2_BINARY_FN(*=, multiplies_equal)
BOOST_LAMBDA2_BINARY_FN(/=, divides_equal)
BOOST_LAMBDA2_BINARY_FN(%=, modulus_equal)
BOOST_LAMBDA2_BINARY_FN(&=, bit_and_equal)
BOOST_LAMBDA2_BINARY_FN(|=, bit_or_equal)
BOOST_LAMBDA2_BINARY_FN(^=, bit_xor_equal)
BOOST_LAMBDA2_BINARY_FN(<<=, left_shift_equal)
BOOST_LAMBDA2_BINARY_FN(>>=, right_shift_equal)
// operators
@@ -110,6 +165,8 @@ template<class A> using enable_unary_lambda =
template<class A, class B> using enable_binary_lambda =
std::enable_if_t<is_lambda_expression<A>::value || is_lambda_expression<B>::value>;
template<class T> using is_stream = std::is_base_of<std::ios_base, remove_cvref_t<T>>;
} // namespace lambda2_detail
#define BOOST_LAMBDA2_UNARY_LAMBDA(op, fn) \
@@ -119,6 +176,13 @@ template<class A, class B> using enable_binary_lambda =
return std::bind( fn(), std::forward<A>(a) ); \
}
#define BOOST_LAMBDA2_POSTFIX_LAMBDA(op, fn) \
template<class A, class = lambda2_detail::enable_unary_lambda<A>> \
auto operator op( A&& a, int ) \
{ \
return std::bind( fn(), std::forward<A>(a) ); \
}
#define BOOST_LAMBDA2_BINARY_LAMBDA(op, fn) \
template<class A, class B, class = lambda2_detail::enable_binary_lambda<A, B>> \
auto operator op( A&& a, B&& b ) \
@@ -153,12 +217,68 @@ BOOST_LAMBDA2_UNARY_LAMBDA(~, std::bit_not<>)
// additional
BOOST_LAMBDA2_BINARY_LAMBDA(<<, lambda2_detail::left_shift)
BOOST_LAMBDA2_BINARY_LAMBDA(>>, lambda2_detail::right_shift)
BOOST_LAMBDA2_UNARY_LAMBDA(+, lambda2_detail::unary_plus)
BOOST_LAMBDA2_UNARY_LAMBDA(*, lambda2_detail::dereference)
BOOST_LAMBDA2_UNARY_LAMBDA(++, lambda2_detail::increment)
BOOST_LAMBDA2_UNARY_LAMBDA(--, lambda2_detail::decrement)
BOOST_LAMBDA2_POSTFIX_LAMBDA(++, lambda2_detail::postfix_increment)
BOOST_LAMBDA2_POSTFIX_LAMBDA(--, lambda2_detail::postfix_decrement)
// compound assignment
BOOST_LAMBDA2_BINARY_LAMBDA(+=, lambda2_detail::plus_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(-=, lambda2_detail::minus_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(*=, lambda2_detail::multiplies_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(/=, lambda2_detail::divides_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(%=, lambda2_detail::modulus_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(&=, lambda2_detail::bit_and_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(|=, lambda2_detail::bit_or_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(^=, lambda2_detail::bit_xor_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(<<=, lambda2_detail::left_shift_equal)
BOOST_LAMBDA2_BINARY_LAMBDA(>>=, lambda2_detail::right_shift_equal)
// operator<<
template<class A, class = std::enable_if_t<!lambda2_detail::is_stream<A>::value>,
class B, class = lambda2_detail::enable_binary_lambda<A, B>>
auto operator<<( A&& a, B&& b )
{
return std::bind( lambda2_detail::left_shift(), std::forward<A>(a), std::forward<B>(b) );
}
template<class A, class = std::enable_if_t<lambda2_detail::is_stream<A>::value>,
class B, class = lambda2_detail::enable_unary_lambda<B>>
auto operator<<( A& a, B&& b )
{
return std::bind( lambda2_detail::left_shift(), std::ref(a), std::forward<B>(b) );
}
// operator>>
template<class A, class = std::enable_if_t<!lambda2_detail::is_stream<A>::value>,
class B, class = lambda2_detail::enable_binary_lambda<A, B>>
auto operator>>( A&& a, B&& b )
{
return std::bind( lambda2_detail::right_shift(), std::forward<A>(a), std::forward<B>(b) );
}
template<class A, class = std::enable_if_t<lambda2_detail::is_stream<A>::value>,
class B, class = lambda2_detail::enable_unary_lambda<B>>
auto operator>>( A& a, B&& b )
{
return std::bind( lambda2_detail::right_shift(), std::ref(a), std::forward<B>(b) );
}
// operator->*
template<class A, class B, class = lambda2_detail::enable_unary_lambda<A>>
auto operator->*( A&& a, B&& b )
{
return std::bind( std::forward<B>(b), std::forward<A>(a) );
}
} // namespace lambda2
} // namespace boost

View File

@@ -10,5 +10,6 @@
"description": "A C++14 lambda library.",
"category": [
"Function-objects"
]
],
"cxxstd": "14"
}

11
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,11 @@
# 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 LINK_LIBRARIES Boost::lambda2 Boost::core)
endif()

View File

@@ -2,10 +2,15 @@
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
import-search /boost/config/checks ;
import testing ;
import ../../config/checks/config : requires ;
import config : requires ;
project : requirements
<library>/boost/lambda2//boost_lambda2
<library>/boost/config//boost_config
<library>/boost/core//boost_core
<warnings>extra
@@ -13,7 +18,8 @@ project : requirements
<toolset>msvc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on ;
<toolset>gcc:<warnings-as-errors>on
;
run quick.cpp ;
run lambda2_test.cpp ;
@@ -21,3 +27,9 @@ run version.cpp ;
run lookup_problem.cpp ;
run dereference.cpp ;
run placeholders.cpp ;
run increment.cpp ;
run subscript.cpp ;
run compound.cpp ;
run stream_insert.cpp ;
run stream_extract.cpp ;
run project.cpp ;

View File

@@ -0,0 +1,17 @@
# 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...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_lambda2 REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::lambda2)
enable_testing()
add_test(quick quick)
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -0,0 +1,17 @@
# 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...3.16)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/lambda2)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::lambda2)
enable_testing()
add_test(quick quick)
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

32
test/compound.cpp Normal file
View File

@@ -0,0 +1,32 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/lambda2.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
#define TEST_COMPOUND(Op) \
BOOST_TEST_EQ( (_1 Op 1)(x1), y1 Op 1 ); \
BOOST_TEST_EQ( (_1 Op _2)(x1, x2), y1 Op y2 ); \
BOOST_TEST_EQ( ((_1 Op _2) Op _3)(x1, x2, x3), (y1 Op y2) Op y3 );
int main()
{
using namespace boost::lambda2;
int x1 = 1, x2 = 2, x3 = 3, y1 = 1, y2 = 2, y3 = 3;
TEST_COMPOUND(+=)
TEST_COMPOUND(-=)
TEST_COMPOUND(*=)
TEST_COMPOUND(/=)
TEST_COMPOUND(%=)
TEST_COMPOUND(&=)
TEST_COMPOUND(|=)
TEST_COMPOUND(^=)
TEST_COMPOUND(<<=)
TEST_COMPOUND(>>=)
return boost::report_errors();
}

34
test/increment.cpp Normal file
View File

@@ -0,0 +1,34 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/lambda2.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
int main()
{
using namespace boost::lambda2;
int x1 = 1, x2 = 2, y1 = 1, y2 = 2;
BOOST_TEST_EQ( (_1++)(x1), y1++ );
BOOST_TEST_EQ( (++_1)(x1), ++y1 );
BOOST_TEST_EQ( (_1--)(x1), y1-- );
BOOST_TEST_EQ( (--_1)(x1), --y1 );
BOOST_TEST_EQ( (_1++ + _2++)(x1, x2), y1++ + y2++ );
BOOST_TEST_EQ( (++_1 + ++_2)(x1, x2), ++y1 + ++y2 );
BOOST_TEST_EQ( (_1-- + _2--)(x1, x2), y1-- + y2-- );
BOOST_TEST_EQ( (--_1 + --_2)(x1, x2), --y1 + --y2 );
BOOST_TEST_EQ( std::bind(_1 + _2, _1++, _2++)(x1, x2), y1++ + y2++ );
BOOST_TEST_EQ( std::bind(_1 + _2, ++_1, ++_2)(x1, x2), ++y1 + ++y2 );
BOOST_TEST_EQ( std::bind(_1 + _2, _1--, _2--)(x1, x2), y1-- + y2-- );
BOOST_TEST_EQ( std::bind(_1 + _2, --_1, --_2)(x1, x2), --y1 + --y2 );
return boost::report_errors();
}

View File

@@ -25,5 +25,24 @@ int main()
BOOST_TEST_EQ( std::bind(f, _8)( 1, 2, 3, 4, 5, 6, 7, 8 ), 8 );
BOOST_TEST_EQ( std::bind(f, _9)( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 9 );
BOOST_TEST_EQ( _1( 1 ), 1 );
BOOST_TEST_EQ( _2( 1, 2 ), 2 );
BOOST_TEST_EQ( _3( 1, 2, 3 ), 3 );
BOOST_TEST_EQ( _4( 1, 2, 3, 4 ), 4 );
BOOST_TEST_EQ( _5( 1, 2, 3, 4, 5 ), 5 );
BOOST_TEST_EQ( _6( 1, 2, 3, 4, 5, 6 ), 6 );
BOOST_TEST_EQ( _7( 1, 2, 3, 4, 5, 6, 7 ), 7 );
BOOST_TEST_EQ( _8( 1, 2, 3, 4, 5, 6, 7, 8 ), 8 );
BOOST_TEST_EQ( _9( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 9 );
BOOST_TEST_EQ( _1( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 1 );
BOOST_TEST_EQ( _2( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 2 );
BOOST_TEST_EQ( _3( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 3 );
BOOST_TEST_EQ( _4( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 4 );
BOOST_TEST_EQ( _5( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 5 );
BOOST_TEST_EQ( _6( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 6 );
BOOST_TEST_EQ( _7( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 7 );
BOOST_TEST_EQ( _8( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 8 );
return boost::report_errors();
}

79
test/project.cpp Normal file
View File

@@ -0,0 +1,79 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/lambda2.hpp>
#include <boost/core/lightweight_test.hpp>
#include <utility>
struct X
{
int m1;
int m2;
int f1() const
{
return m1;
}
int& f2()
{
return m2;
}
};
int main()
{
using namespace boost::lambda2;
{
X const x{ 1, 2 };
BOOST_TEST_EQ( (_1->*&X::m1)( x ), 1 );
BOOST_TEST_EQ( (_1->*&X::m2)( x ), 2 );
BOOST_TEST_EQ( (_1->*&X::f1)( x ), 1 );
}
{
X x{ 0, 0 };
BOOST_TEST_EQ( (_1->*&X::m1)( x ), 0 );
BOOST_TEST_EQ( (_1->*&X::m2)( x ), 0 );
BOOST_TEST_EQ( (_1->*&X::f1)( x ), 0 );
BOOST_TEST_EQ( (_1->*&X::f2)( x ), 0 );
#if defined(_LIBCPP_VERSION)
// https://bugs.llvm.org/show_bug.cgi?id=51753
using std::placeholders::_1;
#endif
BOOST_TEST_EQ( (_1->*&X::m1 += 1)( x ), 1 );
BOOST_TEST_EQ( (_1->*&X::m2 += 2)( x ), 2 );
BOOST_TEST_EQ( (_1->*&X::f1)( x ), 1 );
BOOST_TEST_EQ( (_1->*&X::f2)( x ), 2 );
BOOST_TEST_EQ( (_1->*&X::f2 += 3)( x ), 5 );
}
{
std::pair<int, int> const x( 1, 2 );
BOOST_TEST_EQ( (_1->*&std::pair<int, int>::first)( x ), 1 );
BOOST_TEST_EQ( (_1->*&std::pair<int, int>::second)( x ), 2 );
#if defined(_LIBCPP_VERSION)
// https://bugs.llvm.org/show_bug.cgi?id=51753
using std::placeholders::_1;
#endif
BOOST_TEST_EQ( (_1->*first)( x ), 1 );
BOOST_TEST_EQ( (_1->*second)( x ), 2 );
}
return boost::report_errors();
}

View File

@@ -1,15 +1,11 @@
// Copyright 2020 Peter Dimov
// Copyright 2020, 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/lambda2.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
using namespace boost::lambda2;
BOOST_TEST_EQ( (_1 + _2 * _3)( 1, 2, 3), 1 + 2 * 3 );
return boost::report_errors();
return (_1 + _2 * _3)( 1, 2, 3) == 1 + 2 * 3? 0: 1;
}

42
test/stream_extract.cpp Normal file
View File

@@ -0,0 +1,42 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/lambda2.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <string>
template<class T> T from_string_1( std::string const& s )
{
using namespace boost::lambda2;
std::istringstream is( s );
T t{};
( std::ref( is ) >> _1 )( t );
return t;
}
template<class T> T from_string_2( std::string const& s )
{
using namespace boost::lambda2;
std::istringstream is( s );
T t{};
( is >> _1 )( t );
return t;
}
int main()
{
BOOST_TEST_EQ( from_string_1<int>( "123" ), 123 );
BOOST_TEST_EQ( from_string_2<int>( "456" ), 456 );
return boost::report_errors();
}

38
test/stream_insert.cpp Normal file
View File

@@ -0,0 +1,38 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/lambda2.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <string>
template<class T> std::string to_string_1( T const& t )
{
using namespace boost::lambda2;
std::ostringstream os;
( std::ref( os ) << _1 )( t );
return os.str();
}
template<class T> std::string to_string_2( T const& t )
{
using namespace boost::lambda2;
std::ostringstream os;
( os << _1 )( t );
return os.str();
}
int main()
{
BOOST_TEST_EQ( to_string_1( 123 ), "123" );
BOOST_TEST_EQ( to_string_2( 456 ), "456" );
return boost::report_errors();
}

27
test/subscript.cpp Normal file
View File

@@ -0,0 +1,27 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/lambda2.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
int main()
{
using namespace boost::lambda2;
int x[] = { 1, 2, 3, 4 };
BOOST_TEST_EQ( _1[0](x), x[0] );
BOOST_TEST_EQ( _1[_2](x, 1), x[1] );
BOOST_TEST_EQ( (_1[_2] + _3[_4])(x, 2, x, 3), x[2] + x[3] );
BOOST_TEST_EQ( std::bind(_1 + _2, _1[_2], _3[_4])(x, 2, x, 3), x[2] + x[3] );
_1[0](x) = 7;
BOOST_TEST_EQ( x[0], 7 );
_1[_2](x, 1) = 8;
BOOST_TEST_EQ( x[1], 8 );
return boost::report_errors();
}