dune-common  2.11
iteratorrange.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5 #ifndef DUNE_COMMON_ITERATORRANGE_HH
6 #define DUNE_COMMON_ITERATORRANGE_HH
7 
8 namespace Dune {
9 
11 
24  template<typename Iterator, typename Sentinel=Iterator>
26  {
27 
28  public:
29 
31  typedef Iterator iterator;
32 
34  typedef Sentinel sentinel;
35 
37 
40  typedef Iterator const_iterator;
41 
43  IteratorRange(const Iterator& begin, const Sentinel& end)
44  : begin_(begin)
45  , end_(end)
46  {}
47 
50  {}
51 
53  iterator begin() const
54  {
55  return begin_;
56  }
57 
59  sentinel end() const
60  {
61  return end_;
62  }
63 
64  private:
65 
66  Iterator begin_;
67  Sentinel end_;
68 
69  };
70 
71 }
72 
73 #endif // DUNE_COMMON_ITERATORRANGE_HH
IteratorRange()
Default constructor, relies on iterators being default-constructible.
Definition: iteratorrange.hh:49
iterator begin() const
Returns an iterator pointing to the begin of the range.
Definition: iteratorrange.hh:53
Iterator const_iterator
The iterator belonging to this range.
Definition: iteratorrange.hh:40
Sentinel sentinel
The iterator belonging to this range.
Definition: iteratorrange.hh:34
Dune namespace
Definition: alignedallocator.hh:12
IteratorRange(const Iterator &begin, const Sentinel &end)
Constructs an iterator range on [begin,end).
Definition: iteratorrange.hh:43
sentinel end() const
Returns an iterator pointing past the end of the range.
Definition: iteratorrange.hh:59
Simple range between a begin and an end iterator.
Definition: iteratorrange.hh:25
Iterator iterator
The iterator belonging to this range.
Definition: iteratorrange.hh:31