Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
is_member.hpp
Go to the documentation of this file.
1/*
2 Copyright 2008 Adobe Systems Incorporated
3 Distributed under the Boost Software License - Version 1.0 (see the accompanying file LICENSE
4 or a copy at https://stlab.github.io/adobe_source_libraries/licenses.html)
5*/
6
7/**************************************************************************************************/
8
9#ifndef ADOBE_FUNCTIONAL_IS_MEMBER_HPP
10#define ADOBE_FUNCTIONAL_IS_MEMBER_HPP
11
12#include <adobe/config.hpp>
13
14#include <boost/iterator/iterator_traits.hpp>
15#include <boost/range/begin.hpp>
16#include <boost/range/const_iterator.hpp>
17#include <boost/range/end.hpp>
18
21
22/**************************************************************************************************/
23
24namespace adobe {
25
26/**************************************************************************************************/
27
31
32template <typename I, // I ForwardIterator
33 typename O = less> // O modles StrictWeakOrdering
34struct is_member {
35 typedef bool result_type;
36
37 is_member(I f, I l, O o = O()) : first(f), last(l), compare(o) {}
38
39 bool operator()(const typename boost::iterator_value<I>::type& x) const {
40 return binary_search(first, last, x, compare) != last;
41 }
42
46};
47
48template <typename I> // I models ForwardIterator
50 return is_member<I, less>(f, l);
51}
52
53template <typename I, // I models ForwardIterator
54 typename O>
55// O modles StrictWeakOrdering
57 return is_member<I, O>(f, l, o);
58}
59
60template <typename I> // I models ForwardRange
64
65template <typename I, // I models ForwardRange
66 typename O>
67// O modles StrictWeakOrdering
69 return make_is_member(begin(r), end(r), o);
70}
71
73
74/**************************************************************************************************/
75
76} // namespace adobe
77
78/**************************************************************************************************/
79
80#endif
81
82/**************************************************************************************************/
I binary_search(I f, I l, const T &x, C c, P p)
is_member< I, less > make_is_member(I f, I l)
Definition is_member.hpp:49
is_member(I f, I l, O o=O())
Definition is_member.hpp:37
bool operator()(const typename boost::iterator_value< I >::type &x) const
Definition is_member.hpp:39