1 #ifndef BOOST_MP11_DETAIL_MP_MIN_ELEMENT_HPP_INCLUDED
2 #define BOOST_MP11_DETAIL_MP_MIN_ELEMENT_HPP_INCLUDED
4 // Copyright 2015-2017 Peter Dimov.
6 // Distributed under the Boost Software License, Version 1.0.
8 // See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt
11 #include <boost/mp11/detail/mp_fold.hpp>
12 #include <boost/mp11/list.hpp>
13 #include <boost/mp11/utility.hpp>
20 // mp_min_element<L, P>
24 template<template<class...> class P> struct select_min
26 template<class T1, class T2> using fn = mp_if<P<T1, T2>, T1, T2>;
31 template<class L, template<class...> class P> using mp_min_element = mp_fold_q<mp_rest<L>, mp_first<L>, detail::select_min<P>>;
32 template<class L, class Q> using mp_min_element_q = mp_min_element<L, Q::template fn>;
34 // mp_max_element<L, P>
38 template<template<class...> class P> struct select_max
40 template<class T1, class T2> using fn = mp_if<P<T2, T1>, T1, T2>;
45 template<class L, template<class...> class P> using mp_max_element = mp_fold_q<mp_rest<L>, mp_first<L>, detail::select_max<P>>;
46 template<class L, class Q> using mp_max_element_q = mp_max_element<L, Q::template fn>;
51 #endif // #ifndef BOOST_MP11_DETAIL_MP_MIN_ELEMENT_HPP_INCLUDED