mp_remove_if.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef BOOST_MP11_DETAIL_MP_REMOVE_IF_HPP_INCLUDED
  2. #define BOOST_MP11_DETAIL_MP_REMOVE_IF_HPP_INCLUDED
  3. // Copyright 2015-2019 Peter Dimov.
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. //
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. #include <boost/mp11/utility.hpp>
  10. #include <boost/mp11/detail/mp_list.hpp>
  11. #include <boost/mp11/detail/mp_append.hpp>
  12. #include <boost/mp11/detail/config.hpp>
  13. namespace boost
  14. {
  15. namespace mp11
  16. {
  17. // mp_remove_if<L, P>
  18. namespace detail
  19. {
  20. template<class L, template<class...> class P> struct mp_remove_if_impl
  21. {
  22. };
  23. template<template<class...> class L, class... T, template<class...> class P> struct mp_remove_if_impl<L<T...>, P>
  24. {
  25. #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 )
  26. template<class U> struct _f { using type = mp_if<P<U>, mp_list<>, mp_list<U>>; };
  27. using type = mp_append<L<>, typename _f<T>::type...>;
  28. #else
  29. template<class U> using _f = mp_if<P<U>, mp_list<>, mp_list<U>>;
  30. using type = mp_append<L<>, _f<T>...>;
  31. #endif
  32. };
  33. } // namespace detail
  34. template<class L, template<class...> class P> using mp_remove_if = typename detail::mp_remove_if_impl<L, P>::type;
  35. template<class L, class Q> using mp_remove_if_q = mp_remove_if<L, Q::template fn>;
  36. } // namespace mp11
  37. } // namespace boost
  38. #endif // #ifndef BOOST_MP11_DETAIL_MP_REMOVE_IF_HPP_INCLUDED