Files
boost_mpl/include/boost/mpl/max_element.hpp
T

73 lines
1.5 KiB
C++
Raw Normal View History

2002-09-15 22:13:24 +00:00
#ifndef BOOST_MPL_MAX_ELEMENT_HPP_INCLUDED
#define BOOST_MPL_MAX_ELEMENT_HPP_INCLUDED
2004-09-02 15:41:37 +00:00
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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)
//
// See http://www.boost.org/libs/mpl for documentation.
2002-09-15 22:13:24 +00:00
2008-10-10 09:10:26 +00:00
// $Id$
2004-09-02 15:41:37 +00:00
// $Date$
// $Revision$
#include <boost/mpl/less.hpp>
#include <boost/mpl/iter_fold.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/aux_/common_name_wknd.hpp>
#include <boost/mpl/aux_/na_spec.hpp>
namespace boost { namespace mpl {
2002-09-15 22:13:24 +00:00
2003-11-11 01:03:27 +00:00
BOOST_MPL_AUX_COMMON_NAME_WKND(max_element)
2002-09-15 22:13:24 +00:00
namespace aux {
template< typename Predicate >
struct select_max
{
template< typename OldIterator, typename Iterator >
struct apply
{
typedef typename apply2<
Predicate
2004-09-02 15:41:37 +00:00
, typename deref<OldIterator>::type
, typename deref<Iterator>::type
2002-09-15 22:13:24 +00:00
>::type condition_;
typedef typename if_<
condition_
, Iterator
, OldIterator
>::type type;
};
};
} // namespace aux
2003-03-11 11:59:49 +00:00
2002-09-15 22:13:24 +00:00
template<
2004-09-02 15:41:37 +00:00
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
2002-09-15 22:13:24 +00:00
, typename Predicate = less<_,_>
>
struct max_element
2004-09-02 15:41:37 +00:00
: iter_fold<
2002-09-15 22:13:24 +00:00
Sequence
, typename begin<Sequence>::type
2004-09-02 15:41:37 +00:00
, protect< aux::select_max<Predicate> >
>
{
2002-09-15 22:13:24 +00:00
};
2004-09-02 15:41:37 +00:00
BOOST_MPL_AUX_NA_SPEC(1, max_element)
2003-03-11 11:59:49 +00:00
2004-09-02 15:41:37 +00:00
}}
2002-09-15 22:13:24 +00:00
#endif // BOOST_MPL_MAX_ELEMENT_HPP_INCLUDED