mercredi 4 décembre 2019

std::vector error with allocator when accessing member functions

I'm getting an error when trying to access the size of a std::vector of Employee objects. I'm not really sure what is causing it.

My best guess is that it might have something to do with the fact that the typeid of a new vector of Employees and that of the one that is giving me errors are different. I couldn't find anything online about either of these typeids.

currentLLNode = new LLNode();
currentLLNode = data->getFirstCombo();

std::string s1 = typeid(currentLLNode->employees).name();
std::vector<Employee*> employees;
std::string s2 = typeid(employees).name();        // Outputs NSt3__16vectorIP8EmployeeNS_9allocatorIS2_EEEE
std::string s3 = typeid(currentLLNode).name();    // Outputs FNSt3__16vectorIP8EmployeeNS_9allocatorIS2_EEEE

Note: trying to recreate this resulted in both of them having the same output, so maybe its not the issue but I thought I'd mention it.

The error is usually raised when I try to save the employees generated from data->getFirstCombo() to another std::vector<Employee*> variable or try to access a member function of the vector.

0   zelkins.WorkHoursCalculator     0x000000010176a0cc std::__1::vector<Employee*, std::__1::allocator<Employee*> >::size() const + 12 (vector:657)
1   zelkins.WorkHoursCalculator     0x000000010176b569 std::__1::vector<Employee*, std::__1::allocator<Employee*> >::vector(std::__1::vector<Employee*, std::__1::allocator<Employee*> > const&) + 73 (vector:1249)
2   zelkins.WorkHoursCalculator     0x000000010176981d std::__1::vector<Employee*, std::__1::allocator<Employee*> >::vector(std::__1::vector<Employee*, std::__1::allocator<Employee*> > const&) + 29 (vector:1255)

Potentially relevant info about the involved classes:

Schedule Class (data in the above code snippet)

public:
    LLNode *getFirstCombo() { return employeeCombos->getStartNode(); }
private:
    CircularLL *employeeCombos;

LLNode Struct

struct LLNode {
    std::vector<Employee*> employees;

    LLNode *next;
    LLNode *last;
};

CicularLL Class (employeeCombos in Schedule Class)

public:
    LLNode *getStartNode() { return start; }       
private:
    LLNode *start;

Aucun commentaire:

Enregistrer un commentaire