forked from boostorg/variant2
Compare commits
7 Commits
boost-1.75
...
feature/gc
Author | SHA1 | Date | |
---|---|---|---|
a3d35e61fe | |||
84a2c175d0 | |||
ea3268feb4 | |||
efc1d5acca | |||
c6186e0a95 | |||
24ccee2104 | |||
93b8618e94 |
201
.github/workflows/ci.yml
vendored
Normal file
201
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
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
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11,14"
|
||||
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: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- 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
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Create user-config.jam
|
||||
if: matrix.compiler
|
||||
run: |
|
||||
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
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"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- 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: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
|
@ -504,11 +504,23 @@ using std::is_trivially_move_assignable;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 40800
|
||||
|
||||
template<class T> struct is_trivially_destructible: std::has_trivial_destructor<T>
|
||||
{
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
using std::is_trivially_destructible;
|
||||
|
||||
#endif
|
||||
|
||||
// variant_storage
|
||||
|
||||
template<class D, class... T> union variant_storage_impl;
|
||||
|
||||
template<class... T> using variant_storage = variant_storage_impl<mp11::mp_all<std::is_trivially_destructible<T>...>, T...>;
|
||||
template<class... T> using variant_storage = variant_storage_impl<mp11::mp_all<detail::is_trivially_destructible<T>...>, T...>;
|
||||
|
||||
template<class D> union variant_storage_impl<D>
|
||||
{
|
||||
@ -807,7 +819,7 @@ template<class U, class... T> using resolve_overload_index = mp11::mp_find<mp11:
|
||||
// variant_base
|
||||
|
||||
template<bool is_trivially_destructible, bool is_single_buffered, class... T> struct variant_base_impl;
|
||||
template<class... T> using variant_base = variant_base_impl<mp11::mp_all<std::is_trivially_destructible<T>...>::value, mp11::mp_all<std::is_nothrow_move_constructible<T>...>::value, T...>;
|
||||
template<class... T> using variant_base = variant_base_impl<mp11::mp_all<detail::is_trivially_destructible<T>...>::value, mp11::mp_all<std::is_nothrow_move_constructible<T>...>::value, T...>;
|
||||
|
||||
struct none {};
|
||||
|
||||
@ -1317,7 +1329,7 @@ template<bool CopyAssignable, bool TriviallyCopyAssignable, class... T> struct v
|
||||
|
||||
template<class... T> using variant_ca_base = variant_ca_base_impl<
|
||||
mp11::mp_all<std::is_copy_constructible<T>..., std::is_copy_assignable<T>...>::value,
|
||||
mp11::mp_all<std::is_trivially_destructible<T>..., detail::is_trivially_copy_constructible<T>..., detail::is_trivially_copy_assignable<T>...>::value,
|
||||
mp11::mp_all<detail::is_trivially_destructible<T>..., detail::is_trivially_copy_constructible<T>..., detail::is_trivially_copy_assignable<T>...>::value,
|
||||
T...>;
|
||||
|
||||
template<class... T> struct variant_ca_base_impl<true, true, T...>: public variant_cc_base<T...>
|
||||
@ -1466,7 +1478,7 @@ template<bool MoveAssignable, bool TriviallyMoveAssignable, class... T> struct v
|
||||
|
||||
template<class... T> using variant_ma_base = variant_ma_base_impl<
|
||||
mp11::mp_all<std::is_move_constructible<T>..., std::is_move_assignable<T>...>::value,
|
||||
mp11::mp_all<std::is_trivially_destructible<T>..., detail::is_trivially_move_constructible<T>..., detail::is_trivially_move_assignable<T>...>::value,
|
||||
mp11::mp_all<detail::is_trivially_destructible<T>..., detail::is_trivially_move_constructible<T>..., detail::is_trivially_move_assignable<T>...>::value,
|
||||
T...>;
|
||||
|
||||
template<class... T> struct variant_ma_base_impl<true, true, T...>: public variant_mc_base<T...>
|
||||
@ -2085,7 +2097,7 @@ template<class R, class F, class V1, class V2> struct visit_L2
|
||||
template<class I> auto operator()( I ) const -> Vret<R, F, V1, V2>
|
||||
{
|
||||
auto f2 = bind_front( std::forward<F>(f), unsafe_get<I::value>( std::forward<V1>(v1) ) );
|
||||
return visit<R>( f2, std::forward<V2>(v2) );
|
||||
return visit<R>( f2, std::forward<V2>(v2) );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5,10 +5,11 @@
|
||||
"Peter Dimov"
|
||||
],
|
||||
"maintainers": [
|
||||
"Peter Dimov <pdimov -at- pdimov.com>"
|
||||
"Peter Dimov <pdimov -at- gmail.com>"
|
||||
],
|
||||
"description": "A never-valueless, strong guarantee implementation of std::variant.",
|
||||
"category": [
|
||||
"Containers", "Data"
|
||||
]
|
||||
],
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
@ -115,4 +115,7 @@ run variant_visit_derived.cpp ;
|
||||
|
||||
run variant_many_types.cpp ;
|
||||
|
||||
run variant_visit_r.cpp ;
|
||||
run variant_visit_r.cpp : : :
|
||||
<toolset>gcc,<target-os>windows:<variant>release
|
||||
<toolset>gcc,<target-os>cygwin:<variant>release
|
||||
;
|
||||
|
@ -57,6 +57,60 @@ STATIC_ASSERT( !std::is_nothrow_move_constructible<X2>::value );
|
||||
STATIC_ASSERT( !std::is_nothrow_copy_assignable<X2>::value );
|
||||
STATIC_ASSERT( !std::is_nothrow_move_assignable<X2>::value );
|
||||
|
||||
struct Y1
|
||||
{
|
||||
int v = 1;
|
||||
|
||||
Y1() = default;
|
||||
Y1(Y1 const&) = delete;
|
||||
Y1(Y1&&) = delete;
|
||||
};
|
||||
|
||||
STATIC_ASSERT( !std::is_copy_constructible<Y1>::value );
|
||||
STATIC_ASSERT( !std::is_move_constructible<Y1>::value );
|
||||
|
||||
struct Y2
|
||||
{
|
||||
int v = 2;
|
||||
|
||||
Y2() = default;
|
||||
Y2(Y2 const&) = delete;
|
||||
Y2(Y2&&) = delete;
|
||||
};
|
||||
|
||||
STATIC_ASSERT( !std::is_copy_constructible<Y2>::value );
|
||||
STATIC_ASSERT( !std::is_move_constructible<Y2>::value );
|
||||
|
||||
struct Z1
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v = 1;
|
||||
|
||||
Z1() { ++instances; }
|
||||
~Z1() { --instances; }
|
||||
|
||||
Z1(Z1 const&) = delete;
|
||||
Z1(Z1&&) = delete;
|
||||
};
|
||||
|
||||
int Z1::instances = 0;
|
||||
|
||||
struct Z2
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v = 2;
|
||||
|
||||
Z2() { ++instances; }
|
||||
~Z2() { --instances; }
|
||||
|
||||
Z2(Z2 const&) = delete;
|
||||
Z2(Z2&&) = delete;
|
||||
};
|
||||
|
||||
int Z2::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -177,5 +231,62 @@ int main()
|
||||
BOOST_TEST_EQ( get<0>(v).v, 4 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<Y1, Y2> v;
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
variant<Z1, Z2> v;
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
BOOST_TEST_EQ( Z1::instances, 1 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
BOOST_TEST_EQ( Z1::instances, 1 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
BOOST_TEST_EQ( Z1::instances, 0 );
|
||||
BOOST_TEST_EQ( Z2::instances, 1 );
|
||||
|
||||
v.emplace<1>();
|
||||
BOOST_TEST_EQ( v.index(), 1 );
|
||||
BOOST_TEST_EQ( get<1>(v).v, 2 );
|
||||
BOOST_TEST_EQ( Z1::instances, 0 );
|
||||
BOOST_TEST_EQ( Z2::instances, 1 );
|
||||
|
||||
v.emplace<0>();
|
||||
BOOST_TEST_EQ( v.index(), 0 );
|
||||
BOOST_TEST_EQ( get<0>(v).v, 1 );
|
||||
BOOST_TEST_EQ( Z1::instances, 1 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( Z1::instances, 0 );
|
||||
BOOST_TEST_EQ( Z2::instances, 0 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user