1
0
forked from boostorg/mp11

Make mp_infoke SFINAE-friendly

This commit is contained in:
Peter Dimov
2017-05-19 15:37:49 +03:00
parent 1d1be2bbf4
commit 7100d10c7e
3 changed files with 44 additions and 5 deletions

View File

@@ -116,19 +116,24 @@ template<template<class...> class F> struct mp_quote
template<class... T> using fn = typename mp_defer<F, T...>::type;
};
// mp_unquote
// mp_invoke
#if BOOST_WORKAROUND( BOOST_MSVC, < 1900 )
namespace detail
{
template<class Q, class... T> struct mp_invoke_impl
{
using type = typename Q::template fn<T...>;
};
template<class Q, class... T> struct mp_invoke_impl: mp_defer<Q::template fn, T...> {};
} // namespace detail
template<class Q, class... T> using mp_invoke = typename detail::mp_invoke_impl<Q, T...>::type;
#else
template<class Q, class... T> using mp_invoke = typename Q::template fn<T...>;
#endif
} // namespace mp11
} // namespace boost

View File

@@ -83,6 +83,7 @@ run mp_valid.cpp : : : $(REQ) ;
run mp_defer.cpp : : : $(REQ) ;
run mp_quote.cpp : : : $(REQ) ;
run mp_invoke.cpp : : : $(REQ) ;
run mp_invoke_sf.cpp : : : $(REQ) ;
# integer_sequence
run integer_sequence.cpp : : : $(REQ) ;

33
test/mp_invoke_sf.cpp Normal file
View File

@@ -0,0 +1,33 @@
// Copyright 2015, 2017 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/mp11/utility.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
using boost::mp11::mp_invoke;
using boost::mp11::mp_quote;
using boost::mp11::mp_valid;
using boost::mp11::mp_identity_t;
int main()
{
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke>));
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, void>));
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, void, void>));
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, void, void, void>));
using Qi = mp_quote<mp_identity_t>;
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, Qi>));
BOOST_TEST_TRAIT_TRUE((mp_valid<mp_invoke, Qi, void>));
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_invoke, Qi, void, void>));
return boost::report_errors();
}