/* -*- c++ -*- */ /* * Copyright (C) 2009 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef ANDROID_ASTL_FUNCTIONAL__ #define ANDROID_ASTL_FUNCTIONAL__ #if defined(_T) || defined(_Arg) || defined(_Arg1) || defined(_Arg2) || \ defined(_Result) || defined(_Name) || defined(_Op) #error "Macro(s) already defined." #endif namespace std { template <class _Arg, class _Result> struct unary_function { typedef _Arg argument_type; typedef _Result result_type; }; template <class _Arg1, class _Arg2, class _Result> struct binary_function { typedef _Arg1 first_argument_type; typedef _Arg2 second_argument_type; typedef _Result result_type; }; // Comparaison #define FUNCTIONAL_BINARY_COMPARAISON(_Name, _Op) \ template <typename _T> \ struct _Name : public binary_function<_T, _T, bool> \ { \ bool operator()(const _T& left, const _T& right) const \ { return left _Op right; } \ }; FUNCTIONAL_BINARY_COMPARAISON(equal_to, ==) FUNCTIONAL_BINARY_COMPARAISON(not_equal_to, !=) FUNCTIONAL_BINARY_COMPARAISON(greater, >) FUNCTIONAL_BINARY_COMPARAISON(less, <) FUNCTIONAL_BINARY_COMPARAISON(greater_equal, >=) FUNCTIONAL_BINARY_COMPARAISON(less_equal, <=) } // namespace std #endif // ANDROID_ASTL_FUNCTIONAL__