I have class like this:
template<size_t MAX_SIZE>
struct Buffer{
size_t size;
char data[MAX_SIZE]; // this must be inside the struct itself
constexpr static size_t max_size = MAX_SIZE;
};
I need to be able to pass this class to function that must not use template, currently I am doing something like this:
void process(size_t &size, char *data, size_t max_size);
int main(){
Buffer<1024> b;
process(b.size, b.data, b.max_size);
}
Is there better way to do the same? I can think about base class, and pass by reference, but it get too complicated to be correct.
(This is not actual code, please do not pay attention if there are syntax errors.)
Aucun commentaire:
Enregistrer un commentaire