forked from boostorg/mp11
Add value list support to mp_fill. Refs #53.
This commit is contained in:
@@ -199,7 +199,10 @@ template<class Q, class... L> using mp_filter_q = typename detail::mp_filter_imp
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class L, class V> struct mp_fill_impl;
|
template<class L, class V> struct mp_fill_impl
|
||||||
|
{
|
||||||
|
// An error "no type named 'type'" here means that the L argument of mp_fill is not a list
|
||||||
|
};
|
||||||
|
|
||||||
template<template<class...> class L, class... T, class V> struct mp_fill_impl<L<T...>, V>
|
template<template<class...> class L, class... T, class V> struct mp_fill_impl<L<T...>, V>
|
||||||
{
|
{
|
||||||
@@ -216,6 +219,15 @@ template<template<class...> class L, class... T, class V> struct mp_fill_impl<L<
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
|
||||||
|
|
||||||
|
template<template<auto...> class L, auto... A, class V> struct mp_fill_impl<L<A...>, V>
|
||||||
|
{
|
||||||
|
using type = L<((void)A, V::value)...>;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<class L, class V> using mp_fill = typename detail::mp_fill_impl<L, V>::type;
|
template<class L, class V> using mp_fill = typename detail::mp_fill_impl<L, V>::type;
|
||||||
|
@@ -79,6 +79,7 @@ run mp_transform_if.cpp ;
|
|||||||
run mp_transform_if_q.cpp ;
|
run mp_transform_if_q.cpp ;
|
||||||
run mp_filter.cpp ;
|
run mp_filter.cpp ;
|
||||||
run mp_fill.cpp ;
|
run mp_fill.cpp ;
|
||||||
|
run mp_fill_2.cpp ;
|
||||||
run mp_count.cpp ;
|
run mp_count.cpp ;
|
||||||
run mp_count_if.cpp ;
|
run mp_count_if.cpp ;
|
||||||
run mp_count_if_q.cpp ;
|
run mp_count_if_q.cpp ;
|
||||||
|
40
test/mp_fill_2.cpp
Normal file
40
test/mp_fill_2.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Copyright 2023 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/mp11/algorithm.hpp>
|
||||||
|
#include <boost/mp11/integral.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
|
||||||
|
|
||||||
|
#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined")
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
template<auto... A> struct V1 {};
|
||||||
|
template<int... I> struct V2 {};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using boost::mp11::mp_fill;
|
||||||
|
using boost::mp11::mp_int;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V1<>, mp_int<-1>>, V1<>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V1<false>, mp_int<-1>>, V1<-1>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V1<false, 0>, mp_int<-1>>, V1<-1, -1>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V1<false, 0, true>, mp_int<-1>>, V1<-1, -1, -1>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V1<false, 0, true, std::size_t(1)>, mp_int<-1>>, V1<-1, -1, -1, -1>);
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V2<>, mp_int<-1>>, V2<>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V2<0>, mp_int<-1>>, V2<-1>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V2<0, 1>, mp_int<-1>>, V2<-1, -1>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V2<0, 1, 2>, mp_int<-1>>, V2<-1, -1, -1>);
|
||||||
|
BOOST_TEST_TRAIT_SAME(mp_fill<V2<0, 1, 2, 3>, mp_int<-1>>, V2<-1, -1, -1, -1>);
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user