c++ - Using boost.pool instead of 'new' for container of objects -
I am working in that code base, currently this is the code that often does this: < Pre> Should use Bulb Pool Support here? I can imagine doing this (this is a pseudocode, because I'm not sure how to use the pool yet): To avoid this copy and avoid avoiding allocation, however, I code Maintenance has been reduced because there is too much boilerplate involved in adding / removing objects from the vector. I have thought of using the boost with custom deliliter: filter_wector, but not sure if this helps a lot, it helps in cleaning, but I still want to Use custom allocation with std :: vector to understand either because it is already fixed and will not shrink in size. Can anyone understand the "best" solution for this problem? I think what I do is, With such an approach in this way, the number of // In the header: class labels {public: zero parascript (); Private: Letter * M_AramAire; }; // in CPP: Passive Parsext () {Delete} M_IERRE; M_myArray = new letter [string_length]; Basically every time the string changes into a label, we delete the old letters and delete them again. These letter objects are somewhat lightweight, but this is often the case since I
std :: vector & lt; Letter & gt; because each
push_back () will be the result of a copy I also want to avoid copying.
// In the header: class Label {public : void ParseText (); Private: std :: vector & lt; Letter *> M_myArray; Promotion :: object_pool m_pool; }; // CPP: parseText () {// loop through each element in the loop m_myArray and call pool :: free m_myArray.clear (); // Loop each letter and create a new letter object in the container (...) {m_myArray.push_back (m_pool.malloc ()); // Constructor is not sure how to control params / / ......}
pool: : Malloc () has to call while push_backing.
vector to reduce the amount of allocation Use and
resize , and Allow letters to be reused, we have something like this:
// In the header: Class Label {public: void ParseText (); Private: std :: vector & lt; Letter & gt; M_myArray; }; // in CPP: Zero Parsext () {m_myArray.resize (string_length); // [...]
letter items as much as possible is being reused from the previous example < />
Comments
Post a Comment