mirror of
https://github.com/boostorg/lambda2.git
synced 2026-01-19 16:22:20 +00:00
Compare commits
38 Commits
boost-1.77
...
boost-1.85
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a17ffc25d3 | ||
|
|
2c8de60398 | ||
|
|
62815a69bf | ||
|
|
247f6b7b58 | ||
|
|
2935343723 | ||
|
|
8ac931161b | ||
|
|
3ba6ab955e | ||
|
|
4b68743cf0 | ||
|
|
3f43588316 | ||
|
|
20420e134f | ||
|
|
7824b74a27 | ||
|
|
d72468479f | ||
|
|
b55fdcb9fa | ||
|
|
fd1a3e4543 | ||
|
|
8c6c1166c4 | ||
|
|
c618d6902b | ||
|
|
ae42ebda76 | ||
|
|
3ccd5c251b | ||
|
|
132db3b09a | ||
|
|
253aef863f | ||
|
|
a593616a98 | ||
|
|
2ff3fef3d1 | ||
|
|
0572e42219 | ||
|
|
7c39436198 | ||
|
|
f8b3099259 | ||
|
|
a666ac4fb6 | ||
|
|
d57e7e1618 | ||
|
|
d7a1fccc89 | ||
|
|
0c1898100a | ||
|
|
e6a538a98e | ||
|
|
08b40af530 | ||
|
|
d6389b60f5 | ||
|
|
f2ab3ade7c | ||
|
|
e2251ab450 | ||
|
|
3a06c98e8d | ||
|
|
8b08326f6e | ||
|
|
b9cc0aa5d1 | ||
|
|
58c947fcf9 |
494
.github/workflows/ci.yml
vendored
494
.github/workflows/ci.yml
vendored
@@ -17,86 +17,71 @@ 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
|
||||
os: ubuntu-20.04
|
||||
install: g++-7
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install: g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install: g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.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
|
||||
- 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:23.04
|
||||
os: ubuntu-latest
|
||||
install: g++-13
|
||||
- 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
|
||||
os: ubuntu-20.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
@@ -120,18 +105,65 @@ jobs:
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
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:23.04
|
||||
os: ubuntu-latest
|
||||
install: clang-16
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
container: ubuntu:23.10
|
||||
os: ubuntu-latest
|
||||
install: clang-17
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
os: macos-11
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-12
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python3 git g++
|
||||
|
||||
- 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 +183,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,14 +202,22 @@ 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
|
||||
@@ -186,7 +226,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@@ -214,4 +254,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-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- 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-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- 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-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- 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-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- 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-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- 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-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- 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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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[]
|
||||
|
||||
|
||||
16
doc/lambda2/changelog.adoc
Normal file
16
doc/lambda2/changelog.adoc
Normal 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`.
|
||||
@@ -66,7 +66,7 @@ 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://github.com/boostorg/lambda2/actions[Github Actions] and
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace lambda2 {
|
||||
template<int I> struct lambda2_arg;
|
||||
|
||||
inline constexpr lambda2_arg<1> _1{};
|
||||
inline constexpr lambda2_arg<1> _2{};
|
||||
inline constexpr lambda2_arg<1> _3{};
|
||||
inline constexpr lambda2_arg<1> _4{};
|
||||
inline constexpr lambda2_arg<1> _5{};
|
||||
inline constexpr lambda2_arg<1> _6{};
|
||||
inline constexpr lambda2_arg<1> _7{};
|
||||
inline constexpr lambda2_arg<1> _8{};
|
||||
inline constexpr lambda2_arg<1> _9{};
|
||||
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
|
||||
|
||||
@@ -86,6 +86,15 @@ 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
|
||||
```
|
||||
@@ -388,3 +397,39 @@ template<class A, class B> auto operator@=( A && a, B && b );
|
||||
+
|
||||
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' );
|
||||
}
|
||||
```
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
#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 108500
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -31,6 +32,14 @@ struct subscript
|
||||
}
|
||||
};
|
||||
|
||||
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
|
||||
@@ -64,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
|
||||
@@ -151,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) \
|
||||
@@ -201,9 +217,6 @@ 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)
|
||||
|
||||
@@ -226,6 +239,46 @@ 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
|
||||
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
"description": "A C++14 lambda library.",
|
||||
"category": [
|
||||
"Function-objects"
|
||||
]
|
||||
],
|
||||
"cxxstd": "14"
|
||||
}
|
||||
|
||||
11
test/CMakeLists.txt
Normal file
11
test/CMakeLists.txt
Normal 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()
|
||||
@@ -24,3 +24,6 @@ run placeholders.cpp ;
|
||||
run increment.cpp ;
|
||||
run subscript.cpp ;
|
||||
run compound.cpp ;
|
||||
run stream_insert.cpp ;
|
||||
run stream_extract.cpp ;
|
||||
run project.cpp ;
|
||||
|
||||
17
test/cmake_install_test/CMakeLists.txt
Normal file
17
test/cmake_install_test/CMakeLists.txt
Normal 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 COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
17
test/cmake_subdir_test/CMakeLists.txt
Normal file
17
test/cmake_subdir_test/CMakeLists.txt
Normal 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 COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
79
test/project.cpp
Normal file
79
test/project.cpp
Normal 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();
|
||||
}
|
||||
@@ -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
42
test/stream_extract.cpp
Normal 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
38
test/stream_insert.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user