forked from boostorg/mp11
Make mp_infoke SFINAE-friendly
This commit is contained in:
@@ -116,19 +116,24 @@ template<template<class...> class F> struct mp_quote
|
|||||||
template<class... T> using fn = typename mp_defer<F, T...>::type;
|
template<class... T> using fn = typename mp_defer<F, T...>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// mp_unquote
|
// mp_invoke
|
||||||
|
#if BOOST_WORKAROUND( BOOST_MSVC, < 1900 )
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class Q, class... T> struct mp_invoke_impl
|
template<class Q, class... T> struct mp_invoke_impl: mp_defer<Q::template fn, T...> {};
|
||||||
{
|
|
||||||
using type = typename Q::template fn<T...>;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<class Q, class... T> using mp_invoke = typename detail::mp_invoke_impl<Q, T...>::type;
|
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 mp11
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
@@ -83,6 +83,7 @@ run mp_valid.cpp : : : $(REQ) ;
|
|||||||
run mp_defer.cpp : : : $(REQ) ;
|
run mp_defer.cpp : : : $(REQ) ;
|
||||||
run mp_quote.cpp : : : $(REQ) ;
|
run mp_quote.cpp : : : $(REQ) ;
|
||||||
run mp_invoke.cpp : : : $(REQ) ;
|
run mp_invoke.cpp : : : $(REQ) ;
|
||||||
|
run mp_invoke_sf.cpp : : : $(REQ) ;
|
||||||
|
|
||||||
# integer_sequence
|
# integer_sequence
|
||||||
run integer_sequence.cpp : : : $(REQ) ;
|
run integer_sequence.cpp : : : $(REQ) ;
|
||||||
|
33
test/mp_invoke_sf.cpp
Normal file
33
test/mp_invoke_sf.cpp
Normal 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();
|
||||||
|
}
|
Reference in New Issue
Block a user