Compare commits

...

7 Commits

Author SHA1 Message Date
Peter Dimov 8c935dc996 Fix unwrap_and_invoke for functions returning void. Fixes #145. 2026-05-31 14:34:01 +03:00
Peter Dimov e6595f0d64 Update .drone.jsonnet 2026-05-01 16:45:55 +03:00
Peter Dimov 48cc883bd3 Add windows-cmake-use to ci.yml 2026-04-30 20:31:59 +03:00
Peter Dimov a66df030ae Add posix-cmake-use to ci.yml 2026-04-30 19:36:42 +03:00
Peter Dimov 04ac86837c Disable -Wformat-truncation in error_category_test(2).cpp under GCC 16 2026-04-30 19:29:54 +03:00
Peter Dimov 080b4e9961 Update ci.yml 2026-04-30 17:06:37 +03:00
Peter Dimov 571076780e Update cmake_install_test/CMakeLists.txt 2026-04-30 17:02:01 +03:00
8 changed files with 270 additions and 96 deletions
+54 -33
View File
@@ -239,19 +239,26 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 25.04 GCC 15 UBSAN",
"cppalliance/droneubuntu2504:1",
"Linux 26.04 GCC 15 UBSAN",
"cppalliance/droneubuntu2604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '11,14,17,20,23,2c' } + ubsan,
"g++-15-multilib",
),
linux_pipeline(
"Linux 25.04 GCC 15 ASAN",
"cppalliance/droneubuntu2504:1",
"Linux 26.04 GCC 15 ASAN",
"cppalliance/droneubuntu2604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '11,14,17,20,23,2c' } + asan,
"g++-15-multilib",
),
linux_pipeline(
"Linux 26.04 GCC 16",
"cppalliance/droneubuntu2604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-16', CXXSTD: '11,14,17,20,23,2c' },
"g++-16-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
@@ -280,6 +287,27 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"clang-3.8",
),
linux_pipeline(
"Linux 18.04 Clang 3.9",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.9', CXXSTD: '11,14' },
"clang-3.9",
),
linux_pipeline(
"Linux 18.04 Clang 4.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-4.0', CXXSTD: '11,14' },
"clang-4.0",
),
linux_pipeline(
"Linux 18.04 Clang 5.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '11,14' },
"clang-5.0",
),
linux_pipeline(
"Linux 22.04 Clang 13",
"cppalliance/droneubuntu2204:1",
@@ -316,54 +344,47 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 24.04 Clang 18 UBSAN",
"Linux 24.04 Clang 18",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + ubsan,
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' },
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 18 ASAN",
"Linux 24.04 Clang 19",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + asan,
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 19 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' } + ubsan,
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' },
"clang-19",
),
linux_pipeline(
"Linux 24.04 Clang 19 ASAN",
"Linux 24.04 Clang 20",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' } + asan,
"clang-19",
),
linux_pipeline(
"Linux 24.04 Clang 20 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,23,2c' } + ubsan,
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,23,2c' },
"clang-20",
),
linux_pipeline(
"Linux 24.04 Clang 20 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,23,2c' } + asan,
"clang-20",
),
linux_pipeline(
"Linux 25.10 Clang 21",
"cppalliance/droneubuntu2510:1",
"Linux 26.04 Clang 21",
"cppalliance/droneubuntu2604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '11,14,17,20,23,2c' },
"clang-21",
),
linux_pipeline(
"Linux 26.04 Clang 22 UBSAN",
"cppalliance/droneubuntu2604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-22', CXXSTD: '11,14,17,20,23,2c' } + ubsan,
"clang-22",
),
linux_pipeline(
"Linux 26.04 Clang 22 ASAN",
"cppalliance/droneubuntu2604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-22', CXXSTD: '11,14,17,20,23,2c' } + asan,
"clang-22",
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
+140 -60
View File
@@ -17,25 +17,11 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
cxxstd: "11"
container: ubuntu:18.04
os: ubuntu-latest
install: g++-4.8
- toolset: gcc-5
cxxstd: "11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
install: g++-5
- toolset: gcc-6
cxxstd: "11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
install: g++-6
- toolset: gcc-7
cxxstd: "11,14,17"
container: ubuntu:18.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-7
- toolset: gcc-8
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
@@ -52,10 +38,12 @@ jobs:
install: g++-10
- toolset: gcc-11
cxxstd: "11,14,17,2a"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
- toolset: gcc-12
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
container: ubuntu:22.04
os: ubuntu-latest
install: g++-12
- toolset: gcc-13
cxxstd: "11,14,17,20,2b"
@@ -69,27 +57,14 @@ jobs:
install: g++-14
- toolset: gcc-15
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:25.04
container: ubuntu:26.04
os: ubuntu-latest
install: g++-15
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
container: ubuntu:18.04
- toolset: gcc-16
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:26.04
os: ubuntu-latest
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
container: ubuntu:18.04
os: ubuntu-latest
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
install: clang-5.0
install: g++-16
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
@@ -198,9 +173,16 @@ jobs:
compiler: clang++-21
cxxstd: "11,14,17,20,23,2c"
stdlib: "native,libc++"
container: ubuntu:25.10
container: ubuntu:26.04
os: ubuntu-latest
install: clang-21 libc++-21-dev libc++abi-21-dev
- toolset: clang
compiler: clang++-22
cxxstd: "11,14,17,20,23,2c"
stdlib: "native,libc++"
container: ubuntu:26.04
os: ubuntu-latest
install: clang-22 libc++-22-dev libc++abi-22-dev
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-14
@@ -212,12 +194,7 @@ jobs:
os: macos-26
runs-on: ${{matrix.os}}
container:
image: ${{matrix.container}}
volumes:
- /node20217:/node20217:rw,rshared
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
container: ${{matrix.container}}
defaults:
run:
@@ -230,14 +207,7 @@ jobs:
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
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
@@ -286,19 +256,23 @@ jobs:
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: msvc-14.5
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2025-vs2026
- toolset: clang-win
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
os: windows-latest
- toolset: gcc
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2022
os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
@@ -339,7 +313,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
@@ -384,7 +358,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
@@ -439,7 +413,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
@@ -481,6 +455,57 @@ jobs:
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error
posix-cmake-use:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Install Boost --with-library
run: |
cd ../boost-root
./b2 -j3 --with-$LIBRARY --prefix=$HOME/.local 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
windows-cmake-subdir:
strategy:
fail-fast: false
@@ -491,7 +516,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
@@ -539,7 +564,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
@@ -605,7 +630,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
@@ -657,3 +682,58 @@ jobs:
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-use:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Install Boost --with-library
shell: cmd
run: |
cd ../boost-root
b2 -j3 --with-%LIBRARY% install
- name: Use the installed library (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DBoost_ROOT=C:/Boost ..
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
+24 -1
View File
@@ -66,7 +66,8 @@ template<class R, class T, class E> int invoke_test( R& r, result<T, E> const& r
template<class F, class... A,
class R = decltype( compat::invoke( std::declval<F>(), detail::invoke_unwrap( std::declval<A>() )... ) ),
class E = detail::get_error_type<compat::remove_cvref_t<A>...>
class E = detail::get_error_type<compat::remove_cvref_t<A>...>,
class En = typename std::enable_if< !std::is_void<R>::value >::type
>
auto unwrap_and_invoke( F&& f, A&&... a ) -> result<R, E>
{
@@ -82,6 +83,28 @@ auto unwrap_and_invoke( F&& f, A&&... a ) -> result<R, E>
return compat::invoke( std::forward<F>(f), detail::invoke_unwrap( std::forward<A>(a) )... );
}
template<class F, class... A,
class R = decltype( compat::invoke( std::declval<F>(), detail::invoke_unwrap( std::declval<A>() )... ) ),
class E = detail::get_error_type<compat::remove_cvref_t<A>...>,
class En1 = void,
class En2 = typename std::enable_if< std::is_void<R>::value >::type
>
auto unwrap_and_invoke( F&& f, A&&... a ) -> result<R, E>
{
{
result<void, E> r;
using Q = int[];
(void)Q{ detail::invoke_test( r, a )... };
if( !r ) return r.error();
}
compat::invoke( std::forward<F>(f), detail::invoke_unwrap( std::forward<A>(a) )... );
return {};
}
// unwrap_and_construct
namespace detail
+2
View File
@@ -228,3 +228,5 @@ run unwrap_and_construct.cpp ;
run unwrap_and_construct2.cpp ;
run detail_is_aggregate_test.cpp ;
run unwrap_and_invoke3.cpp ;
+2 -2
View File
@@ -2,11 +2,11 @@
# 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)
cmake_minimum_required(VERSION 3.5...3.31)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_system REQUIRED)
find_package(Boost COMPONENTS system REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main Boost::system)
+4
View File
@@ -8,6 +8,10 @@
// See library home page at http://www.boost.org/libs/system
#if defined(__GNUC__) && __GNUC__ >= 16
# pragma GCC diagnostic ignored "-Wformat-truncation"
#endif
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/snprintf.hpp>
+4
View File
@@ -8,6 +8,10 @@
// See library home page at http://www.boost.org/libs/system
#if defined(__GNUC__) && __GNUC__ >= 16
# pragma GCC diagnostic ignored "-Wformat-truncation"
#endif
#include <boost/system/error_category.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/snprintf.hpp>
+40
View File
@@ -0,0 +1,40 @@
// Copyright 2026 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/unwrap_and_invoke.hpp>
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::system;
int g_x;
void f( int x )
{
g_x += x;
}
int main()
{
{
g_x = 0;
result<int> a1( 1 );
result<void> r = unwrap_and_invoke( f, a1 );
BOOST_TEST( r );
BOOST_TEST_EQ( g_x, 1 );
}
{
auto ec = make_error_code( errc::invalid_argument );
result<int> a1( ec );
result<void> r = unwrap_and_invoke( f, a1 );
BOOST_TEST( r.has_error() ) && BOOST_TEST_EQ( r.error(), ec );
}
return boost::report_errors();
}