diff --git a/include/boost/mp11/list.hpp b/include/boost/mp11/list.hpp index 0189d74..4075d31 100644 --- a/include/boost/mp11/list.hpp +++ b/include/boost/mp11/list.hpp @@ -157,6 +157,15 @@ template class L, class T1, class T2, class... T> struct mp_s using type = T2; }; +#if defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +template class L, auto A1, auto A2, auto... A> struct mp_second_impl> +{ + using type = mp_value; +}; + +#endif + } // namespace detail template using mp_second = typename detail::mp_second_impl::type; @@ -176,6 +185,15 @@ template class L, class T1, class T2, class T3, class... T> s using type = T3; }; +#if defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +template class L, auto A1, auto A2, auto A3, auto... A> struct mp_third_impl> +{ + using type = mp_value; +}; + +#endif + } // namespace detail template using mp_third = typename detail::mp_third_impl::type; diff --git a/test/Jamfile b/test/Jamfile index 4c9b626..4c12162 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -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 ; diff --git a/test/mp_second_2.cpp b/test/mp_second_2.cpp new file mode 100644 index 0000000..8f1b332 --- /dev/null +++ b/test/mp_second_2.cpp @@ -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 + +#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined") +int main() {} + +#else + +#include +#include + +template struct L1 {}; +template 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>, mp_true); + BOOST_TEST_TRAIT_SAME(mp_second>, mp_int<1>); + + return boost::report_errors(); +} + +#endif diff --git a/test/mp_third_2.cpp b/test/mp_third_2.cpp new file mode 100644 index 0000000..e4f913e --- /dev/null +++ b/test/mp_third_2.cpp @@ -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 + +#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined") +int main() {} + +#else + +#include +#include + +template struct L1 {}; +template 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>, mp_false); + BOOST_TEST_TRAIT_SAME(mp_third>, mp_int<2>); + + return boost::report_errors(); +} + +#endif