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