distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
CopyConstructQueueFunctor.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_COPYCONSTRUCTQUEUEFUNCTOR_HPP_
13 #define INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_COPYCONSTRUCTQUEUEFUNCTOR_HPP_
14 
16 
17 namespace distortos
18 {
19 
20 namespace internal
21 {
22 
29 template<typename T>
31 {
32 public:
33 
40  constexpr explicit CopyConstructQueueFunctor(const T& value) :
41  value_{value}
42  {
43 
44  }
45 
52  void operator()(void* const storage) const override
53  {
54  new (storage) T{value_};
55  }
56 
57 private:
58 
60  const T& value_;
61 };
62 
63 } // namespace internal
64 
65 } // namespace distortos
66 
67 #endif // INCLUDE_DISTORTOS_INTERNAL_SYNCHRONIZATION_COPYCONSTRUCTQUEUEFUNCTOR_HPP_
void operator()(void *const storage) const override
Copy-constructs the element in the queue's storage.
Definition: CopyConstructQueueFunctor.hpp:52
Top-level namespace of distortos project.
Definition: buttons.hpp:33
Definition: CopyConstructQueueFunctor.hpp:30
QueueFunctor class header.
const T & value_
reference to object that will be used as argument of copy constructor
Definition: CopyConstructQueueFunctor.hpp:60
constexpr CopyConstructQueueFunctor(const T &value)
CopyConstructQueueFunctor's constructor.
Definition: CopyConstructQueueFunctor.hpp:40
QueueFunctor is a type-erased interface for functors which execute some action on queue's storage (li...
Definition: QueueFunctor.hpp:31