New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
compare_pointees.hpp in vendors/XIOS/current/extern/boost/include/boost/utility – NEMO

source: vendors/XIOS/current/extern/boost/include/boost/utility/compare_pointees.hpp @ 3428

Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

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