Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:55

0001 #ifndef BOOST_MP11_BIND_HPP_INCLUDED
0002 #define BOOST_MP11_BIND_HPP_INCLUDED
0003 
0004 //  Copyright 2017, 2018 Peter Dimov.
0005 //
0006 //  Distributed under the Boost Software License, Version 1.0.
0007 //
0008 //  See accompanying file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt
0010 
0011 #include <boost/mp11/algorithm.hpp>
0012 #include <boost/mp11/utility.hpp>
0013 #include <cstddef>
0014 
0015 namespace boost
0016 {
0017 namespace mp11
0018 {
0019 
0020 // mp_bind_front
0021 template<template<class...> class F, class... T> struct mp_bind_front
0022 {
0023     // the indirection through mp_defer works around the language inability
0024     // to expand U... into a fixed parameter list of an alias template
0025 
0026     template<class... U> using fn = typename mp_defer<F, T..., U...>::type;
0027 };
0028 
0029 template<class Q, class... T> using mp_bind_front_q = mp_bind_front<Q::template fn, T...>;
0030 
0031 // mp_bind_back
0032 template<template<class...> class F, class... T> struct mp_bind_back
0033 {
0034     template<class... U> using fn = typename mp_defer<F, U..., T...>::type;
0035 };
0036 
0037 template<class Q, class... T> using mp_bind_back_q = mp_bind_back<Q::template fn, T...>;
0038 
0039 // mp_arg
0040 template<std::size_t I> struct mp_arg
0041 {
0042     template<class... T> using fn = mp_at_c<mp_list<T...>, I>;
0043 };
0044 
0045 using _1 = mp_arg<0>;
0046 using _2 = mp_arg<1>;
0047 using _3 = mp_arg<2>;
0048 using _4 = mp_arg<3>;
0049 using _5 = mp_arg<4>;
0050 using _6 = mp_arg<5>;
0051 using _7 = mp_arg<6>;
0052 using _8 = mp_arg<7>;
0053 using _9 = mp_arg<8>;
0054 
0055 // mp_bind
0056 template<template<class...> class F, class... T> struct mp_bind;
0057 
0058 namespace detail
0059 {
0060 
0061 template<class V, class... T> struct eval_bound_arg
0062 {
0063     using type = V;
0064 };
0065 
0066 template<std::size_t I, class... T> struct eval_bound_arg<mp_arg<I>, T...>
0067 {
0068     using type = typename mp_arg<I>::template fn<T...>;
0069 };
0070 
0071 template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind<F, U...>, T...>
0072 {
0073     using type = typename mp_bind<F, U...>::template fn<T...>;
0074 };
0075 
0076 template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind_front<F, U...>, T...>
0077 {
0078     using type = typename mp_bind_front<F, U...>::template fn<T...>;
0079 };
0080 
0081 template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind_back<F, U...>, T...>
0082 {
0083     using type = typename mp_bind_back<F, U...>::template fn<T...>;
0084 };
0085 
0086 } // namespace detail
0087 
0088 template<template<class...> class F, class... T> struct mp_bind
0089 {
0090 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, == 1915 )
0091 private:
0092 
0093     template<class... U> struct _f { using type = F<typename detail::eval_bound_arg<T, U...>::type...>; };
0094 
0095 public:
0096 
0097     template<class... U> using fn = typename _f<U...>::type;
0098 
0099 #else
0100 
0101     template<class... U> using fn = F<typename detail::eval_bound_arg<T, U...>::type...>;
0102 
0103 #endif
0104 };
0105 
0106 template<class Q, class... T> using mp_bind_q = mp_bind<Q::template fn, T...>;
0107 
0108 } // namespace mp11
0109 } // namespace boost
0110 
0111 #endif // #ifndef BOOST_MP11_BIND_HPP_INCLUDED