BWAPI
|
00001 // Copyright (c) 1998-2003 ETH Zurich (Switzerland). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00005 // the terms of the Q Public License version 1.0. 00006 // See the file LICENSE.QPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Matrix_search/include/CGAL/Transform_iterator.h $ 00015 // $Id: Transform_iterator.h 28567 2006-02-16 14:30:13Z lsaboret $ 00016 // 00017 // 00018 // Author(s) : Michael Hoffmann <hoffmann@inf.ethz.ch> 00019 00020 #ifndef CGAL_TRANSFORM_ITERATOR_H 00021 #define CGAL_TRANSFORM_ITERATOR_H 00022 00023 #include <CGAL/Optimisation/assertions.h> 00024 #include <CGAL/circulator_bases.h> 00025 #include <iterator> 00026 00027 namespace std { 00028 struct _Unchecked_iterator_tag; 00029 }; 00030 00031 00032 CGAL_BEGIN_NAMESPACE 00033 00034 template < class OutputIterator, class Operation > 00035 struct Transform_iterator { 00036 // Workaround. Added this non standard iterator category for VC8. 00037 // Strange that no other iterator complains about this "feature" missing 00038 typedef std::_Unchecked_iterator_tag _Checked_iterator_category; 00039 typedef std::output_iterator_tag iterator_category; 00040 typedef Transform_iterator< OutputIterator, Operation > self; 00041 typedef typename Operation::argument_type argument_type; 00042 00043 typedef typename std::iterator_traits<OutputIterator>::difference_type difference_type; 00044 typedef typename std::iterator_traits<OutputIterator>::value_type value_type; 00045 typedef typename std::iterator_traits<OutputIterator>::pointer pointer; 00046 typedef typename std::iterator_traits<OutputIterator>::reference reference; 00047 00048 Transform_iterator( const OutputIterator& o, 00049 const Operation& op) 00050 : o_( o), op_( op) 00051 {} 00052 00053 operator OutputIterator() { return o_; } 00054 00055 self& operator*() { return *this; } 00056 00057 self& operator++() { return *this; } 00058 00059 self& operator++( int) { return *this; } 00060 00061 self& operator=( const argument_type& a) { 00062 *(o_++) = op_( a); 00063 return *this; 00064 } 00065 00066 private: 00067 OutputIterator o_; 00068 Operation op_; 00069 }; 00070 00071 template < class OutputIterator, class Operation > inline 00072 Transform_iterator< OutputIterator, Operation > 00073 transform_iterator( const OutputIterator& o, 00074 const Operation& op) 00075 { return Transform_iterator< OutputIterator, Operation >( o, op); } 00076 00077 template < class OutputIterator, class Operation > inline 00078 Iterator_tag 00079 query_circulator_or_iterator( 00080 const Transform_iterator< OutputIterator, Operation >&) 00081 { return Iterator_tag(); } 00082 00083 CGAL_END_NAMESPACE 00084 00085 #endif // CGAL_TRANSFORM_ITERATOR_H