Answer the question
In order to leave comments, you need to log in
Do I need to optimize the use of temporary wrappers?
To make it easier to work with the code, I wrote a small class that encapsulates the buffer and its size (something like NSData in Cocoa). Everywhere where it is necessary to work with the data buffer I use this class.
The problem is that there are places in the code where I directly (usually from a third-party API) get the buffer and its size, and I need to pass this data to a function that accepts objects of my buffer class. Now for these purposes I create a temporary variable that wraps the data. I don't like this approach - using temporary objects at least requires calling an extra destructor, which is not really necessary in my case. Making method sets for transferring encapsulated data directly is also not a good idea.
I heard that there is an approach in which we create global objects that serve to transfer the wrapped data. The question is: is this approach really used, and if so, how to implement it as correctly as possible in C++?
Answer the question
In order to leave comments, you need to log in
requires calling an extra destructorIs it so scary and hits performance hard in your case? In the case of a move, the destructor of the moved object generally doesn't have to do anything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question