I'm experiencing a problem at the moment where apparently I am Attempting to reference a deleted function. As far as I can see, I'm not actually referencing a function but a smart pointer to a struct.
This is a university project whereupon multiple header files and CPP files are being used to allow us to understand how to use multiple files in the same project and link them together along with understanding and making use of polymorphism. We are using multiple files as the brief states we must. The files and definitions were provided for us.
The following is supposed to conduct a "Breadth-first" search on a terrain map (array of numbers ranging from 0-3) from a starting location to the goal location. It is about path-finding.
This is what I have so far:
#include "SearchBreadthfirst.h" // Declaration of this class #include <iostream> #include <list> using namespace std; bool CSearchBreadthFirst::FindPath(TerrainMap& terrain, unique_ptr<SNode> start, unique_ptr<SNode> goal, NodeList& path) { // Initialise Lists NodeList closedList; // Closed list of nodes NodeList openList; // Open list of nodes unique_ptr<SNode>currentNode(new SNode); // Allows the current node to be stored unique_ptr<SNode>nextNode(new SNode); // Allows the next nodes to be stored in the open list // Boolean Variables bool goalFound = false; // Returns true when the goal is found // Start Search openList.push_front(move(start)); // Push the start node onto the open list // If there is data in the open list and the goal hasn't ben found while (!openList.empty() || goalFound == false) { cout << endl << "Open list front:" << openList.front() << endl; currentNode->x = openList.front()->x; currentNode->y = openList.front()->y; currentNode->score = openList.front()->score; currentNode->parent = openList.front()->parent; } } It's highlighting this line: currentNode->x = openList.front()->x; as the problem.
The NodeList type is defined in SearchBreadthfirst.h as the following:
using NodeList = deque<unique_ptr<SNode>>;
SNode is also defined in SearchBreadthfirst.h as such:
struct SNode { int x; // x coordinate int y; // y coordinate int score; // used in more complex algorithms SNode* parent = 0; // note use of raw pointer here }; The program breaks upon build. I've been trying to wrap my head around this for days now, so any help is greatly appreciated. If I've missed anything out, let me know and I'll add it in!
James
CSearchBreadthFirst,TerrainMap, andunique_ptrare undefined.