diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc
index aa6723e..4a44995 100644
--- a/doc/mp11/algorithm.adoc
+++ b/doc/mp11/algorithm.adoc
@@ -396,6 +396,13 @@ Replaces all `T` elements of `L` for which `mp_to_bool
>` is `mp_true` with
|*mp_replace_if*|A~1~|W|...|A~n~
|===
+## mp_replace_if_q
+
+ template using mp_replace_if_q =
+ mp_replace_if;
+
+As `mp_replace_if`, but takes a quoted metafunction.
+
## mp_replace_at_c
template using mp_replace_at_c = /*...*/;
diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp
index a0f246e..44130d2 100644
--- a/include/boost/mp11/algorithm.hpp
+++ b/include/boost/mp11/algorithm.hpp
@@ -378,13 +378,19 @@ template class P, class W> struct mp_replace_if_impl
template class L, class... T, template class P, class W> struct mp_replace_if_impl, P, W>
{
+#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1920 )
+ template struct _f { using type = mp_if, W, U>; };
+ using type = L::type...>;
+#else
template using _f = mp_if, W, U>;
using type = L<_f...>;
+#endif
};
} // namespace detail
template class P, class W> using mp_replace_if = typename detail::mp_replace_if_impl::type;
+template using mp_replace_if_q = mp_replace_if;
// mp_copy_if
namespace detail
diff --git a/test/Jamfile b/test/Jamfile
index bebab98..9c95adf 100644
--- a/test/Jamfile
+++ b/test/Jamfile
@@ -55,6 +55,7 @@ run mp_at_sf.cpp ;
run mp_take.cpp ;
run mp_replace.cpp ;
run mp_replace_if.cpp ;
+run mp_replace_if_q.cpp ;
run mp_copy_if.cpp ;
run mp_remove.cpp ;
run mp_remove_if.cpp ;
diff --git a/test/mp_replace_if_q.cpp b/test/mp_replace_if_q.cpp
new file mode 100644
index 0000000..a692673
--- /dev/null
+++ b/test/mp_replace_if_q.cpp
@@ -0,0 +1,59 @@
+
+// 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
+#include
+#include
+#include
+#include
+
+struct X1 {};
+
+int main()
+{
+ using boost::mp11::mp_list;
+ using boost::mp11::mp_replace_if_q;
+ using boost::mp11::mp_quote;
+
+ {
+ using L1 = mp_list<>;
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, L1>));
+
+ using L2 = mp_list;
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, L2>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, mp_list>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, mp_list>));
+ }
+
+ {
+ using L1 = std::tuple<>;
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, L1>));
+
+ using L2 = std::tuple;
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, L2>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, std::tuple>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, std::tuple>));
+ }
+
+ {
+ using L2 = std::pair;
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, L2>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, std::pair>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, void>, std::pair>));
+ }
+
+ return boost::report_errors();
+}