Hello developers,
I have currently the following problem: I want to use the SmartPointer
with an array type datatype e.g. char[13].
The following contructors are implemented:
1.) SmartPointer ()
default constructor with empty payload
2.) SmartPointer (uint8_t size)
Allocates memory from the given size.
3.) template<typename T >
SmartPointer (const T *data)
4.) SmartPointer (const SmartPointer &other)
The third variant is not useable with pointer type data, because the
memory gets only calculated for the size of the pointer.
So the next solution would be to use variant 2, but then there is no way
to fill the data array. There are only getter functions and no setter
functions. Thus i would suggest to add another constructor type
template<typename T >
SmartPointer(const T *data, int size) which allocates size*sizeof(T)
memory. For this solutions also getter functions with a size parameter
have to be added. The pointer is not type-safe anyway. If you can think
up a better solution, please tell me.
If you are ok with this solution, I will implement it as soon as possible.
Best Regards,
Thorsten Lajewski