So I'm working on implementing saving and reading for my current game I'm using PugiXML for reading and writing.
It's gone rather smoothly 'till recently, i needed a vector of XML documents, so i could store the information for the last few game map files that have been used. But pugiXML didnt like me stuffing documents into a vector dynamically, so i messed with things a bit and now its a vector of unique_ptr 's which i figured should work, but now even though everything compiles and no exceptions are thrown during runtime it seems like when i use push_back() it seems like the document is being deleted as soon as its being created and i have no clue as to why. ill post the code I've got below, any help is as always appreciated
#include "pugixml.hpp"
#include <vector>
#include <memory>
std::vector<std::unique_ptr<pugi::xml_document>> mapFile;
std::string mapFileName = "test.xml";
mapFile.push_back(std::unique_ptr<pugi::xml_document>(new pugi::xml_document()));//even after this call size is remaining 0
pugi::xml_parse_result result = mapFile[mapFile.size() - 1]->load_file(mapFileName.c_str());
if(!result)
{
std::cout<< "Load result: "<< result.description()<< ", mesh name: "<< mapFile[mapFile.size() - 1]->child("mesh").attribute("name").value()<< "\n";
try
{throw;}
catch(std::exception e)
{
std::cout<<"Error: Failed to find "<< mapName << " the file was either moved or damaged.\n";
}
}