vendredi 26 août 2016

How to do a factory of const objects

This is not a question about dlib, but a question on how to implement a feature on dlib.

Dlib has a virtual class dlib::tensor, and an implementation of it named dlib::alias_tensor_instance. Objects of this class are constructed by calling operator()(dlib::tensor &original, size_t offset) on the factory class dlib::alias_tensor, that will create a dlib::alias_tensor_instance pointing to a internal slice of the original tensor, that can be used wherever a tensor is required, without actually copying it.

Since it is very common to const dlib::tensor& to be passed around, I am interested on a overload of the factory operator taking a const:

<something> operator()(const dlib::tensor &original, size_t offset);

Trouble is, neither I nor the author knows how it can be done properly. Do you guys knows of any solution? Here is the GitHub issue.

Aucun commentaire:

Enregistrer un commentaire