From beb9c2dd595efb094c0dea8d329a8ea69b82dc39 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 14 Feb 2019 19:57:04 +0200 Subject: [PATCH] Add mp_eval_if_not --- include/boost/mp11/utility.hpp | 4 +++ test/Jamfile | 1 + test/mp_eval_if_not.cpp | 47 ++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 test/mp_eval_if_not.cpp diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index 8a8ee27..b68351a 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -147,6 +147,10 @@ template class F, class... U> using mp_eval_ template class F, class... U> using mp_eval_if = typename detail::mp_eval_if_c_impl(C::value), T, F, U...>::type; template using mp_eval_if_q = typename detail::mp_eval_if_c_impl(C::value), T, Q::template fn, U...>::type; +// mp_eval_if_not +template class F, class... U> using mp_eval_if_not = mp_eval_if, T, F, U...>; +template using mp_eval_if_not_q = mp_eval_if, T, Q::template fn, U...>; + // mp_cond // so elegant; so doesn't work diff --git a/test/Jamfile b/test/Jamfile index 7137c5f..437c187 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -124,6 +124,7 @@ run mp_quote_trait.cpp ; run mp_cond.cpp ; run mp_cond_sf.cpp ; run mp_not_fn.cpp ; +run mp_eval_if_not.cpp ; # integer_sequence run integer_sequence.cpp ; diff --git a/test/mp_eval_if_not.cpp b/test/mp_eval_if_not.cpp new file mode 100644 index 0000000..987e037 --- /dev/null +++ b/test/mp_eval_if_not.cpp @@ -0,0 +1,47 @@ + +// Copyright 2015, 2017, 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 +#include + +int main() +{ + using boost::mp11::mp_identity; + using boost::mp11::mp_eval_if_not; + using boost::mp11::mp_eval_if_not_q; + using boost::mp11::mp_quote; + + using qt_identity = mp_quote; + + BOOST_TEST_TRAIT_TRUE((std::is_same, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_identity>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_identity>)); + + using boost::mp11::mp_int; + + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], mp_identity, void()>, mp_identity>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], qt_identity, void()>, mp_identity>)); + + using boost::mp11::mp_size_t; + + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], mp_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], mp_identity, void()>, mp_identity>)); + + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], qt_identity, void, void, void>, char[]>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, char[], qt_identity, void()>, mp_identity>)); + + return boost::report_errors(); +}