Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:38:09

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 #if defined(_MSC_VER) || defined(__GNUC__)
0016 # pragma push_macro( "I" )
0017 # undef I
0018 #endif
0019 
0020 namespace boost
0021 {
0022 namespace mp11
0023 {
0024 
0025 // mp_bind_front
0026 template<template<class...> class F, class... T> struct mp_bind_front
0027 {
0028     // the indirection through mp_defer works around the language inability
0029     // to expand U... into a fixed parameter list of an alias template
0030 
0031     template<class... U> using fn = typename mp_defer<F, T..., U...>::type;
0032 };
0033 
0034 template<class Q, class... T> using mp_bind_front_q = mp_bind_front<Q::template fn, T...>;
0035 
0036 // mp_bind_back
0037 template<template<class...> class F, class... T> struct mp_bind_back
0038 {
0039     template<class... U> using fn = typename mp_defer<F, U..., T...>::type;
0040 };
0041 
0042 template<class Q, class... T> using mp_bind_back_q = mp_bind_back<Q::template fn, T...>;
0043 
0044 // mp_arg
0045 template<std::size_t I> struct mp_arg
0046 {
0047     template<class... T> using fn = mp_at_c<mp_list<T...>, I>;
0048 };
0049 
0050 using _1 = mp_arg<0>;
0051 using _2 = mp_arg<1>;
0052 using _3 = mp_arg<2>;
0053 using _4 = mp_arg<3>;
0054 using _5 = mp_arg<4>;
0055 using _6 = mp_arg<5>;
0056 using _7 = mp_arg<6>;
0057 using _8 = mp_arg<7>;
0058 using _9 = mp_arg<8>;
0059 
0060 // mp_bind
0061 template<template<class...> class F, class... T> struct mp_bind;
0062 
0063 namespace detail
0064 {
0065 
0066 template<class V, class... T> struct eval_bound_arg
0067 {
0068     using type = V;
0069 };
0070 
0071 template<std::size_t I, class... T> struct eval_bound_arg<mp_arg<I>, T...>
0072 {
0073     using type = typename mp_arg<I>::template fn<T...>;
0074 };
0075 
0076 template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind<F, U...>, T...>
0077 {
0078     using type = typename mp_bind<F, U...>::template fn<T...>;
0079 };
0080 
0081 template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind_front<F, U...>, T...>
0082 {
0083     using type = typename mp_bind_front<F, U...>::template fn<T...>;
0084 };
0085 
0086 template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind_back<F, U...>, T...>
0087 {
0088     using type = typename mp_bind_back<F, U...>::template fn<T...>;
0089 };
0090 
0091 } // namespace detail
0092 
0093 template<template<class...> class F, class... T> struct mp_bind
0094 {
0095 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, == 1915 )
0096 private:
0097 
0098     template<class... U> struct _f { using type = F<typename detail::eval_bound_arg<T, U...>::type...>; };
0099 
0100 public:
0101 
0102     template<class... U> using fn = typename _f<U...>::type;
0103 
0104 #else
0105 
0106     template<class... U> using fn = F<typename detail::eval_bound_arg<T, U...>::type...>;
0107 
0108 #endif
0109 };
0110 
0111 template<class Q, class... T> using mp_bind_q = mp_bind<Q::template fn, T...>;
0112 
0113 } // namespace mp11
0114 } // namespace boost
0115 
0116 #if defined(_MSC_VER) || defined(__GNUC__)
0117 # pragma pop_macro( "I" )
0118 #endif
0119 
0120 #endif // #ifndef BOOST_MP11_BIND_HPP_INCLUDED