Adobe Source Libraries 2.0.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
other_of.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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
17namespace adobe {
18
19/**************************************************************************************************/
28/**************************************************************************************************/
34template <typename T, // T models EqualityComparable
35 typename P, // P models pair<T, T>
36 typename BinaryPredicate>
37inline const T& other_of(const P& pair, const T& x, BinaryPredicate pred) {
38 return pred(pair.first, x) ? pair.second : pair.first;
39}
40
46template <typename T, // T models EqualityComparable
47 typename P>
48// P models pair<T, T>
49inline const T& other_of(const P& pair, const T& x) {
50 return other_of(pair, x, std::equal_to<T>());
51}
52
53/**************************************************************************************************/
54
55} // namespace adobe
56
57/**************************************************************************************************/
58
59#endif
60
61/**************************************************************************************************/
const T & other_of(const P &pair, const T &x, BinaryPredicate pred)
other_of implementation
Definition other_of.hpp:37