diff --git a/doc/mp11/utility.adoc b/doc/mp11/utility.adoc index c9399f7..bb6826d 100644 --- a/doc/mp11/utility.adoc +++ b/doc/mp11/utility.adoc @@ -231,3 +231,20 @@ template using is_const_and_volatile = template using is_const_and_volatile = mp_all>>; ``` + +## mp_not_fn

+ + template class P> struct mp_not_fn + { + template using fn = mp_not>; + }; + +`mp_not_fn

` returns a quoted metafunction `Q` such that `Q::fn` returns `mp_not>`. + +That is, it negates the result of `P`. + +## mp_not_fn_q + + template using mp_not_fn_q = mp_not_fn; + +As `mp_not_fn`, but takes a quoted metafunction. diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index f9a4e8c..8a8ee27 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -212,6 +212,14 @@ template using mp_invoke_q = typename Q::template fn; // old name for mp_invoke_q retained for compatibility, but deprecated template using mp_invoke BOOST_MP11_DEPRECATED("please use mp_invoke_q") = mp_invoke_q; +// mp_not_fn

+template class P> struct mp_not_fn +{ + template using fn = mp_not< mp_invoke_q, T...> >; +}; + +template using mp_not_fn_q = mp_not_fn; + } // namespace mp11 } // namespace boost diff --git a/test/Jamfile b/test/Jamfile index 010309b..8e152ca 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -116,6 +116,7 @@ run mp_invoke_q_sf.cpp ; run mp_quote_trait.cpp ; run mp_cond.cpp ; run mp_cond_sf.cpp ; +run mp_not_fn.cpp ; # integer_sequence run integer_sequence.cpp ; diff --git a/test/mp_not_fn.cpp b/test/mp_not_fn.cpp new file mode 100644 index 0000000..808e0ab --- /dev/null +++ b/test/mp_not_fn.cpp @@ -0,0 +1,36 @@ + +// Copyright 2019 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 + +template using is_const_ = std::is_const; + +struct Q_is_const +{ + template using fn = std::is_const; +}; + +int main() +{ + using boost::mp11::mp_not_fn; + using boost::mp11::mp_not_fn_q; + + BOOST_TEST_TRAIT_TRUE((mp_not_fn::fn)); + BOOST_TEST_TRAIT_FALSE((mp_not_fn::fn)); + + BOOST_TEST_TRAIT_TRUE((mp_not_fn::fn)); + BOOST_TEST_TRAIT_FALSE((mp_not_fn::fn)); + + BOOST_TEST_TRAIT_TRUE((mp_not_fn_q::fn)); + BOOST_TEST_TRAIT_FALSE((mp_not_fn_q::fn)); + + return boost::report_errors(); +}