Line data Source code
1 : /* src/future/algorithm.hpp - future algorithm library features
2 :
3 : Copyright (C) 1996-2013
4 : CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 :
6 : This file is part of CACAO.
7 :
8 : This program is free software; you can redistribute it and/or
9 : modify it under the terms of the GNU General Public License as
10 : published by the Free Software Foundation; either version 2, or (at
11 : your option) any later version.
12 :
13 : This program is distributed in the hope that it will be useful, but
14 : WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 : General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with this program; if not, write to the Free Software
20 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 : 02110-1301, USA.
22 :
23 : */
24 :
25 :
26 : #ifndef FUTURE_ALGORITHM_HPP_
27 : #define FUTURE_ALGORITHM_HPP_ 1
28 :
29 : #include "config.h"
30 :
31 : // get all_of any_of none_of templates
32 : #if HAVE_STD_ALL_ANY_NONE_OF
33 :
34 : #include <algorithm>
35 :
36 : namespace cacao {
37 : using std::all_of;
38 : using std::any_of;
39 : using std::none_of;
40 : } // end namespace cacao
41 :
42 : #elif HAVE_BOOST_ALL_ANY_NONE_OF
43 : #include <boost/algorithm/cxx11/all_of.hpp>
44 : #include <boost/algorithm/cxx11/any_of.hpp>
45 : #include <boost/algorithm/cxx11/none_of.hpp>
46 :
47 : namespace cacao {
48 : using boost::algorithm::all_of;
49 : using boost::algorithm::any_of;
50 : using boost::algorithm::none_of;
51 : } // end namespace cacao
52 :
53 : #else
54 : namespace cacao {
55 : template< class InputIt, class UnaryPredicate >
56 : bool all_of(InputIt first, InputIt last, UnaryPredicate p) {
57 : for (; first != last; ++first) {
58 : if (!p(*first)) return false;
59 : }
60 : return true;
61 : }
62 :
63 : template< class InputIt, class UnaryPredicate >
64 0 : bool any_of(InputIt first, InputIt last, UnaryPredicate p) {
65 0 : for (; first != last; ++first) {
66 0 : if (p(*first)) return true;
67 : }
68 0 : return false;
69 : }
70 :
71 : template< class InputIt, class UnaryPredicate >
72 0 : bool none_of(InputIt first, InputIt last, UnaryPredicate p) {
73 0 : for (; first != last; ++first) {
74 0 : if (p(*first)) return false;
75 : }
76 0 : return true;
77 : }
78 : } // end namespace cacao
79 : #endif
80 :
81 : #endif /* FUTURE_ALGORITHM_HPP_ */
82 :
83 : /*
84 : * These are local overrides for various environment variables in Emacs.
85 : * Please do not remove this and leave it at the end of the file, where
86 : * Emacs will automagically detect them.
87 : * ---------------------------------------------------------------------
88 : * Local variables:
89 : * mode: c++
90 : * indent-tabs-mode: t
91 : * c-basic-offset: 4
92 : * tab-width: 4
93 : * End:
94 : * vim:noexpandtab:sw=4:ts=4:
95 : */
|