containers.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_CONCEPTS_CONCEPTS_CONTAINERS_HPP_
13 #define ECL_CONCEPTS_CONCEPTS_CONTAINERS_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include <ecl/config/ecl.hpp>
21 #include "macros.hpp"
22 
23 /*****************************************************************************
24 ** Namespaces
25 *****************************************************************************/
26 
27 namespace ecl {
28 
29 /*****************************************************************************
30 ** Concept [Container]
31 *****************************************************************************/
32 
36 template <typename Implementation>
37 class ContainerConcept {
38 public:
39 
50  ecl_compile_time_concept_test(ContainerConcept)
51  {
52  iter = container.begin();
53  iter = container.end();
54  unsigned int n;
55  n = container.size();
56  (void) n; // remove set but not used warnings.
57  }
58 
59 private:
60  // Putting instantiations here actually saves instantiation (which can cause a
61  // problem if there is no default constructor).
62  Implementation container;
63  typename Implementation::iterator iter;
64 };
68 template <typename Implementation>
70 public:
71 
84  {
85  iter = container.begin();
86  iter = container.end();
87  unsigned int n;
88  n = container.size();
89  container.resize(1);
90  (void) n; // remove set but not used warnings.
91  }
92 
93 private:
94  // Putting instantiations here actually saves instantiation (which can cause a
95  // problem if there is no default constructor).
96  Implementation container;
97  typename Implementation::iterator iter;
98 };
99 
103 namespace concepts {
104 
114 template <typename T, bool Result=false>
115 class SignedByteTest {
116 private:
117  SignedByteTest() {}
118 };
119 
129 template <typename T>
130 class SignedByteTest<T,true> {
131 public:
132  SignedByteTest() {}
133 };
134 
144 template <typename T, bool Result=false>
145 class UnsignedByteTest {
146 private:
147  UnsignedByteTest() {}
148 };
149 
159 template <typename T>
160 class UnsignedByteTest<T,true> {
161 public:
162  UnsignedByteTest() {}
163 };
164 
171 template <typename T>
172 class SignedByteTestCheck : public SignedByteTest<T, ecl::is_signed_byte<T>::value > {};
173 
180 template <typename T>
181 class UnsignedByteTestCheck : public UnsignedByteTest<T, ecl::is_unsigned_byte<T>::value > {};
182 
191 template <typename T>
192 class ByteTest {
193 private:
194  ByteTest() {}
195 };
196 
205 template <>
206 class ByteTest<unsigned char> {
207 public:
208  ByteTest() {}
209 };
213 template <>
214 class ByteTest<char> {
215 public:
216  ByteTest() {}
217 };
218 
222 template <>
223 class ByteTest<signed char> {
224 public:
225  ByteTest() {}
226 };
227 
228 } // namespace concepts
236 template <typename Implementation>
238 public:
239 
250  {
251  typedef typename Implementation::value_type element_type;
252  iter = container.begin();
253  iter = container.end();
254  unsigned int n;
255  n = container.size();
256  // If not a char, this results in a private call -> compile time error!
257  concepts::UnsignedByteTestCheck<element_type> char_test;
258  (void) n; // remove set but unused warnings.
259  }
260 
261 private:
262  // Putting instantiations here actually saves instantiation (which can cause a
263  // problem if there is no default constructor).
264  Implementation container;
265  typename Implementation::iterator iter;
266 };
267 
271 template <typename Implementation>
273 public:
274 
285  {
286  typedef typename Implementation::value_type element_type;
287  iter = container.begin();
288  iter = container.end();
289  unsigned int n;
290  n = container.size();
291  // If not a char, this results in a private call -> compile time error!
292  concepts::SignedByteTestCheck<element_type> char_test;
293  }
294 
295 private:
296  // Putting instantiations here actually saves instantiation (which can cause a
297  // problem if there is no default constructor).
298  Implementation container;
299  typename Implementation::iterator iter;
300 };
301 
307 template <typename Implementation>
308 class ByteContainerConcept {
309 public:
310 
320  ecl_compile_time_concept_test(ByteContainerConcept)
321  {
322  typedef typename Implementation::value_type element_type;
323  iter = container.begin();
324  iter = container.end();
325  unsigned int n;
326  n = container.size();
327  // If not a char, this results in a private call -> compile time error!
328  concepts::ByteTest<element_type> char_test;
329  (void) n; // remove set but unused warnings.
330  }
331 
332 private:
333  // Putting instantiations here actually saves instantiation (which can cause a
334  // problem if there is no default constructor).
335  Implementation container;
336  typename Implementation::iterator iter;
337 };
338 
339 }; // namespace ecl
340 
341 #endif /* ECL_CONCEPTS_CONCEPTS_CONTAINERS_HPP_ */
ecl::UnsignedByteContainerConcept::container
Implementation container
Definition: containers.hpp:270
ecl::DynamicContainerConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(DynamicContainerConcept)
Implements a concept test for containers.
Definition: containers.hpp:89
ecl::SignedByteContainerConcept::container
Implementation container
Definition: containers.hpp:304
ecl::ContainerConcept::container
Implementation container
Definition: containers.hpp:76
ecl::ContainerConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(ContainerConcept)
Implements a concept test for containers.
Definition: containers.hpp:64
ecl::DynamicContainerConcept::container
Implementation container
Definition: containers.hpp:102
ecl::UnsignedByteContainerConcept::iter
Implementation::iterator iter
Definition: containers.hpp:271
ecl::ByteContainerConcept::container
Implementation container
Definition: containers.hpp:341
ecl::SignedByteContainerConcept
Defines validating functionality for the signed byte container concept.
Definition: containers.hpp:278
macros.hpp
Mechanisms enabling compile time checking of metaprogramming concepts.
ecl::UnsignedByteContainerConcept
Defines validating functionality for the byte container concept.
Definition: containers.hpp:243
ecl::SignedByteContainerConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(SignedByteContainerConcept)
Implements a concept test for byte containers.
Definition: containers.hpp:290
ecl::ContainerConcept::iter
Implementation::iterator iter
Definition: containers.hpp:77
ecl::UnsignedByteContainerConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(UnsignedByteContainerConcept)
Implements a concept test for byte containers.
Definition: containers.hpp:255
ecl::ByteContainerConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(ByteContainerConcept)
Implements a concept test for byte containers.
Definition: containers.hpp:326
fundamental_types.hpp
ecl::ByteContainerConcept::iter
Implementation::iterator iter
Definition: containers.hpp:342
ecl::DynamicContainerConcept
Defines validating functionality for the dynamic container concept.
Definition: containers.hpp:75
ecl::SignedByteContainerConcept::iter
Implementation::iterator iter
Definition: containers.hpp:305
ecl::DynamicContainerConcept::iter
Implementation::iterator iter
Definition: containers.hpp:103
ecl
Embedded control libraries.


ecl_concepts
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:24