From 7100d10c7e359205648f2737f0d2b42c9657daa8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 19 May 2017 15:37:49 +0300 Subject: [PATCH] Make mp_infoke SFINAE-friendly --- include/boost/mp11/utility.hpp | 15 ++++++++++----- test/Jamfile.v2 | 1 + test/mp_invoke_sf.cpp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 test/mp_invoke_sf.cpp diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index 1439596..dd85e89 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -116,19 +116,24 @@ template class F> struct mp_quote template using fn = typename mp_defer::type; }; -// mp_unquote +// mp_invoke +#if BOOST_WORKAROUND( BOOST_MSVC, < 1900 ) + namespace detail { -template struct mp_invoke_impl -{ - using type = typename Q::template fn; -}; +template struct mp_invoke_impl: mp_defer {}; } // namespace detail template using mp_invoke = typename detail::mp_invoke_impl::type; +#else + +template using mp_invoke = typename Q::template fn; + +#endif + } // namespace mp11 } // namespace boost diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f45c9e6..e700170 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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) ; diff --git a/test/mp_invoke_sf.cpp b/test/mp_invoke_sf.cpp new file mode 100644 index 0000000..7c2feb6 --- /dev/null +++ b/test/mp_invoke_sf.cpp @@ -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 +#include +#include + +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)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + + using Qi = mp_quote; + + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_TRUE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + + return boost::report_errors(); +}