diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index ab31f52..1326fc3 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -262,7 +262,8 @@ Same as `mp_repeat_c` but with a type argument `N`. The number of copies is `N:: `mp_product, L2, ..., Ln>` evaluates `F` for values `Ui` taken from the Cartesian product of the lists, as if the elements `Ui` are formed by `n` nested loops, each traversing `Li`. -It returns a list of the form `L1` containing the results of the application of `F`. +It returns a list of the form `L1` containing the results of the application of `F`. The degenerate case +of zero lists, `mp_product`, returns `mp_list>`. .mp_product on two lists [cols="<.^4m,4*^.^1m",width=85%] diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index f0a700d..73a15e7 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -254,7 +254,9 @@ template using mp_repeat = typename detail::mp_repeat_c_impl class F, class P, class... L> struct mp_product_impl_2; +template class F, class P, class... L> struct mp_product_impl_2 +{ +}; template class F, class P> struct mp_product_impl_2 { @@ -266,7 +268,14 @@ template class F, class P, template class L1, class using type = mp_append, L...>::type...>; }; -template class F, class... L> struct mp_product_impl; +template class F, class... L> struct mp_product_impl +{ +}; + +template class F> struct mp_product_impl +{ + using type = mp_list< F<> >; +}; template class F, class L1, class... L> struct mp_product_impl { diff --git a/test/mp_product.cpp b/test/mp_product.cpp index 3d3d2ad..f00bc40 100644 --- a/test/mp_product.cpp +++ b/test/mp_product.cpp @@ -24,9 +24,10 @@ struct Y1 {}; struct Z1 {}; struct Z2 {}; -template struct F {}; - template struct F1 {}; +template struct F3 {}; + +template struct F {}; int main() { @@ -40,8 +41,8 @@ int main() using L2 = mp_list; using L3 = std::pair; - BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple, F, F, F, F, F>>)); - BOOST_TEST_TRAIT_TRUE((std::is_same, L1, L2, L3>, std::tuple, F, F, F, F, F>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple, F3, F3, F3, F3, F3>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, L1, L2, L3>, std::tuple, F3, F3, F3, F3, F3>>)); } { @@ -49,8 +50,8 @@ int main() using L2 = mp_list<>; using L3 = std::pair; - BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple<>>)); - BOOST_TEST_TRAIT_TRUE((std::is_same, L1, L2, L3>, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, L1, L2, L3>, std::tuple<>>)); } { @@ -64,5 +65,10 @@ int main() BOOST_TEST_TRAIT_TRUE((std::is_same, L2>, mp_list, F1, F1>>)); } + { + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_list>>)); + } + return boost::report_errors(); }