diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 298c25a..a91aeec 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +60,9 @@ template class F> using mp_fold = typename namespace detail { -template class F, class... L> struct mp_transform_impl; +template class F, class... L> struct mp_transform_impl +{ +}; template class F, template class L, class... T> struct mp_transform_impl> { @@ -68,19 +71,33 @@ template class F, template class L, class... T> str template class F, template class L1, class... T1, template class L2, class... T2> struct mp_transform_impl, L2> { - static_assert( sizeof...(T1) == sizeof...(T2), "The arguments of mp_transform should be of the same size" ); using type = L1...>; }; template class F, template class L1, class... T1, template class L2, class... T2, template class L3, class... T3> struct mp_transform_impl, L2, L3> { - static_assert( sizeof...(T1) == sizeof...(T2) && sizeof...(T1) == sizeof...(T3), "The arguments of mp_transform should be of the same size" ); using type = L1...>; }; +#if BOOST_WORKAROUND( BOOST_MSVC, == 1900 ) + +template using mp_same_size_1 = mp_same...>; +template struct mp_same_size_2: mp_defer {}; + +#endif + } // namespace detail -template class F, class... L> using mp_transform = typename detail::mp_transform_impl::type; +#if BOOST_WORKAROUND( BOOST_MSVC, == 1900 ) + +template class F, class... L> using mp_transform = typename mp_if::type, detail::mp_transform_impl>::type; + +#else + +template class F, class... L> using mp_transform = typename mp_if...>, detail::mp_transform_impl>::type; + +#endif + template using mp_transform_q = mp_transform; namespace detail @@ -88,8 +105,6 @@ namespace detail template class F, template class L1, class... T1, template class L2, class... T2, template class L3, class... T3, template class L4, class... T4, class... L> struct mp_transform_impl, L2, L3, L4, L...> { - static_assert( sizeof...(T1) == sizeof...(T2) && sizeof...(T1) == sizeof...(T3) && sizeof...(T1) == sizeof...(T4), "The arguments of mp_transform should be of the same size" ); - using A1 = L1...>; template using _f = mp_transform; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ef473d6..f45c9e6 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -35,6 +35,7 @@ run mp_apply_q.cpp : : : $(REQ) ; run mp_assign.cpp : : : $(REQ) ; run mp_clear.cpp : : : $(REQ) ; run mp_transform.cpp : : : $(REQ) ; +run mp_transform_sf.cpp : : : $(REQ) ; run mp_transform_if.cpp : : : $(REQ) ; run mp_fill.cpp : : : $(REQ) ; run mp_count.cpp : : : $(REQ) ; diff --git a/test/mp_transform_sf.cpp b/test/mp_transform_sf.cpp new file mode 100644 index 0000000..7f18eab --- /dev/null +++ b/test/mp_transform_sf.cpp @@ -0,0 +1,42 @@ + +// 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 +#include + +using boost::mp11::mp_transform; +using boost::mp11::mp_list; +using boost::mp11::mp_valid; + +template using F = void; + +template using transform = mp_transform; + +int main() +{ + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + BOOST_TEST_TRAIT_FALSE((mp_valid)); + +#if !BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) + BOOST_TEST_TRAIT_TRUE((mp_valid>)); +#endif + + BOOST_TEST_TRAIT_FALSE((mp_valid, mp_list>)); + BOOST_TEST_TRAIT_FALSE((mp_valid, mp_list<>, mp_list>)); + BOOST_TEST_TRAIT_FALSE((mp_valid, mp_list<>, mp_list<>, mp_list>)); + BOOST_TEST_TRAIT_FALSE((mp_valid, mp_list<>, mp_list<>, mp_list<>, mp_list>)); + + return boost::report_errors(); +}