Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:30

0001 // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
0002 //
0003 // Use, modification, and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/optional for documentation.
0008 //
0009 // You are welcome to contact the author at:
0010 //  fernando_cacciola@hotmail.com
0011 //
0012 #ifndef BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP
0013 #define BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP
0014 
0015 #include<functional>
0016 
0017 namespace boost {
0018 
0019 // template<class OP> bool equal_pointees(OP const& x, OP const& y);
0020 // template<class OP> struct equal_pointees_t;
0021 //
0022 // Being OP a model of OptionalPointee (either a pointer or an optional):
0023 //
0024 // If both x and y have valid pointees, returns the result of (*x == *y)
0025 // If only one has a valid pointee, returns false.
0026 // If none have valid pointees, returns true.
0027 // No-throw
0028 template<class OptionalPointee>
0029 inline
0030 bool equal_pointees ( OptionalPointee const& x, OptionalPointee const& y )
0031 {
0032   return (!x) != (!y) ? false : ( !x ? true : (*x) == (*y) ) ;
0033 }
0034 
0035 template<class OptionalPointee>
0036 struct equal_pointees_t
0037 {
0038   typedef bool result_type;
0039   typedef OptionalPointee first_argument_type;
0040   typedef OptionalPointee second_argument_type;
0041 
0042   bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
0043     { return equal_pointees(x,y) ; }
0044 } ;
0045 
0046 // template<class OP> bool less_pointees(OP const& x, OP const& y);
0047 // template<class OP> struct less_pointees_t;
0048 //
0049 // Being OP a model of OptionalPointee (either a pointer or an optional):
0050 //
0051 // If y has not a valid pointee, returns false.
0052 // ElseIf x has not a valid pointee, returns true.
0053 // ElseIf both x and y have valid pointees, returns the result of (*x < *y)
0054 // No-throw
0055 template<class OptionalPointee>
0056 inline
0057 bool less_pointees ( OptionalPointee const& x, OptionalPointee const& y )
0058 {
0059   return !y ? false : ( !x ? true : (*x) < (*y) ) ;
0060 }
0061 
0062 template<class OptionalPointee>
0063 struct less_pointees_t
0064 {
0065   typedef bool result_type;
0066   typedef OptionalPointee first_argument_type;
0067   typedef OptionalPointee second_argument_type;
0068 
0069   bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
0070     { return less_pointees(x,y) ; }
0071 } ;
0072 
0073 } // namespace boost
0074 
0075 #endif
0076