From 094206a08d61b14abb2d6d28e6c59e0d316efc55 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 24 Mar 2023 11:58:56 +0200 Subject: [PATCH] Make mp_rename, mp_apply, mp_apply_q SFINAE-friendly --- include/boost/mp11/detail/mp_rename.hpp | 5 ++- test/Jamfile | 1 + test/mp_apply_q_sf.cpp | 49 +++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 test/mp_apply_q_sf.cpp diff --git a/include/boost/mp11/detail/mp_rename.hpp b/include/boost/mp11/detail/mp_rename.hpp index 8368ac6..5af6fc4 100644 --- a/include/boost/mp11/detail/mp_rename.hpp +++ b/include/boost/mp11/detail/mp_rename.hpp @@ -8,6 +8,8 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt +#include + namespace boost { namespace mp11 @@ -22,9 +24,8 @@ template class B> struct mp_rename_impl // An error "no type named 'type'" here means that the first argument to mp_rename is not a list }; -template class A, class... T, template class B> struct mp_rename_impl, B> +template class A, class... T, template class B> struct mp_rename_impl, B>: mp_defer { - using type = B; }; } // namespace detail diff --git a/test/Jamfile b/test/Jamfile index 28ce8e9..8c8f683 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -41,6 +41,7 @@ run mp_replace_front.cpp ; run mp_replace_second.cpp ; run mp_replace_third.cpp ; run mp_apply_q.cpp ; +run mp_apply_q_sf.cpp ; run mp_is_list.cpp ; run mp_list_c.cpp ; run mp_transform_front.cpp ; diff --git a/test/mp_apply_q_sf.cpp b/test/mp_apply_q_sf.cpp new file mode 100644 index 0000000..d30ce21 --- /dev/null +++ b/test/mp_apply_q_sf.cpp @@ -0,0 +1,49 @@ +// Copyright 2015, 2017, 2023 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include + +using boost::mp11::mp_apply_q; +using boost::mp11::mp_list; +using boost::mp11::mp_quote; +using boost::mp11::mp_quote_trait; +using boost::mp11::mp_valid; +using boost::mp11::mp_identity; +using boost::mp11::mp_identity_t; + +int main() +{ + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) + + BOOST_TEST_TRAIT_FALSE((mp_valid)); + + BOOST_TEST_TRAIT_FALSE((mp_valid>)); + BOOST_TEST_TRAIT_FALSE((mp_valid>)); + BOOST_TEST_TRAIT_FALSE((mp_valid>)); + +#endif + + using Qi = mp_quote; + + BOOST_TEST_TRAIT_FALSE((mp_valid>)); + BOOST_TEST_TRAIT_TRUE((mp_valid>)); + BOOST_TEST_TRAIT_FALSE((mp_valid>)); + + using Qt = mp_quote_trait; + +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) + BOOST_TEST_TRAIT_FALSE((mp_valid>)); +#endif + BOOST_TEST_TRAIT_TRUE((mp_valid>)); + BOOST_TEST_TRAIT_FALSE((mp_valid>)); + + return boost::report_errors(); +}