stlab.adobe.com Adobe Systems Incorporated

other_of.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 /*************************************************************************************************/
00007 
00008 #ifndef ADOBE_ALGORITHM_OTHER_OF_HPP
00009 #define ADOBE_ALGORITHM_OTHER_OF_HPP
00010 
00011 #include <adobe/config.hpp>
00012 
00013 #include <algorithm>
00014 
00015 /*************************************************************************************************/
00016 
00017 namespace adobe {
00018 
00019 /*************************************************************************************************/
00028 /*************************************************************************************************/
00034 template <typename T, // T models EqualityComparable
00035           typename P, // P models pair<T, T>
00036           typename BinaryPredicate>
00037 inline const T& other_of(const P& pair, const T& x, BinaryPredicate pred)
00038 {
00039     return pred(pair.first, x) ? pair.second : pair.first;
00040 }
00041 
00047 template <typename T, // T models EqualityComparable
00048           typename P> // P models pair<T, T>
00049 inline const T& other_of(const P& pair, const T& x)
00050 {
00051     return other_of(pair, x, std::equal_to<T>());
00052 }
00053 
00054 /*************************************************************************************************/
00055 
00056 } // namespace adobe
00057 
00058 /*************************************************************************************************/
00059 
00060 #endif
00061 
00062 /*************************************************************************************************/

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