У меня большой проект, над которым я работаю, и он продолжает давать мне
ошибку C3889: < /p>
error C3889: call to object of class type 'std::equal_to': no matching call operator found
note: could be 'unknown-type std::equal_to::operator ()(_Ty1 &&,_Ty2 &&) noexcept() const'
note: Failed to specialize function template 'unknown-type std::equal_to::operator ()(_Ty1 &&,_Ty2 &&) noexcept() const'
note: With the following template arguments:
note: '_Ty1=const _Ty &'
note: '_Ty2=const _Ty &'
note: binary '==': 'const _Ty' does not define this operator or a conversion to a type acceptable to the predefined operator
with
[
_Ty=Spot
]
< /code>
Я использую код Visual Studio 2022. < /p>
Вот mre: < /p>
#include
#include
template
bool isin(T i, const std::vector& vec) {
for (const T& t : vec) {
if (i == t) return true;
}
return false;
}
template
std::vector GetAllUniqueCombos(const std::vector& arr) {
std::vector n;
for (int i = 0; i < arr.size(); ++i) {
for (int j = i + 1; j < arr.size(); ++j) {
if (!isin({ arr, arr[j] }, n))n.push_back({ arr, arr[j] });
}
}
return n;
}
struct Spot {
int x, y;
};
void DrawTriangle(Spot s1, Spot s2, Spot s3, int color);
void DrawPolygon(const std::vector& points, int color) {
if (points.size() < 3) return;
std::vector a;
for (int j = 1; j < points.size(); j++) {
a.push_back(points[j]);
}
for (auto i : GetAllUniqueCombos(a)) {
DrawTriangle(points[0], i[0], i[1], color);
}
}
int main() {
DrawPolygon({ {25, 25}, {50, 50}, {25, 50}, {50, 25} }, 0xffaa55);
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... ual-tovoid