Skip to content

Commit

Permalink
Split variant_index_type into separate runs for each variant size
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Dec 22, 2024
1 parent d77d61c commit 010c785
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
11 changes: 9 additions & 2 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,16 @@ compile variant_visit_cx.cpp : [ requires cxx14_constexpr ] ;
compile variant_visit_cx_2.cpp : [ requires cxx14_constexpr ] ;
compile variant_visit_r_cx.cpp : [ requires cxx14_constexpr ] ;

run variant_index_type.cpp : : :
local index-type-reqs =

<variant>release
<toolset>msvc,<address-model>32:<build>no
<toolset>msvc-14.0:<build>no # fails on GHA (only) with "out of heap space"
<toolset>clang,<target-os>linux:<cxxflags>-ftemplate-depth=1024 # for Clang 3.x
;

local list-sizes = 126 127 128 129 254 255 256 257 ;

for local list-size in $(list-sizes)
{
run variant_index_type.cpp : : : $(index-type-reqs) <define>LIST_SIZE=$(list-size) : variant_index_type_$(list-size) ;
}
30 changes: 11 additions & 19 deletions test/variant_index_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ template<std::size_t I> struct W

template<class N> using Wf = W< N::value >;

template<template<class...> class F, std::size_t N> void test_()
template<class L, template<class...> class F> void test()
{
using V = mp_rename< mp_transform<F, mp_iota_c<N>>, boost::variant2::variant >;
using V = mp_rename< mp_transform<F, L>, boost::variant2::variant >;

constexpr std::size_t N = mp_size<L>::value;

using last_type = F<mp_size_t<N-1>>;

Expand All @@ -63,32 +65,22 @@ template<template<class...> class F, std::size_t N> void test_()
}
}

template<template<class...> class F> void test()
{
test_<F, 126>();
test_<F, 127>();
test_<F, 128>();
test_<F, 129>();

test_<F, 254>();
test_<F, 255>();
test_<F, 256>();
test_<F, 257>();
}

int main()
{
constexpr std::size_t N = LIST_SIZE;
using L = mp_iota_c<N>;

static_assert( !boost::variant2::variant< X<0>, X<1> >::uses_double_storage(), "" );
test<Xf>();
test<L, Xf>();

static_assert( boost::variant2::variant< Y<0>, Y<1> >::uses_double_storage(), "" );
test<Yf>();
test<L, Yf>();

static_assert( !boost::variant2::variant< Z<0>, Z<1> >::uses_double_storage(), "" );
test<Zf>();
test<L, Zf>();

static_assert( boost::variant2::variant< W<0>, W<1> >::uses_double_storage(), "" );
test<Wf>();
test<L, Wf>();

return boost::report_errors();
}

0 comments on commit 010c785

Please sign in to comment.