stlab.adobe.com Adobe Systems Incorporated
other_of.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 /*************************************************************************************************/
7 
8 #ifndef ADOBE_ALGORITHM_OTHER_OF_HPP
9 #define ADOBE_ALGORITHM_OTHER_OF_HPP
10 
11 #include <adobe/config.hpp>
12 
13 #include <algorithm>
14 
15 /*************************************************************************************************/
16 
17 namespace adobe {
18 
19 /*************************************************************************************************/
28 /*************************************************************************************************/
34 template <typename T, // T models EqualityComparable
35  typename P, // P models pair<T, T>
36  typename BinaryPredicate>
37 inline const T& other_of(const P& pair, const T& x, BinaryPredicate pred)
38 {
39  return pred(pair.first, x) ? pair.second : pair.first;
40 }
41 
47 template <typename T, // T models EqualityComparable
48  typename P> // P models pair<T, T>
49 inline const T& other_of(const P& pair, const T& x)
50 {
51  return other_of(pair, x, std::equal_to<T>());
52 }
53 
54 /*************************************************************************************************/
55 
56 } // namespace adobe
57 
58 /*************************************************************************************************/
59 
60 #endif
61 
62 /*************************************************************************************************/
T1 first
Definition: pair.hpp:77
const T & other_of(const P &pair, const T &x, BinaryPredicate pred)
other_of implementation
Definition: other_of.hpp:37
T2 second
Definition: pair.hpp:78

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google