paramxx  1.0.7
stlPtrWrapper.h
1 #ifndef STLPTRWRAPPER_H
2 #define STLPTRWRAPPER_H
3 
4 // --8<--8<--8<--8<--
5 //
6 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
7 //
8 // This file is part of paramxx
9 //
10 // paramxx is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License
12 // as published by the Free Software Foundation; either version 2
13 // of the License, or (at your option) any later version.
14 //
15 // paramxx is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the
22 // Free Software Foundation, Inc.
23 // 51 Franklin Street, Fifth Floor
24 // Boston, MA 02110-1301, USA
25 //
26 // -->8-->8-->8-->8--
27 
28 #include <algorithm>
29 
30 using namespace std;
31 
35 template <class Type>
37 
38  friend ostream& operator << ( ostream& os, stlPtrWrapper<Type>& a ) {
39  os << a( );
40  return os;
41  }
42 
43  friend ostream& operator << ( ostream& os, stlPtrWrapper<Type>* a ) {
44  os << (*a)( );
45  return os;
46  }
47 
48  friend bool operator == (const stlPtrWrapper<Type>& xw1,
49  const stlPtrWrapper<Type>& xw2) {
50  return (xw1.operator()() && xw2.operator()()) ? xw1() == xw2() : false;
51  }
52 
53  friend bool operator < (const stlPtrWrapper<Type>& xw1,
54  const stlPtrWrapper<Type>& xw2) {
55  return (xw1() && xw2()) ? xw1() < xw2() : false;
56  }
57 
58 public:
59 
60  stlPtrWrapper( Type x = 0 ) : val( x ) { }
61 
62  stlPtrWrapper( const stlPtrWrapper<Type>& xxx ) : val( xxx.val ) { }
63 
64  // purposely left blank
65  ~stlPtrWrapper() { }
66 
67  stlPtrWrapper& operator = ( const stlPtrWrapper<Type>& rhs ) {
68 
69  if ( this == &rhs )
70  return *this;
71 
72  val = rhs.val;
73  return *this;
74 
75  }
76 
77  const Type operator( ) () const { return val; }
78 
79  Type operator( ) () { return val; }
80 
81 private:
82 
83  Type val;
84 
85 };
86 
87 #endif
STL namespace.
Definition: stlPtrWrapper.h:36