2017-04-01 18:42:11 +03:00
|
|
|
#ifndef BOOST_MP11_BIND_HPP_INCLUDED
|
|
|
|
#define BOOST_MP11_BIND_HPP_INCLUDED
|
|
|
|
|
|
|
|
// Copyright 2017 Peter Dimov.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
|
#include <boost/mp11/algorithm.hpp>
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
namespace mp11
|
|
|
|
{
|
|
|
|
|
2017-05-09 20:53:00 +03:00
|
|
|
// mp_arg
|
2017-04-01 18:42:11 +03:00
|
|
|
template<std::size_t I> struct mp_arg
|
|
|
|
{
|
|
|
|
template<class... T> using fn = mp_at_c<mp_list<T...>, I>;
|
|
|
|
};
|
|
|
|
|
|
|
|
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>;
|
|
|
|
|
2017-05-09 20:53:00 +03:00
|
|
|
// mp_bind
|
2017-04-01 18:42:11 +03:00
|
|
|
template<template<class...> class F, class... T> struct mp_bind;
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
|
|
|
|
template<class V, class... T> struct eval_bound_arg
|
|
|
|
{
|
|
|
|
using type = V;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<std::size_t I, class... T> struct eval_bound_arg<mp_arg<I>, T...>
|
|
|
|
{
|
|
|
|
using type = typename mp_arg<I>::template fn<T...>;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<template<class...> class F, class... U, class... T> struct eval_bound_arg<mp_bind<F, U...>, T...>
|
|
|
|
{
|
|
|
|
using type = typename mp_bind<F, U...>::template fn<T...>;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
template<template<class...> class F, class... T> struct mp_bind
|
|
|
|
{
|
|
|
|
template<class... U> using fn = F<typename detail::eval_bound_arg<T, U...>::type...>;
|
|
|
|
};
|
|
|
|
|
2017-05-09 20:53:00 +03:00
|
|
|
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
|
|
|
|
{
|
2017-08-22 22:01:10 +03:00
|
|
|
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1920 && BOOST_MSVC >= 1900 )
|
2017-05-09 20:53:00 +03:00
|
|
|
#else
|
|
|
|
private:
|
|
|
|
#endif
|
|
|
|
|
2018-01-23 11:39:56 +09:00
|
|
|
template<class... U> struct _fn { using type = F<T..., U...>; };
|
2017-05-09 20:53:00 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2018-01-23 11:39:56 +09:00
|
|
|
// the indirection through _fn works around the language inability
|
|
|
|
// to expand U... into a fixed parameter list of an alias template
|
2017-05-09 20:53:00 +03:00
|
|
|
|
2018-01-23 11:39:56 +09:00
|
|
|
template<class... U> using fn = typename _fn<U...>::type;
|
2017-05-09 20:53:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2017-08-22 22:01:10 +03:00
|
|
|
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1920 && BOOST_MSVC >= 1900 )
|
2017-05-09 20:53:00 +03:00
|
|
|
#else
|
|
|
|
private:
|
|
|
|
#endif
|
|
|
|
|
2018-01-23 11:39:56 +09:00
|
|
|
template<class... U> struct _fn { using type = F<U..., T...>; };
|
2017-05-09 20:53:00 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2018-01-23 11:39:56 +09:00
|
|
|
template<class... U> using fn = typename _fn<U...>::type;
|
2017-05-09 20:53:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class Q, class... T> using mp_bind_back_q = mp_bind_back<Q::template fn, T...>;
|
|
|
|
|
2017-04-01 18:42:11 +03:00
|
|
|
} // namespace mp11
|
|
|
|
} // namespace boost
|
|
|
|
|
|
|
|
#endif // #ifndef BOOST_MP11_BIND_HPP_INCLUDED
|