forked from boostorg/mp11
Evaluate mp_bind_front, mp_bind_back inside mp_bind
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef BOOST_MP11_BIND_HPP_INCLUDED
|
||||
#define BOOST_MP11_BIND_HPP_INCLUDED
|
||||
|
||||
// Copyright 2017 Peter Dimov.
|
||||
// Copyright 2017, 2018 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
@@ -17,6 +17,25 @@ namespace boost
|
||||
namespace mp11
|
||||
{
|
||||
|
||||
// mp_bind_front
|
||||
template<template<class...> class F, class... T> struct mp_bind_front
|
||||
{
|
||||
// the indirection through mp_defer works around the language inability
|
||||
// to expand U... into a fixed parameter list of an alias template
|
||||
|
||||
template<class... U> using fn = typename mp_defer<F, T..., U...>::type;
|
||||
};
|
||||
|
||||
template<class Q, class... T> using mp_bind_front_q = mp_bind_front<Q::template fn, T...>;
|
||||
|
||||
// mp_bind_back
|
||||
template<template<class...> class F, class... T> struct mp_bind_back
|
||||
{
|
||||
template<class... U> using fn = typename mp_defer<F, U..., T...>::type;
|
||||
};
|
||||
|
||||
template<class Q, class... T> using mp_bind_back_q = mp_bind_back<Q::template fn, T...>;
|
||||
|
||||
// mp_arg
|
||||
template<std::size_t I> struct mp_arg
|
||||
{
|
||||
@@ -54,6 +73,16 @@ template<template<class...> class F, class... U, class... T> struct eval_bound_a
|
||||
using type = typename mp_bind<F, U...>::template fn<T...>;
|
||||
};
|
||||
|
||||
template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind_front<F, U...>, T...>
|
||||
{
|
||||
using type = typename mp_bind_front<F, U...>::template fn<T...>;
|
||||
};
|
||||
|
||||
template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind_back<F, U...>, T...>
|
||||
{
|
||||
using type = typename mp_bind_back<F, U...>::template fn<T...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<template<class...> class F, class... T> struct mp_bind
|
||||
@@ -63,25 +92,6 @@ template<template<class...> class F, class... T> struct mp_bind
|
||||
|
||||
template<class Q, class... T> using mp_bind_q = mp_bind<Q::template fn, T...>;
|
||||
|
||||
// mp_bind_front
|
||||
template<template<class...> class F, class... T> struct mp_bind_front
|
||||
{
|
||||
// the indirection through mp_defer works around the language inability
|
||||
// to expand U... into a fixed parameter list of an alias template
|
||||
|
||||
template<class... U> using fn = typename mp_defer<F, T..., U...>::type;
|
||||
};
|
||||
|
||||
template<class Q, class... T> using mp_bind_front_q = mp_bind_front<Q::template fn, T...>;
|
||||
|
||||
// mp_bind_back
|
||||
template<template<class...> class F, class... T> struct mp_bind_back
|
||||
{
|
||||
template<class... U> using fn = typename mp_defer<F, U..., T...>::type;
|
||||
};
|
||||
|
||||
template<class Q, class... T> using mp_bind_back_q = mp_bind_back<Q::template fn, T...>;
|
||||
|
||||
} // namespace mp11
|
||||
} // namespace boost
|
||||
|
||||
|
Reference in New Issue
Block a user