I built a C++ wrapper around the FreeRTOS timer API. My class statically allocates the timer control block which is operated by a FreeRTOS thread in the background. This means that if I move or copy this object, the control block will be moved/copied as well BUT the thread wont notice that. Because of that I consider the object non-copyable and non-movable.
Here's the outline:
#include <cstdint>
#include <concepts>
template <std::invocable Cb>
class timer
{
public:
timer() = default;
timer(Cb cb, TickType_t timer_period, bool auto_reload = false)
: cb_{ cb }
{
xTimerCreateStatic("timer", timer_period, auto_reload, static_cast<void*>(this), &timer::timer_expired_cb, &buf_);
}
timer(const timer&) = delete;
timer(timer&&) = delete;
auto operator=(const timer&) = delete;
auto operator=(timer&&) = delete;
// ...
private:
Cb cb_;
TimerHandle_t handle_;
StaticTimer_t buf_;
};
Now I want to push multiple of this timer objects into a C++ container which I can dynamically extend or shrink as objects enter or leave the container. Is there a stdlib container that doesn't require objects to be moveable or copyable and still provides all the functionality?