Inside my struct called "S_html_attr_value", I have overloaded the == operator, using the following code:
Now, I attempted to make use of it using the following code:Code:bool operator== (const S_html_attr_value& attrValue) { if (attrValue.content == this->content) { return true; } return false; }
where "ATTR_NAME" is to be replaced with a given attribute's name (i.e. I don't actually use that in the code). attr_values_iterator is a typedef for a map<S_browser, TYPE_attr_values>::const_iterator. TYPE_attr_values is a typedef for a vector<S_html_attr_value>. So essentially, what I'm doing in the code is using a map iterator to iterate through the map, and then for each map element, I iterate through it->second (which is a vector, of course). I compare it->second.at(i) (which is either a const_reference S_html_attr_value, or a reference S_html_attr_value, depending on which at() function is being called of the vector) with attrValue which is a const S_html_attr_value&.Code:for (attr_values_iterator it = ATTR_NAME.supported_attr_values.begin(); it != ATTR_NAME.supported_attr_values.end(); it++) { for (size_t i = 0; i < it->second.size(); i++) { if (it->second.at(i) == attrValue) { attr_value_is_supported = true; break; } } if (attr_value_is_supported) break; }
Therefore, I do not understand the compile error that I get for the red text which says the following:
Why is this invalid?error: passing ‘const S_html_attr_value’ as ‘this’ argument of ‘bool S_html_attr_value::operator==(const S_html_attr_value&)’ discards qualifiers



LinkBack URL
About LinkBacks





perator ==(const T& b) const;
