2017-06-07 00:02:25 +03:00
|
|
|
////
|
|
|
|
|
Copyright 2017 Peter Dimov
|
2017-04-01 19:46:45 +03:00
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
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
|
|
|
|
|
////
|
|
|
|
|
|
|
|
|
|
[#bind]
|
|
|
|
|
# Bind, <boost/mp11/bind.hpp>
|
|
|
|
|
:toc:
|
2017-06-07 00:13:13 +03:00
|
|
|
:toc-title:
|
2017-06-07 00:02:25 +03:00
|
|
|
:idprefix:
|
|
|
|
|
|
|
|
|
|
## mp_arg<I>
|
2017-04-01 19:46:45 +03:00
|
|
|
|
|
|
|
|
template<std::size_t I> struct mp_arg;
|
|
|
|
|
|
|
|
|
|
`mp_arg<I>` is a quoted metafunction whose nested template `fn<T...>` returns the `I`-th zero-based element of `T...`.
|
|
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
## _1, ..., _9
|
|
|
|
|
|
2017-04-01 19:46:45 +03:00
|
|
|
using _1 = mp_arg<0>;
|
|
|
|
|
using _2 = mp_arg<1>;
|
|
|
|
|
using _3 = mp_arg<2>;
|
|
|
|
|
using _4 = mp_arg<3>;
|
|
|
|
|
using _5 = mp_arg<4>;
|
|
|
|
|
using _6 = mp_arg<5>;
|
|
|
|
|
using _7 = mp_arg<6>;
|
|
|
|
|
using _8 = mp_arg<7>;
|
|
|
|
|
using _9 = mp_arg<8>;
|
|
|
|
|
|
|
|
|
|
`_1` to `_9` are placeholder types, the equivalent to the placeholders of `boost::bind`.
|
|
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
## mp_bind<F, T...>
|
|
|
|
|
|
2017-04-01 19:46:45 +03:00
|
|
|
template<template<class...> class F, class... T> struct mp_bind;
|
|
|
|
|
|
2018-09-07 23:45:57 +03:00
|
|
|
`mp_bind<F, T...>` is a quoted metafunction that implements the type-based
|
|
|
|
|
equivalent of `boost::bind`. Its nested template `fn<U...>` returns `F<V...>`,
|
|
|
|
|
where `V...` is `T...` with the placeholders replaced by the corresponding
|
|
|
|
|
element of `U...` and the `mp_bind`, `mp_bind_front`, and `mp_bind_back`
|
|
|
|
|
expressions replaced with their corresponding evaluations against `U...`.
|
2017-04-01 19:46:45 +03:00
|
|
|
|
|
|
|
|
For example, `mp_bind<F, int, _2, mp_bind<G, _1>>::fn<float, void>` is `F<int, void, G<float>>`.
|
|
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
## mp_bind_q<Q, T...>
|
|
|
|
|
|
2017-05-10 23:23:56 +03:00
|
|
|
template<class Q, class... T> using mp_bind_q = mp_bind<Q::template fn, T...>;
|
|
|
|
|
|
|
|
|
|
As `mp_bind`, but takes a quoted metafunction.
|
|
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
## mp_bind_front<F, T...>
|
|
|
|
|
|
2017-05-10 00:39:18 +03:00
|
|
|
template<template<class...> class F, class... T> struct mp_bind_front;
|
|
|
|
|
|
|
|
|
|
`mp_bind_front<F, T...>` binds the leftmost arguments of `F` to `T...`. Its nested template `fn<U...>` returns `F<T..., U...>`.
|
|
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
## mp_bind_front_q<Q, T...>
|
|
|
|
|
|
2017-06-10 03:44:31 +03:00
|
|
|
template<class Q, class... T> using mp_bind_front_q =
|
|
|
|
|
mp_bind_front<Q::template fn, T...>;
|
2017-05-10 00:39:18 +03:00
|
|
|
|
|
|
|
|
As `mp_bind_front`, but takes a quoted metafunction.
|
|
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
## mp_bind_back<F, T...>
|
|
|
|
|
|
2017-05-10 00:39:18 +03:00
|
|
|
template<template<class...> class F, class... T> struct mp_bind_back;
|
|
|
|
|
|
|
|
|
|
`mp_bind_back<F, T...>` binds the rightmost arguments of `F` to `T...`. Its nested template `fn<U...>` returns `F<U..., T...>`.
|
|
|
|
|
|
2017-06-07 00:02:25 +03:00
|
|
|
## mp_bind_back_q<Q, T...>
|
|
|
|
|
|
2017-06-10 03:44:31 +03:00
|
|
|
template<class Q, class... T> using mp_bind_back_q =
|
|
|
|
|
mp_bind_back<Q::template fn, T...>;
|
2017-05-10 00:39:18 +03:00
|
|
|
|
|
|
|
|
As `mp_bind_back`, but takes a quoted metafunction.
|