initialiser.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_CONTAINERS_INITIALISER_HPP_
13 #define ECL_CONTAINERS_INITIALISER_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include <cstddef> // size_t
20 #include "definitions.hpp"
21 #include <ecl/config/macros.hpp>
23 
24 /*****************************************************************************
25 ** Namespaces
26 *****************************************************************************/
27 
28 namespace ecl {
29 namespace containers {
30 
31 /*****************************************************************************
32 ** Interface [BoundedListInitialiser]
33 *****************************************************************************/
48 template<class Type, class Iterator, std::size_t N = ecl::DynamicStorage>
50 
51  public:
58  BoundedListInitialiser(const Type &value, Iterator iter);
59 
61 
73 
74  protected:
75  Iterator iterator;
76  std::size_t current_size;
77 };
78 
79 /*****************************************************************************
80 ** Implementation [BoundedListInitialiser]
81 *****************************************************************************/
82 
83 template <typename Type, typename Iterator, std::size_t N>
85  iterator(iter),
86  current_size(1)
87 {
88  *iterator = value;
89  ++iterator;
90 }
91 template <typename Type,typename Iterator,std::size_t N>
93 {
95  *iterator = value;
96  iterator++;
97  current_size++;
98  return *this;
99 }
100 
101 /*****************************************************************************
102 ** Interface [BoundedListInitialiser][Dynamic]
103 *****************************************************************************/
116 template<class Type, class Iterator>
118 
119  public:
129  BoundedListInitialiser(const Type &value, Iterator iter, std::size_t bound) ecl_assert_throw_decl(StandardException);
130 
143 
144  protected:
145  Iterator iterator;
146  std::size_t current_size;
147  const std::size_t upper_bound;
148 };
149 
150 /*****************************************************************************
151 ** Implementation [BoundedListInitialiser]
152 *****************************************************************************/
153 
154 template <typename Type, typename Iterator>
156  iterator(iter),
157  current_size(1),
158  upper_bound(bound)
159 {
161  *iterator = value;
162  ++iterator;
163 }
164 template <typename Type,typename Iterator>
166 {
168  *iterator = value;
169  iterator++;
170  current_size++;
171  return *this;
172 }
173 
174 }; // namespace containers
175 }; // namespace ecl
176 
177 #endif /* ECL_CONTAINERS_INITIALISER_HPP_ */
Embedded control libraries.
Some common container definitions.
Convenience initialiser with bounds checking for dynamic containers.
#define LOC
BoundedListInitialiser< Type, Iterator, N > & operator,(const Type &value) ecl_assert_throw_decl(StandardException)
Definition: initialiser.hpp:92
#define ecl_assert_throw(expression, exception)
OutOfRangeError
BoundedListInitialiser(const Type &value, Iterator iter)
Definition: initialiser.hpp:84
Convenience initialiser with bounds checking for fixed size containers.
Definition: initialiser.hpp:49
#define ecl_assert_throw_decl(exception)
#define ECL_LOCAL


ecl_containers
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:30