]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/utility/compare_pointees.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
725697945aa5f7203c32f5d682d1505c4a539341
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / utility / compare_pointees.hpp
1 // Copyright (C) 2003, Fernando Luis Cacciola Carballal.\r
2 //\r
3 // Use, modification, and distribution is subject to the Boost Software\r
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\r
5 // http://www.boost.org/LICENSE_1_0.txt)\r
6 //\r
7 // See http://www.boost.org/lib/optional for documentation.\r
8 //\r
9 // You are welcome to contact the author at:\r
10 //  fernando_cacciola@hotmail.com\r
11 //\r
12 #ifndef BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP\r
13 #define BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP\r
14 \r
15 #include<functional>\r
16 \r
17 namespace boost {\r
18 \r
19 // template<class OP> bool equal_pointees(OP const& x, OP const& y);\r
20 // template<class OP> struct equal_pointees_t;\r
21 //\r
22 // Being OP a model of OptionalPointee (either a pointer or an optional):\r
23 //\r
24 // If both x and y have valid pointees, returns the result of (*x == *y)\r
25 // If only one has a valid pointee, returns false.\r
26 // If none have valid pointees, returns true.\r
27 // No-throw\r
28 template<class OptionalPointee>\r
29 inline\r
30 bool equal_pointees ( OptionalPointee const& x, OptionalPointee const& y )\r
31 {\r
32   return (!x) != (!y) ? false : ( !x ? true : (*x) == (*y) ) ;\r
33 }\r
34 \r
35 template<class OptionalPointee>\r
36 struct equal_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>\r
37 {\r
38   bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const\r
39     { return equal_pointees(x,y) ; }\r
40 } ;\r
41 \r
42 // template<class OP> bool less_pointees(OP const& x, OP const& y);\r
43 // template<class OP> struct less_pointees_t;\r
44 //\r
45 // Being OP a model of OptionalPointee (either a pointer or an optional):\r
46 //\r
47 // If y has not a valid pointee, returns false.\r
48 // ElseIf x has not a valid pointee, returns true.\r
49 // ElseIf both x and y have valid pointees, returns the result of (*x < *y)\r
50 // No-throw\r
51 template<class OptionalPointee>\r
52 inline\r
53 bool less_pointees ( OptionalPointee const& x, OptionalPointee const& y )\r
54 {\r
55   return !y ? false : ( !x ? true : (*x) < (*y) ) ;\r
56 }\r
57 \r
58 template<class OptionalPointee>\r
59 struct less_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>\r
60 {\r
61   bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const\r
62     { return less_pointees(x,y) ; }\r
63 } ;\r
64 \r
65 } // namespace boost\r
66 \r
67 #endif\r
68 \r