Flow123d  DF_patch_fe_data_tables-522f93f
range_wrapper.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file range_wrapper.hh
15  * @brief Implementation of range helper class.
16  */
17 
18 #ifndef RANGE_WRAPPER_HH_
19 #define RANGE_WRAPPER_HH_
20 
22 
23 /**
24  * @brief Range helper class.
25  *
26  * Allow iterate in bounds given by begin and end iterator. Class can be used for iterable accessor classes.
27  *
28  * Template argument:
29  * - ObjectIn Type over its instances is iterated,
30  * - ObjectOut Operators '*' and '->' returns objects of this type.
31  *
32  * Require the template object to implement:
33  * - ObjectIn must be implicitly convertible to ObjectOut type.
34  */
35 template<class ObjectIn, class ObjectOut>
37 {
38 public:
39  /// Constructor.
41  : begin_(begin), end_(end) {}
42 
43  /// Iterator to begin item of range.
45  return begin_;
46  }
47 
48  /// Iterator to end item of range.
50  return end_;
51  }
52 
53 private:
56 };
57 
58 
59 /**
60  * @brief Range helper class.
61  *
62  * Same as previous but doesn't provide specialization of operators '*' and '->'.
63  */
64 template<class Object>
65 class Range
66 {
67 public:
68  /// Constructor.
70  : begin_(begin), end_(end) {}
71 
72  /// Iterator to begin item of range.
74  return begin_;
75  }
76 
77  /// Iterator to end item of range.
79  return end_;
80  }
81 
82 private:
85 };
86 
87 
88 #endif // RANGE_WRAPPER_HH_
General iterator template. Provides iterator over objects of type ObjectIn in some container....
General iterator template. Provides iterator over objects of type Object in some container.
Range helper class.
RangeConvert(IterConvert< ObjectIn, ObjectOut > begin, IterConvert< ObjectIn, ObjectOut > end)
Constructor.
IterConvert< ObjectIn, ObjectOut > begin_
IterConvert< ObjectIn, ObjectOut > begin()
Iterator to begin item of range.
IterConvert< ObjectIn, ObjectOut > end_
IterConvert< ObjectIn, ObjectOut > end()
Iterator to end item of range.
Range helper class.
Iter< Object > end_
Iter< Object > end()
Iterator to end item of range.
Range(Iter< Object > begin, Iter< Object > end)
Constructor.
Iter< Object > begin_
Iter< Object > begin()
Iterator to begin item of range.
Template Iter serves as general template for internal iterators.