1
0
forked from boostorg/mp11

Move mp_min_element, mp_max_element to detail/mp_min_element.hpp

This commit is contained in:
Peter Dimov
2017-10-15 14:43:33 +03:00
parent ea68803092
commit 66b7128253
3 changed files with 52 additions and 26 deletions

View File

@@ -18,6 +18,7 @@
#include <boost/mp11/detail/mp_map_find.hpp>
#include <boost/mp11/detail/mp_with_index.hpp>
#include <boost/mp11/detail/mp_fold.hpp>
#include <boost/mp11/detail/mp_min_element.hpp>
#include <boost/mp11/detail/config.hpp>
#include <boost/mp11/integer_sequence.hpp>
#include <boost/config.hpp>
@@ -881,30 +882,8 @@ template<class L, class I, class J> using mp_erase = mp_append<mp_take<L, I>, mp
template<class L, std::size_t I, std::size_t J> using mp_erase_c = mp_append<mp_take_c<L, I>, mp_drop_c<L, J>>;
// mp_min_element<L, P>
namespace detail
{
template<template<class...> class P> struct select_min
{
template<class T1, class T2> using fn = mp_if<P<T1, T2>, T1, T2>;
};
} // namespace detail
template<class L, template<class...> class P> using mp_min_element = mp_fold_q<mp_rest<L>, mp_first<L>, detail::select_min<P>>;
// mp_max_element<L, P>
namespace detail
{
template<template<class...> class P> struct select_max
{
template<class T1, class T2> using fn = mp_if<P<T2, T1>, T1, T2>;
};
} // namespace detail
template<class L, template<class...> class P> using mp_max_element = mp_fold_q<mp_rest<L>, mp_first<L>, detail::select_max<P>>;
// in detail/mp_min_element.hpp
} // namespace mp11
} // namespace boost

View File

@@ -8,10 +8,8 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/mp11/integral.hpp>
#include <boost/mp11/detail/mp_plus.hpp>
#include <boost/mp11/detail/config.hpp>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
namespace boost
{

View File

@@ -0,0 +1,49 @@
#ifndef BOOST_MP11_DETAIL_MP_MIN_ELEMENT_HPP_INCLUDED
#define BOOST_MP11_DETAIL_MP_MIN_ELEMENT_HPP_INCLUDED
// Copyright 2015-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/detail/mp_fold.hpp>
#include <boost/mp11/list.hpp>
#include <boost/mp11/utility.hpp>
namespace boost
{
namespace mp11
{
// mp_min_element<L, P>
namespace detail
{
template<template<class...> class P> struct select_min
{
template<class T1, class T2> using fn = mp_if<P<T1, T2>, T1, T2>;
};
} // namespace detail
template<class L, template<class...> class P> using mp_min_element = mp_fold_q<mp_rest<L>, mp_first<L>, detail::select_min<P>>;
// mp_max_element<L, P>
namespace detail
{
template<template<class...> class P> struct select_max
{
template<class T1, class T2> using fn = mp_if<P<T2, T1>, T1, T2>;
};
} // namespace detail
template<class L, template<class...> class P> using mp_max_element = mp_fold_q<mp_rest<L>, mp_first<L>, detail::select_max<P>>;
} // namespace mp11
} // namespace boost
#endif // #ifndef BOOST_MP11_DETAIL_MP_MIN_ELEMENT_HPP_INCLUDED