I've got class Functions
.
It contains of: static std::map<vector2d, double> functionValues;
Also I created my own vector2d
clsss.
So, when I try to insert
/emplace
or add element through using of operator[]
from member function of Function
class into this map
it fails.
So, the error code is C2676. I found no answear, so really appreciate any suggestions what can cause this problem.
enter image description here
Here is some code:
#pragma once
#include "vector2d.h"
#include <map>
extern unsigned int functionCallCounts;
class Function
{
private:
static std::map<vector2d, double> functionValues;
static int coef;
public:
inline static void setCoef(int _coef) { coef = _coef; };
static double calcFunction(vector2d _point);
};
#include "Function.h"
#include <cmath>
std::map<vector2d, double> Function::functionValues;
int Function::coef;
unsigned int functionCallCounts;
double Function::calcFunction(vector2d _point)
{
for (auto e : functionValues)
{
if (_point == e.first)
{
return e.second;
}
}
double functionValue = 2 * pow((_point.x - coef), 2) - _point.x * _point.y + 5 * pow(_point.y, 2);
++functionCallCounts;
functionValues.insert(std::make_pair(_point, functionValue));
return functionValue;
}
And vector2d
class vector2d
{
public:
double x;
double y;
vector2d operator* (double coef);
vector2d operator+ (vector2d v2);
vector2d operator- (vector2d v2);
vector2d operator* (vector2d v2);
vector2d operator/ (vector2d v2);
vector2d operator/ (double devideBy);
double magnitude() const;
double distance(const vector2d& vec2d) const;
vector2d normalizedVec();
void makeNormalized();
vector2d();
vector2d(double _x, double _y);
bool operator== (const vector2d v2) const;
friend vector2d operator*(const double coef, vector2d& v);
};