Changeset 2285
- Timestamp:
- Jun 27, 2010, 2:24:42 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/utility_test.cc
r2274 r2285 64 64 void test_ptr_compare(test::Suite& suite); 65 65 void test_compose_functors(test::Suite& suite); 66 void test_dereferencer(test::Suite& suite); 66 67 67 68 int main(int argc, char* argv[]) … … 225 226 } 226 227 228 229 void test_dereferencer(test::Suite& suite) 230 { 231 using utility::Dereferencer; 232 Dereferencer<double*> deref; 233 double x = 0; 234 double* px = &x; 235 deref(px) = 1.662; 236 if (!suite.add(x==1.662)) { 237 suite.out() << "test_dereferencer failed: x: " << x << "\n"; 238 } 239 } 227 240 228 241 … … 495 508 496 509 } 510 -
trunk/yat/utility/stl_utility.h
r2275 r2285 49 49 #include <exception> 50 50 #include <functional> 51 #include <iterator> 51 52 #include <map> 52 53 #include <ostream> … … 89 90 inline T operator()(T x) const 90 91 { return std::abs(x); } 92 }; 93 94 95 /** 96 \brief Adaptor between pointer and pointee interface 97 98 Pointer must have an \c operator*, i.e., \c Pointer can be a 99 traditional pointer or an \input_iterator. Return type is decided 100 by <a href=http://www.sgi.com/tech/stl/iterator_traits.html> 101 std::iterator_traits </a>. 102 */ 103 template<typename Pointer> 104 struct Dereferencer : 105 public std::unary_function<Pointer, 106 typename std::iterator_traits<Pointer>::reference> 107 { 108 /** 109 \return * \a ti 110 */ 111 typename std::iterator_traits<Pointer>::reference 112 operator()(Pointer ti) const { return *ti; } 91 113 }; 92 114
Note: See TracChangeset
for help on using the changeset viewer.