diff --git a/include/boost/mp11.hpp b/include/boost/mp11.hpp index 32cbb01..e623917 100644 --- a/include/boost/mp11.hpp +++ b/include/boost/mp11.hpp @@ -9,6 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt #include +#include #include #include diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp new file mode 100644 index 0000000..1111370 --- /dev/null +++ b/include/boost/mp11/algorithm.hpp @@ -0,0 +1,188 @@ +#ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED +#define BOOST_MP11_ALGORITHM_HPP_INCLUDED + +// Copyright 2015 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 +#include +#include + +namespace boost +{ + +// mp_assign +namespace detail +{ + +template struct mp_assign_impl; + +template class L1, class... T, template class L2, class... U> struct mp_assign_impl, L2> +{ + using type = L1; +}; + +} // namespace detail + +template using mp_assign = typename detail::mp_assign_impl::type; + +// mp_clear +template using mp_clear = mp_assign>; + +// mp_transform +namespace detail +{ + +template class F, class... L> struct mp_transform_impl; + +template class F, class... L> using mp_transform = typename mp_transform_impl::type; + +template class F, template class L, class... T> struct mp_transform_impl> +{ + using type = L...>; +}; + +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...>; +}; + +} // namespace detail + +template class F, class... L> using mp_transform = typename detail::mp_transform_impl::type; + +// mp_fill +namespace detail +{ + +template struct mp_fill_impl; + +template class L, class... T, class V> struct mp_fill_impl, V> +{ +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) + + template struct _f { using type = V; }; + using type = L::type...>; + +#else + + template using _f = V; + using type = L<_f...>; + +#endif +}; + +} // namespace detail + +template using mp_fill = typename detail::mp_fill_impl::type; + +// mp_count +namespace detail +{ + +template struct mp_count_impl; + +template class L, class... T, class V> struct mp_count_impl, V> +{ + using type = mp_plus...>; +}; + +} // namespace detail + +template using mp_count = typename detail::mp_count_impl::type; + +// mp_count_if +namespace detail +{ + +template class P> struct mp_count_if_impl; + +template class L, class... T, template class P> struct mp_count_if_impl, P> +{ +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) + + template struct _f { using type = mp_to_bool>; }; + using type = mp_plus::type...>; + +#else + + using type = mp_plus>...>; + +#endif +}; + +} // namespace detail + +template class P> using mp_count_if = typename detail::mp_count_if_impl::type; + +// mp_contains +template using mp_contains = mp_to_bool>; + +// mp_repeat(_c) +namespace detail +{ + +template struct mp_repeat_c_impl +{ + using _l1 = typename mp_repeat_c_impl::type; + using _l2 = typename mp_repeat_c_impl::type; + + using type = mp_append<_l1, _l1, _l2>; +}; + +template struct mp_repeat_c_impl +{ + using type = mp_clear; +}; + +template struct mp_repeat_c_impl +{ + using type = L; +}; + +template struct mp_repeat_impl +{ + static_assert( N::value >= 0, "mp_repeat: N must not be negative" ); + + using type = typename mp_repeat_c_impl::type; +}; + +} // namespace detail + +template using mp_repeat_c = typename detail::mp_repeat_c_impl::type; +template using mp_repeat = typename detail::mp_repeat_impl::type; + +// mp_drop +// mp_take +// mp_find +// mp_find_if +// mp_find_index +// mp_find_index_if +// mp_reverse +// mp_copy_if +// mp_remove_if +// mp_product? +// mp_fold +// mp_reverse_fold +// mp_replace? +// mp_replace_if? +// mp_partition +// mp_sort + +} // namespace boost + +#endif // #ifndef BOOST_MP11_ALGORITHM_HPP_INCLUDED diff --git a/include/boost/mp11/list.hpp b/include/boost/mp11/list.hpp index d13d2b2..ecc672e 100644 --- a/include/boost/mp11/list.hpp +++ b/include/boost/mp11/list.hpp @@ -9,10 +9,6 @@ // http://www.boost.org/LICENSE_1_0.txt #include -#include -#include -#include -#include namespace boost { @@ -176,171 +172,6 @@ template class L1, class... T1, template class L2, template using mp_append = typename detail::mp_append_impl::type; -// mp_assign -namespace detail -{ - -template struct mp_assign_impl; - -template class L1, class... T, template class L2, class... U> struct mp_assign_impl, L2> -{ - using type = L1; -}; - -} // namespace detail - -template using mp_assign = typename detail::mp_assign_impl::type; - -// mp_clear -template using mp_clear = mp_assign>; - -// mp_transform -namespace detail -{ - -template class F, class... L> struct mp_transform_impl; - -template class F, class... L> using mp_transform = typename mp_transform_impl::type; - -template class F, template class L, class... T> struct mp_transform_impl> -{ - using type = L...>; -}; - -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...>; -}; - -} // namespace detail - -template class F, class... L> using mp_transform = typename detail::mp_transform_impl::type; - -// mp_fill -namespace detail -{ - -template struct mp_fill_impl; - -template class L, class... T, class V> struct mp_fill_impl, V> -{ -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) - - template struct _f { using type = V; }; - using type = L::type...>; - -#else - - template using _f = V; - using type = L<_f...>; - -#endif -}; - -} // namespace detail - -template using mp_fill = typename detail::mp_fill_impl::type; - -// mp_count -namespace detail -{ - -template struct mp_count_impl; - -template class L, class... T, class V> struct mp_count_impl, V> -{ - using type = mp_plus...>; -}; - -} // namespace detail - -template using mp_count = typename detail::mp_count_impl::type; - -// mp_count_if -namespace detail -{ - -template class P> struct mp_count_if_impl; - -template class L, class... T, template class P> struct mp_count_if_impl, P> -{ -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) - - template struct _f { using type = mp_to_bool>; }; - using type = mp_plus::type...>; - -#else - - using type = mp_plus>...>; - -#endif -}; - -} // namespace detail - -template class P> using mp_count_if = typename detail::mp_count_if_impl::type; - -// mp_contains -template using mp_contains = mp_to_bool>; - -// mp_repeat(_c) -namespace detail -{ - -template struct mp_repeat_c_impl -{ - using _l1 = typename mp_repeat_c_impl::type; - using _l2 = typename mp_repeat_c_impl::type; - - using type = mp_append<_l1, _l1, _l2>; -}; - -template struct mp_repeat_c_impl -{ - using type = mp_clear; -}; - -template struct mp_repeat_c_impl -{ - using type = L; -}; - -template struct mp_repeat_impl -{ - static_assert( N::value >= 0, "mp_repeat: N must not be negative" ); - - using type = typename mp_repeat_c_impl::type; -}; - -} // namespace detail - -template using mp_repeat_c = typename detail::mp_repeat_c_impl::type; -template using mp_repeat = typename detail::mp_repeat_impl::type; - -// mp_drop -// mp_take -// mp_find -// mp_find_if -// mp_find_index -// mp_find_index_if -// mp_reverse -// mp_copy_if -// mp_remove_if -// mp_product? -// mp_fold -// mp_reverse_fold -// mp_replace? -// mp_replace_if? -// mp_partition -// mp_sort - } // namespace boost #endif // #ifndef BOOST_MP11_LIST_HPP_INCLUDED diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 249e876..3f3d35a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -11,6 +11,9 @@ import ../../config/checks/config : requires ; REQ = ; #[ requires cxx11_variadic_templates cxx11_template_aliases cxx11_hdr_type_traits cxx11_hdr_tuple ] ; +# include-only +compile mp11.cpp : : : $(REQ) ; + # list run mp_size.cpp : : : $(REQ) ; run mp_empty.cpp : : : $(REQ) ; diff --git a/test/mp11.cpp b/test/mp11.cpp new file mode 100644 index 0000000..6ab26cb --- /dev/null +++ b/test/mp11.cpp @@ -0,0 +1,14 @@ + +// Copyright 2015 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 + +int main() +{ +} diff --git a/test/mp_assign.cpp b/test/mp_assign.cpp index a586cf5..cd6bea5 100644 --- a/test/mp_assign.cpp +++ b/test/mp_assign.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/test/mp_clear.cpp b/test/mp_clear.cpp index e3fb626..991d5a5 100644 --- a/test/mp_clear.cpp +++ b/test/mp_clear.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/test/mp_fill.cpp b/test/mp_fill.cpp index b2fdf81..e12f538 100644 --- a/test/mp_fill.cpp +++ b/test/mp_fill.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/test/mp_repeat.cpp b/test/mp_repeat.cpp index 3f08a50..a145fc8 100644 --- a/test/mp_repeat.cpp +++ b/test/mp_repeat.cpp @@ -7,9 +7,10 @@ // http://www.boost.org/LICENSE_1_0.txt -#include +#include #include #include +#include #include #include #include