1 //===-- Support/iterator - "Portable" wrapper around <iterator> -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
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
18 // By #includ'ing this file, you get the contents of <iterator> plus the
19 // following classes in the global namespace:
21 // 1. bidirectional_iterator
22 // 2. forward_iterator
24 // The #if directives' expressions are filled in by Autoconf.
26 //===----------------------------------------------------------------------===//
28 #ifndef SUPPORT_ITERATOR
29 #define SUPPORT_ITERATOR
33 #if !@HAVE_BI_ITERATOR@
34 # if @HAVE_STD_ITERATOR@
35 /// If the bidirectional iterator is not defined, we attempt to define it in
36 /// terms of the C++ standard iterator. Otherwise, we import it with a "using"
39 template<class Ty, class PtrDiffTy>
40 struct bidirectional_iterator
41 : public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> {
44 # error "Need to have standard iterator to define bidirectional iterator!"
47 using std::bidirectional_iterator;
50 #if !@HAVE_FWD_ITERATOR@
51 # if @HAVE_STD_ITERATOR@
52 /// If the forward iterator is not defined, attempt to define it in terms of
53 /// the C++ standard iterator. Otherwise, we import it with a "using" statement.
55 template<class Ty, class PtrDiffTy>
56 struct forward_iterator
57 : public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> {
60 # error "Need to have standard iterator to define forward iterator!"
63 using std::forward_iterator;