Added LLVM notice.
[oota-llvm.git] / include / Support / iterator
1 //===-- Support/iterator - "Portable" wrapper around <iterator> -*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides a wrapper around the mysterious <iterator> header file.
11 // In GCC 2.95.3, the file defines a bidirectional_iterator class (and other
12 // friends), instead of the standard iterator class.  In GCC 3.1, the
13 // bidirectional_iterator class got moved out and the new, standards compliant,
14 // iterator<> class was added.  Because there is nothing that we can do to get
15 // correct behavior on both compilers, we have this header with #ifdef's.  Gross
16 // huh?
17 //
18 // By #includ'ing this file, you get the contents of <iterator> plus the
19 // following classes in the global namespace:
20 //
21 //   1. bidirectional_iterator
22 //   2. forward_iterator
23 //
24 //===----------------------------------------------------------------------===//
25
26 #ifndef SUPPORT_ITERATOR
27 #define SUPPORT_ITERATOR
28
29 #include "Config/config.h"
30
31 #include <iterator>
32
33 //////////////////////////////////////////////////////////////////////////////
34 // If the bidirectional iterator is not defined, attempt to define it using
35 // the C++ standard iterator.
36 //////////////////////////////////////////////////////////////////////////////
37 #ifndef HAVE_BI_ITERATOR
38 #ifdef HAVE_STD_ITERATOR
39
40 // Define stupid wrappers around std::iterator...
41 template<class Ty, class PtrDiffTy>
42 struct bidirectional_iterator
43   : public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> {
44 };
45
46 #else
47 #error "Need to have standard iterator to define bidirectional iterator!"
48 #endif
49
50 #else
51
52 // Just use bidirectional_iterator directly.
53 using std::bidirectional_iterator;
54
55 #endif
56
57 //////////////////////////////////////////////////////////////////////////////
58 // If the forward iterator is not defined, attempt to define it using the
59 // C++ standard iterator.
60 //////////////////////////////////////////////////////////////////////////////
61 #ifndef HAVE_FWD_ITERATOR
62 #ifdef HAVE_STD_ITERATOR
63 template<class Ty, class PtrDiffTy>
64 struct forward_iterator
65   : public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> {
66 };
67 #else
68 #error "Need to have standard iterator to define forward iterator!"
69 #endif
70 #else
71 // Just use forward iterator directly.
72 using std::forward_iterator;
73 #endif
74
75
76 #endif