55df8ce2643e58bc794036f887623120d4f9b541
[oota-llvm.git] / include / llvm / ADT / iterator.cmake
1 //===-- llvm/ADT/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 // The #if directives' expressions are filled in by Autoconf.
25 //
26 //===----------------------------------------------------------------------===//
27
28 #ifndef LLVM_ADT_ITERATOR
29 #define LLVM_ADT_ITERATOR
30
31 #include <iterator>
32
33 #undef HAVE_BI_ITERATOR
34 #undef HAVE_STD_ITERATOR
35 #undef HAVE_FWD_ITERATOR
36
37 // defined by Kevin
38 #define HAVE_STD_ITERATOR 1
39
40 #ifdef _MSC_VER
41 #  define HAVE_BI_ITERATOR 0
42 #  define HAVE_STD_ITERATOR 1
43 #  define HAVE_FWD_ITERATOR 0
44 #endif
45
46 #if !HAVE_BI_ITERATOR
47 # if HAVE_STD_ITERATOR
48 /// If the bidirectional iterator is not defined, we attempt to define it in
49 /// terms of the C++ standard iterator. Otherwise, we import it with a "using"
50 /// statement.
51 ///
52 template<class Ty, class PtrDiffTy>
53 struct bidirectional_iterator
54   : public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> {
55 };
56 # else
57 #  error "Need to have standard iterator to define bidirectional iterator!"
58 # endif
59 #else
60 using std::bidirectional_iterator;
61 #endif
62
63 #if !HAVE_FWD_ITERATOR
64 # if HAVE_STD_ITERATOR
65 /// If the forward iterator is not defined, attempt to define it in terms of
66 /// the C++ standard iterator. Otherwise, we import it with a "using" statement.
67 ///
68 template<class Ty, class PtrDiffTy>
69 struct forward_iterator
70   : public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> {
71 };
72 # else
73 #  error "Need to have standard iterator to define forward iterator!"
74 # endif
75 #else
76 using std::forward_iterator;
77 #endif
78
79 #endif