2
0
mirror of https://github.com/boostorg/compat.git synced 2026-01-21 04:42:38 +00:00

8 Commits

Author SHA1 Message Date
Peter Dimov
e7098ce569 Bump MSVC < 1950 workarounds to < 1960; still unfixed. Sad! 2026-01-20 18:51:03 +02:00
Peter Dimov
96ec9c1b89 Add msvc-14.5 to .drone.jsonnet 2026-01-20 18:44:56 +02:00
Christian Mazakas
945b2862b4 invoke internal storage via reference
This prevents the code from erroneously copying the storage which causes
surprising behavior as noted here:
https://github.com/boostorg/compat/issues/23
2026-01-20 07:30:53 -08:00
Christian Mazakas
fbad5e0834 add test for in-place mutation of SBO-stored callables 2026-01-20 07:30:25 -08:00
Peter Dimov
7ce75ac955 Update ci.yml 2026-01-16 02:16:52 +02:00
Peter Dimov
0776d62a95 Update documentation 2025-11-18 14:33:45 +02:00
Peter Dimov
904b80b8a1 Move nontype.hpp to detail 2025-11-18 14:33:45 +02:00
Peter Dimov
ffaadc079d Update .drone.jsonnet 2025-11-18 12:06:25 +02:00
14 changed files with 107 additions and 59 deletions

View File

@@ -34,7 +34,6 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
'set -e',
'uname -a',
'echo $DRONE_STAGE_MACHINE',
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
] +
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
@@ -160,31 +159,24 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 24.04 GCC 14 32 ASAN",
"Linux 24.04 GCC 14 32/64 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan,
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' } + asan,
"g++-14-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 14 64 ASAN",
"Linux 24.04 GCC 14 32/64 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + asan,
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' } + ubsan,
"g++-14-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 14 32 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan,
"g++-14-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 14 64 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan,
"g++-14-multilib",
"Linux 25.10 GCC 15 32/64",
"cppalliance/droneubuntu2510:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '11,14,17,20,23,2c', ADDRMD: '32,64' },
"g++-15-multilib",
),
linux_pipeline(
@@ -202,40 +194,47 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 24.04 Clang 17 UBSAN",
"Linux 24.04 Clang 17",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan,
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' },
"clang-17",
),
linux_pipeline(
"Linux 24.04 Clang 17 ASAN",
"Linux 24.04 Clang 18",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan,
"clang-17",
),
linux_pipeline(
"Linux 24.04 Clang 18 UBSAN",
"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.10 Clang 19",
"cppalliance/droneubuntu2410:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' },
"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,
"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",
{ TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '11,14,17,20,23,2c' },
"clang-21",
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
@@ -258,6 +257,18 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
),
macos_pipeline(
"MacOS 14 Xcode 16.2.0 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
xcode_version = "16.2.0", osx_version = "sonoma", arch = "arm64",
),
macos_pipeline(
"MacOS 14 Xcode 16.2.0 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan,
xcode_version = "16.2.0", osx_version = "sonoma", arch = "arm64",
),
windows_pipeline(
"Windows VS2015 msvc-14.0",
"cppalliance/dronevs2015",
@@ -281,4 +292,10 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"cppalliance/dronevs2022:1",
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
),
windows_pipeline(
"Windows VS2026 msvc-14.5",
"cppalliance/dronevs2026:1",
{ TOOLSET: 'msvc-14.5', CXXSTD: '14,17,20,latest' },
),
]

View File

@@ -183,18 +183,24 @@ jobs:
- toolset: clang
compiler: clang++-20
cxxstd: "03,11,14,17,20,23,2c"
container: ubuntu:25.04
container: ubuntu:24.04
os: ubuntu-latest
install: clang-20
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-13
compiler: clang++-21
cxxstd: "03,11,14,17,20,23,2c"
container: ubuntu:25.10
os: ubuntu-latest
install: clang-21
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-14
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
cxxstd: "03,11,14,17,20,23,2c"
os: macos-15
- toolset: clang
cxxstd: "03,11,14,17,20,23,2c"
os: macos-26
runs-on: ${{matrix.os}}
@@ -321,9 +327,9 @@ jobs:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
- os: macos-26
runs-on: ${{matrix.os}}
@@ -370,9 +376,9 @@ jobs:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
- os: macos-26
runs-on: ${{matrix.os}}
@@ -429,9 +435,9 @@ jobs:
include:
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
- os: macos-26
runs-on: ${{matrix.os}}

View File

@@ -11,7 +11,6 @@ https://www.boost.org/LICENSE_1_0.txt
## Changes in 1.90.0
* Added `to_underlying.hpp` (contributed by Braden Ganetsky.)
* Extracted `nontype_t` to its own public header `nontype.hpp` and added `nontype`.
## Changes in 1.89.0

View File

@@ -39,8 +39,6 @@ for (auto fn : fns) {
## Synopsis
```cpp
#include <boost/compat/nontype.hpp>
namespace boost
{
namespace compat

View File

@@ -12,7 +12,6 @@ include::invoke.adoc[]
include::latch.adoc[]
include::mem_fn.adoc[]
include::move_only_function.adoc[]
include::nontype.adoc[]
include::shared_lock.adoc[]
include::to_array.adoc[]
include::to_underlying.adoc[]

View File

@@ -5,7 +5,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/nontype.hpp>
#include <boost/compat/detail/nontype.hpp>
#include <boost/compat/invoke.hpp>
#include <boost/compat/type_traits.hpp>

View File

@@ -247,7 +247,7 @@ bool is_nullary_arg( F f )
template<bool NoEx, class R, class ...Args>
struct mo_invoke_function_holder
{
static R invoke_function( storage s, Args&&... args) noexcept( NoEx )
static R invoke_function( storage const& s, Args&&... args) noexcept( NoEx )
{
auto f = reinterpret_cast<R(*)( Args... )>( s.pfn_ );
return compat::invoke_r<R>( f, std::forward<Args>( args )... );
@@ -257,7 +257,7 @@ struct mo_invoke_function_holder
template<ref_quals RQ, bool Const, bool NoEx, class F, class R, class ...Args>
struct mo_invoke_object_holder
{
static R invoke_object( storage s, Args&&... args ) noexcept( NoEx )
static R invoke_object( storage const& s, Args&&... args ) noexcept( NoEx )
{
using T = remove_reference_t<F>;
using cv_T = conditional_t<Const, add_const_t<T>, T>;
@@ -274,7 +274,7 @@ struct mo_invoke_object_holder
template<ref_quals RQ, bool Const, bool NoEx, class F, class R, class ...Args>
struct mo_invoke_local_holder
{
static R invoke_local( storage s, Args&&... args ) noexcept( NoEx )
static R invoke_local( storage const& s, Args&&... args ) noexcept( NoEx )
{
using T = remove_reference_t<F>;
using cv_T = conditional_t<Const, add_const_t<T>, T>;
@@ -285,7 +285,7 @@ struct mo_invoke_local_holder
>
>;
return compat::invoke_r<R>( static_cast<cv_ref_T>( *static_cast<cv_T*>( s.addr() ) ), std::forward<Args>( args )... );
return compat::invoke_r<R>( static_cast<cv_ref_T>( *static_cast<cv_T*>( const_cast<storage&>( s ).addr() ) ), std::forward<Args>( args )... );
}
};
@@ -485,9 +485,9 @@ struct move_only_function_base
detail::storage s_;
#if defined(__cpp_noexcept_function_type)
R ( *invoke_ )( detail::storage, Args&&... ) noexcept( NoEx ) = nullptr;
R ( *invoke_ )( detail::storage const&, Args&&... ) noexcept( NoEx ) = nullptr;
#else
R ( *invoke_ )( detail::storage, Args&&... ) = nullptr;
R ( *invoke_ )( detail::storage const&, Args&&... ) = nullptr;
#endif
void ( *manager_ )( op_type, detail::storage&, detail::storage* ) = &manage_empty;
};

View File

@@ -39,7 +39,7 @@ int main()
BOOST_TEST_EQ( boost::compat::bind_back( &X::m, &x )(), -1 );
}
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1950)
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1960)
{
BOOST_TEST_EQ( boost::compat::bind_back( &X::m, Y() )(), -1 );

View File

@@ -39,7 +39,7 @@ int main()
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &x )(), -1 );
}
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1950)
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1960)
{
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, Y() )(), -1 );

View File

@@ -29,7 +29,7 @@ int main()
BOOST_TEST_EQ( boost::compat::invoke( &X::m, &x ), -1 );
}
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1950)
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1960)
{
BOOST_TEST_EQ( boost::compat::invoke( &X::m, Y() ), -1 );

View File

@@ -36,7 +36,7 @@ int main()
#endif
}
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1950)
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1960)
{
constexpr Y y = {};

View File

@@ -13,7 +13,8 @@
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <functional>
#include <array>
#include <cstdint>
#include <memory>
#include <type_traits>
@@ -845,11 +846,39 @@ static void test_conv()
}
}
static void test_mutable_lambda()
{
{
// Within SBO limits.
int captured = 0;
move_only_function<int()> func = [captured]() mutable { return ++captured; };
BOOST_TEST_EQ( func(), 1 );
BOOST_TEST_EQ( func(), 2 );
move_only_function<int()> func2(std::move(func));
BOOST_TEST_EQ( func2(), 3 );
}
{
// Too large for SBO.
std::array<std::uint8_t, 256> captured = {{}};
move_only_function<int()> func = [captured]() mutable { return ++captured[0]; };
BOOST_TEST_EQ( func(), 1 );
BOOST_TEST_EQ( func(), 2 );
move_only_function<int()> func2(std::move(func));
BOOST_TEST_EQ( func2(), 3 );
}
}
int main()
{
test_call();
test_traits();
test_conv();
test_mutable_lambda();
return boost::report_errors();
}

View File

@@ -2,7 +2,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/nontype.hpp>
#include <boost/compat/detail/nontype.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/config/pragma_message.hpp>