forked from boostorg/mp11
Make mp_rename, mp_apply, mp_apply_q SFINAE-friendly
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/mp11/detail/mp_defer.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace mp11
|
||||
@@ -22,9 +24,8 @@ template<class A, template<class...> 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<template<class...> class A, class... T, template<class...> class B> struct mp_rename_impl<A<T...>, B>
|
||||
template<template<class...> class A, class... T, template<class...> class B> struct mp_rename_impl<A<T...>, B>: mp_defer<B, T...>
|
||||
{
|
||||
using type = B<T...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
@@ -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 ;
|
||||
|
49
test/mp_apply_q_sf.cpp
Normal file
49
test/mp_apply_q_sf.cpp
Normal file
@@ -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 <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/utility.hpp>
|
||||
#include <boost/mp11/detail/config.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
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<mp_apply_q>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, void>));
|
||||
|
||||
#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 )
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, void, void>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, void, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, void, mp_list<void>>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, void, mp_list<void, void>>));
|
||||
|
||||
#endif
|
||||
|
||||
using Qi = mp_quote<mp_identity_t>;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, Qi, mp_list<>>));
|
||||
BOOST_TEST_TRAIT_TRUE((mp_valid<mp_apply_q, Qi, mp_list<void>>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, Qi, mp_list<void, void>>));
|
||||
|
||||
using Qt = mp_quote_trait<mp_identity>;
|
||||
|
||||
#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 )
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, Qt, mp_list<>>));
|
||||
#endif
|
||||
BOOST_TEST_TRAIT_TRUE((mp_valid<mp_apply_q, Qt, mp_list<void>>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_apply_q, Qt, mp_list<void, void>>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user