The use of std::map find is throwing compiler error C2675 and I can't figure out why

Viewed 26

Why is my find failing to compile for the class below? Error reads: Severity Code Description Project File Line Suppression State Error C2675 unary '++': '_Iter' does not define this operator or a conversion to a type acceptable to the predefined operator PlayspaceForDataStructures C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\xtree 1259

#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;

class Tag
{
private:
    string name;
    map<string, string> attributes;
public:
    Tag()
    {
        name = "";
    }
    Tag(string inName)
    {
        name = inName;
    }
    Tag(Tag& inTag)
    {
        name = inTag.GetName();
        attributes = inTag.getMap();
        
    }
    string GetName() { return name; }
    void SetName(string inName) { name = inName; }
    void AddAttribute(string inName, string inValue)
    {
        attributes.insert(inName, inValue);

    }
    map<string, string> getMap() { return attributes; }
    string GetValueByName(string inName)
    {
        auto it = attributes.find(inName);
        if (it != attributes.end())
            return it->second;
        else return "";
        
    }

};
0 Answers
Related