]> git.lyx.org Git - lyx.git/blob - src/support/lyxfunctional.h
* lyxfunctional.h: delete compare_memfun and helper classes
[lyx.git] / src / support / lyxfunctional.h
1 // -*- C++ -*-
2 /**
3  * \file lyxfunctional.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * \brief Convenient function objects for use with LyX
12  *
13  * This is currently a small collection of small function objects for use
14  * together with std::algorithms.
15  */
16
17
18 #ifndef LYX_FUNCTIONAL_H
19 #define LYX_FUNCTIONAL_H
20
21 #include <iterator>
22
23 namespace lyx {
24
25 // Functors used in the template.
26
27 ///
28 template<typename T>
29 class equal_1st_in_pair {
30 public:
31         ///
32         typedef typename T::first_type first_type;
33         ///
34         typedef T pair_type;
35         ///
36         equal_1st_in_pair(first_type const & value) : value_(value) {}
37         ///
38         bool operator() (pair_type const & p) const {
39                 return p.first == value_;
40         }
41 private:
42         ///
43         first_type const & value_;
44 };
45
46
47 ///
48 template<typename T>
49 class equal_2nd_in_pair {
50 public:
51         ///
52         typedef typename T::second_type second_type;
53         ///
54         typedef T pair_type;
55         ///
56         equal_2nd_in_pair(second_type const & value) : value_(value) {}
57         ///
58         bool operator() (pair_type const & p) const {
59                 return p.second == value_;
60         }
61 private:
62         ///
63         second_type const & value_;
64 };
65
66 }  // end of namespace lyx
67 #endif