diff --git a/src/solver/variable/include/antares/solver/variable/setofareas.h b/src/solver/variable/include/antares/solver/variable/setofareas.h index 74c68528ba..e6fb86ae5a 100644 --- a/src/solver/variable/include/antares/solver/variable/setofareas.h +++ b/src/solver/variable/include/antares/solver/variable/setofareas.h @@ -115,9 +115,9 @@ class SetsOfAreas /*! ** \brief Default Constructor */ - SetsOfAreas(); + SetsOfAreas() = default; //! Destructor - ~SetsOfAreas(); + ~SetsOfAreas() = default; //@} void initializeFromStudy(Data::Study& study); @@ -198,15 +198,11 @@ class SetsOfAreas public: //! Area list - typedef std::vector SetOfAreasVector; + typedef std::vector> SetOfAreasVector; //! Area list SetOfAreasVector pSetsOfAreas; //! Reference to the origina set std::vector pOriginalSets; - //! An iterator for the begining of the list - typename SetOfAreasVector::iterator pBegin; - //! An iterator to the end of the list - typename SetOfAreasVector::iterator pEnd; //! The study const Data::Study* pStudy; diff --git a/src/solver/variable/include/antares/solver/variable/setofareas.hxx b/src/solver/variable/include/antares/solver/variable/setofareas.hxx index 19e60f2997..e133b06a55 100644 --- a/src/solver/variable/include/antares/solver/variable/setofareas.hxx +++ b/src/solver/variable/include/antares/solver/variable/setofareas.hxx @@ -27,22 +27,6 @@ namespace Solver { namespace Variable { -template -inline SetsOfAreas::SetsOfAreas() -{ - // Do nothing -} - -template -inline SetsOfAreas::~SetsOfAreas() -{ - // Releasing the memory occupied by the areas - for (typename SetOfAreasVector::iterator i = pBegin; i != pEnd; ++i) - { - delete *i; - } -} - template void SetsOfAreas::initializeFromStudy(Data::Study& study) { @@ -74,8 +58,7 @@ void SetsOfAreas::initializeFromStudy(Data::Study& study) continue; } - // Instancing a new set of variables of the area - NextType* n = new NextType(); + auto n = std::make_unique(); // Initialize the variables // From the study @@ -90,8 +73,8 @@ void SetsOfAreas::initializeFromStudy(Data::Study& study) // is variable's column(s) printed in output (set of areas) reports ? n->getPrintStatusFromStudy(study); - // Adding the variables for the area in the list - pSetsOfAreas.push_back(n); + pSetsOfAreas.push_back(std::move(n)); + auto* originalSet = &sets[setIndex]; assert(originalSet != NULL); assert(!originalSet->empty()); @@ -99,10 +82,6 @@ void SetsOfAreas::initializeFromStudy(Data::Study& study) pNames.push_back(setname); } - - // Initializing iterators - pBegin = pSetsOfAreas.begin(); - pEnd = pSetsOfAreas.end(); } template @@ -255,12 +234,12 @@ void SetsOfAreas::buildDigest(SurveyResults& results, int digestLevel, in results.data.area = nullptr; results.data.rowIndex = 0; - for (auto i = pBegin; i != pEnd; ++i) + for (auto& set: pSetsOfAreas) { results.data.columnIndex = 0; results.data.rowCaptions[results.data.rowIndex].clear() << "@ " << pNames[results.data.rowIndex]; - (*i)->buildDigest(results, digestLevel, dataLevel); + set->buildDigest(results, digestLevel, dataLevel); ++results.data.rowIndex; } }