diff --git a/include/boost/mp11/utility.hpp b/include/boost/mp11/utility.hpp index 0fe8853..5590e09 100644 --- a/include/boost/mp11/utility.hpp +++ b/include/boost/mp11/utility.hpp @@ -52,27 +52,6 @@ template struct mp_if_c_impl template using mp_if_c = typename detail::mp_if_c_impl::type; template using mp_if = typename detail::mp_if_c_impl(C::value), T, E...>::type; -// mp_eval_if, mp_eval_if_c -namespace detail -{ - -template class F, class... U> struct mp_eval_if_c_impl; - -template class F, class... U> struct mp_eval_if_c_impl -{ - using type = T; -}; - -template class F, class... U> struct mp_eval_if_c_impl -{ - using type = F; -}; - -} // namespace detail - -template class F, class... U> using mp_eval_if_c = typename detail::mp_eval_if_c_impl::type; -template class F, class... U> using mp_eval_if = typename detail::mp_eval_if_c_impl(C::value), T, F, U...>::type; - // mp_valid // implementation by Bruno Dutra (by the name is_evaluable) namespace detail @@ -107,6 +86,26 @@ struct mp_no_type template class F, class... T> using mp_defer = mp_if, detail::mp_defer_impl, detail::mp_no_type>; +// mp_eval_if, mp_eval_if_c +namespace detail +{ + +template class F, class... U> struct mp_eval_if_c_impl; + +template class F, class... U> struct mp_eval_if_c_impl +{ + using type = T; +}; + +template class F, class... U> struct mp_eval_if_c_impl: mp_defer +{ +}; + +} // namespace detail + +template class F, class... U> using mp_eval_if_c = typename detail::mp_eval_if_c_impl::type; +template class F, class... U> using mp_eval_if = typename detail::mp_eval_if_c_impl(C::value), T, F, U...>::type; + // mp_quote template class F> struct mp_quote { diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 579fc86..ef473d6 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -77,6 +77,7 @@ run mp_inherit.cpp : : : $(REQ) ; run mp_if.cpp : : : $(REQ) ; run mp_if_sf.cpp : : : $(REQ) ; run mp_eval_if.cpp : : : $(REQ) ; +run mp_eval_if_sf.cpp : : : $(REQ) ; run mp_valid.cpp : : : $(REQ) ; run mp_defer.cpp : : : $(REQ) ; run mp_quote.cpp : : : $(REQ) ; diff --git a/test/mp_eval_if_sf.cpp b/test/mp_eval_if_sf.cpp new file mode 100644 index 0000000..8eca74e --- /dev/null +++ b/test/mp_eval_if_sf.cpp @@ -0,0 +1,34 @@ + +// Copyright 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_eval_if; +using boost::mp11::mp_identity_t; + +template using eval_if = mp_eval_if; + +int main() +{ + using boost::mp11::mp_valid; + + BOOST_TEST_TRAIT_TRUE((mp_valid)); + BOOST_TEST_TRAIT_TRUE((mp_valid)); + BOOST_TEST_TRAIT_TRUE((mp_valid)); + BOOST_TEST_TRAIT_TRUE((mp_valid)); + + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_TRUE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + + return boost::report_errors(); +}