From fc8bfcf601c35b0cc4e337be2f59f2a16912af5e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 14 Feb 2019 21:03:13 +0200 Subject: [PATCH] Add mp_eval_or --- include/boost/mp11/utility.hpp | 4 +++ test/Jamfile | 1 + test/mp_eval_or.cpp | 51 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 test/mp_eval_or.cpp diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index b085d0e..38989f4 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -153,6 +153,10 @@ template using mp_eval_if_q = typename de 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_eval_or +template class F, class... U> using mp_eval_or = mp_eval_if_not, T, F, U...>; +template using mp_eval_or_q = mp_eval_or; + // mp_cond // so elegant; so doesn't work diff --git a/test/Jamfile b/test/Jamfile index 437c187..74f6b67 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -125,6 +125,7 @@ run mp_cond.cpp ; run mp_cond_sf.cpp ; run mp_not_fn.cpp ; run mp_eval_if_not.cpp ; +run mp_eval_or.cpp ; # integer_sequence run integer_sequence.cpp ; diff --git a/test/mp_eval_or.cpp b/test/mp_eval_or.cpp new file mode 100644 index 0000000..c56a91b --- /dev/null +++ b/test/mp_eval_or.cpp @@ -0,0 +1,51 @@ + +// 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 difference_type = typename T::difference_type; + +struct X +{ +}; + +struct Y +{ + using difference_type = int; +}; + +int main() +{ + using boost::mp11::mp_eval_or; + using boost::mp11::mp_eval_or_q; + using boost::mp11::mp_identity; + using boost::mp11::mp_quote; + + BOOST_TEST_TRAIT_SAME(mp_eval_or, void); + BOOST_TEST_TRAIT_SAME(mp_eval_or, mp_identity); + BOOST_TEST_TRAIT_SAME(mp_eval_or, void); + + using Q_identity = mp_quote; + + BOOST_TEST_TRAIT_SAME(mp_eval_or_q, void); + BOOST_TEST_TRAIT_SAME(mp_eval_or_q, mp_identity); + BOOST_TEST_TRAIT_SAME(mp_eval_or_q, void); + + BOOST_TEST_TRAIT_SAME(mp_eval_or, std::ptrdiff_t); + BOOST_TEST_TRAIT_SAME(mp_eval_or, int); + + using Q_diff_type = mp_quote; + + BOOST_TEST_TRAIT_SAME(mp_eval_or_q, std::ptrdiff_t); + BOOST_TEST_TRAIT_SAME(mp_eval_or_q, int); + + return boost::report_errors(); +}