이 코드 조각은 VS 2013에서 완벽하게 작동하지만 VS 2015로 업데이트해야합니다. 그러면 오류가 발생합니다.VS 2015에서 C2664 오류가 발생하여 VS 2013에서 작동합니다.
나는 https://msdn.microsoft.com/en-us/library/s5b150wd.aspx을 읽었으며 꽤 많이 봤지만 아직 해결 방법을 모르고있다.
저는 수학 수학을하기 위해 고유 수학 라이브러리를 사용하고 있습니다. Eigen의 Vector3d 클래스는 컨테이너의 키로 사용할 수 없으므로이 문제를 해결하기 위해 자체 Vector3dLite 클래스를 만들었습니다.
error C2664: cannot convert argument 1 from 'std::pair<Vector3dLite,int>' to 'std::pair<const _Kty,_Ty> &&'
with
[
_Kty=Vector3dLite,
_Ty=int,
_Pr=std::less<Vector3dLite>,
_Alloc=std::allocator<std::pair<const Vector3dLite,int>>
]
and
[
_Kty=Vector3dLite,
_Ty=int
]
내가 Vector3dLite 객체 전에 CONST를 작성하려고 않았지만 분명히 구문이 올바르지 않습니다 : 컴파일러는 다음 오류를
map<Vector3dLite, int> VertexIds;
int unique_vertid = 0;
VertexIds.insert(make_pair(Vector3dLite(tri.Vert1), unique_vertid)); //This line
// Vert1 is an eigen Vector3d object
//...
을 던지는 컴파일러 오류 어디
class Vector3dLite
{
public:
float VertX, VertY,VertZ;
Vector3dLite(Vector3d& InputVert)
{
VertX = static_cast<float>(InputVert.x());
VertY = static_cast<float>(InputVert.y());
VertZ = static_cast<float>(InputVert.z());
}
Vector3dLite(Vector3dLite& InputVert)
{
VertX = InputVert.VertX;
VertY = InputVert.VertY;
VertZ = InputVert.VertZ;
}
//more operator overloading stuff below
}
는 여기에 있습니다.
VertexIds.insert (make_pair (const Vector3dLite (tri.Vert1), unique_vertid)));
또 다른 방법은 'emplace'를 사용하여'VertexIds.emplace (tri.Vert1, unique_vertid); '와 같은 것을 사용하여 페어를 구성하는 것입니다. –