forked from boostorg/mp11
Add value list support to mp_second, mp_third. Refs #53.
This commit is contained in:
@@ -157,6 +157,15 @@ template<template<class...> class L, class T1, class T2, class... T> struct mp_s
|
||||
using type = T2;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
|
||||
|
||||
template<template<auto...> class L, auto A1, auto A2, auto... A> struct mp_second_impl<L<A1, A2, A...>>
|
||||
{
|
||||
using type = mp_value<A2>;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L> using mp_second = typename detail::mp_second_impl<L>::type;
|
||||
@@ -176,6 +185,15 @@ template<template<class...> class L, class T1, class T2, class T3, class... T> s
|
||||
using type = T3;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
|
||||
|
||||
template<template<auto...> class L, auto A1, auto A2, auto A3, auto... A> struct mp_third_impl<L<A1, A2, A3, A...>>
|
||||
{
|
||||
using type = mp_value<A3>;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class L> using mp_third = typename detail::mp_third_impl<L>::type;
|
||||
|
@@ -38,7 +38,9 @@ run mp_front_2.cpp ;
|
||||
run mp_pop_front.cpp ;
|
||||
run mp_pop_front_2.cpp ;
|
||||
run mp_second.cpp ;
|
||||
run mp_second_2.cpp ;
|
||||
run mp_third.cpp ;
|
||||
run mp_third_2.cpp ;
|
||||
run mp_push_front.cpp ;
|
||||
run mp_push_back.cpp ;
|
||||
run mp_rename.cpp ;
|
||||
|
32
test/mp_second_2.cpp
Normal file
32
test/mp_second_2.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/mp11/list.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/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<auto... A> struct L1 {};
|
||||
template<int... I> struct L2 {};
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_second;
|
||||
using boost::mp11::mp_true;
|
||||
using boost::mp11::mp_int;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_second<L1<-1, true>>, mp_true);
|
||||
BOOST_TEST_TRAIT_SAME(mp_second<L2<0, 1>>, mp_int<1>);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
32
test/mp_third_2.cpp
Normal file
32
test/mp_third_2.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/mp11/list.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/mp11/integral.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<auto... A> struct L1 {};
|
||||
template<int... I> struct L2 {};
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_third;
|
||||
using boost::mp11::mp_false;
|
||||
using boost::mp11::mp_int;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_third<L1<-1, true, false>>, mp_false);
|
||||
BOOST_TEST_TRAIT_SAME(mp_third<L2<0, 1, 2>>, mp_int<2>);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user