compare_pointees.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
00002 //
00003 // Use, modification, and distribution is subject to the Boost Software
00004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00005 // http://www.boost.org/LICENSE_1_0.txt)
00006 //
00007 // See http://www.boost.org/lib/optional for documentation.
00008 //
00009 // You are welcome to contact the author at:
00010 //  fernando_cacciola@hotmail.com
00011 //
00012 #ifndef BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP
00013 #define BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP
00014 
00015 #include<functional>
00016 
00017 namespace boost {
00018 
00019 // template<class OP> bool equal_pointees(OP const& x, OP const& y);
00020 // template<class OP> struct equal_pointees_t;
00021 //
00022 // Being OP a model of OptionalPointee (either a pointer or an optional):
00023 //
00024 // If both x and y have valid pointees, returns the result of (*x == *y)
00025 // If only one has a valid pointee, returns false.
00026 // If none have valid pointees, returns true.
00027 // No-throw
00028 template<class OptionalPointee>
00029 inline
00030 bool equal_pointees ( OptionalPointee const& x, OptionalPointee const& y )
00031 {
00032   return (!x) != (!y) ? false : ( !x ? true : (*x) == (*y) ) ;
00033 }
00034 
00035 template<class OptionalPointee>
00036 struct equal_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>
00037 {
00038   bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
00039     { return equal_pointees(x,y) ; }
00040 } ;
00041 
00042 // template<class OP> bool less_pointees(OP const& x, OP const& y);
00043 // template<class OP> struct less_pointees_t;
00044 //
00045 // Being OP a model of OptionalPointee (either a pointer or an optional):
00046 //
00047 // If y has not a valid pointee, returns false.
00048 // ElseIf x has not a valid pointee, returns true.
00049 // ElseIf both x and y have valid pointees, returns the result of (*x < *y)
00050 // No-throw
00051 template<class OptionalPointee>
00052 inline
00053 bool less_pointees ( OptionalPointee const& x, OptionalPointee const& y )
00054 {
00055   return !y ? false : ( !x ? true : (*x) < (*y) ) ;
00056 }
00057 
00058 template<class OptionalPointee>
00059 struct less_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>
00060 {
00061   bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
00062     { return less_pointees(x,y) ; }
00063 } ;
00064 
00065 } // namespace boost
00066 
00067 #endif
00068 

Generated on Wed Jan 21 15:32:10 2009 for SystemC by  doxygen 1.5.5