I create many times I use class DataBuffer in many places in code, so it should be fast and lightweight. Moreover I use various buffer sizes, so to reduce memory allocations I wrote such template:
template<unsigned int T_buffer_size> class DataBuffer
{
public:
DataBuffer (const unsigned int &buffer_size);
char buffer [T_buffer_size];
const unsigned int buffer_size;
};
The problem is, that i have to copy DataBuffer objects few times. That's why I'm wondering if move constructor can help here. Is there an easy way to move my 'buffer' array between objects?
It's easy to implement this class:
class DataBuffer
{
public:
DataBuffer (const unsigned int &buffer_size);
char *buffer;
const unsigned int buffer_size;
};
But because 'buffer' is a regular pointer it takes more time to access data stored inside it...