~ubuntu-branches/ubuntu/breezy/aqsis/breezy

« back to all changes in this revision

Viewing changes to boost/boost/mpl/max_element.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Will Newton
  • Date: 2004-12-07 20:06:49 UTC
  • Revision ID: james.westby@ubuntu.com-20041207200649-fccswkrvp4oc8lmn
Tags: upstream-0.9.3
ImportĀ upstreamĀ versionĀ 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-----------------------------------------------------------------------------
 
2
// boost mpl/max_element.hpp header file
 
3
// See http://www.boost.org for updates, documentation, and revision history.
 
4
//-----------------------------------------------------------------------------
 
5
//
 
6
// Copyright (c) 2000-02
 
7
// Aleksey Gurtovoy
 
8
//
 
9
// Permission to use, copy, modify, distribute and sell this software
 
10
// and its documentation for any purpose is hereby granted without fee, 
 
11
// provided that the above copyright notice appears in all copies and 
 
12
// that both the copyright notice and this permission notice appear in 
 
13
// supporting documentation. No representations are made about the 
 
14
// suitability of this software for any purpose. It is provided "as is" 
 
15
// without express or implied warranty.
 
16
 
 
17
#ifndef BOOST_MPL_MAX_ELEMENT_HPP_INCLUDED
 
18
#define BOOST_MPL_MAX_ELEMENT_HPP_INCLUDED
 
19
 
 
20
#include "boost/mpl/less.hpp"
 
21
#include "boost/mpl/iter_fold.hpp"
 
22
#include "boost/mpl/begin_end.hpp"
 
23
#include "boost/mpl/if.hpp"
 
24
#include "boost/mpl/apply.hpp"
 
25
#include "boost/mpl/lambda.hpp"
 
26
#include "boost/mpl/aux_/void_spec.hpp"
 
27
 
 
28
namespace boost {
 
29
namespace mpl {
 
30
 
 
31
namespace aux {
 
32
 
 
33
template< typename Predicate >
 
34
struct select_max
 
35
{
 
36
    template< typename OldIterator, typename Iterator >
 
37
    struct apply
 
38
    {
 
39
        typedef typename apply2<
 
40
              Predicate
 
41
            , typename OldIterator::type
 
42
            , typename Iterator::type
 
43
            >::type condition_;
 
44
 
 
45
        typedef typename if_<
 
46
              condition_
 
47
            , Iterator
 
48
            , OldIterator
 
49
            >::type type;
 
50
    };
 
51
};
 
52
 
 
53
} // namespace aux 
 
54
 
 
55
 
 
56
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN
 
57
 
 
58
template<
 
59
      typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Sequence)
 
60
    , typename Predicate = less<_,_>
 
61
    >
 
62
struct max_element
 
63
{
 
64
 private:
 
65
    typedef typename lambda<Predicate>::type pred_;
 
66
 
 
67
 public:
 
68
    typedef typename iter_fold<
 
69
          Sequence
 
70
        , typename begin<Sequence>::type
 
71
        , protect< aux::select_max<pred_> >
 
72
        >::type type;
 
73
};
 
74
 
 
75
BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END
 
76
 
 
77
BOOST_MPL_AUX_ALGORITHM_VOID_SPEC(1, max_element)
 
78
 
 
79
} // namespace mpl
 
80
} // namespace boost
 
81
 
 
82
#endif // BOOST_MPL_MAX_ELEMENT_HPP_INCLUDED