このコードは VS 2013 では完全に機能していましたが、VS 2015 に更新する必要があり、エラーが発生しました。
https://msdn.microsoft.com/en-us/library/s5b150wd.aspxを読み、かなりグーグルで検索しましたが、これを修正する方法はまだわかりません。
固有数学ライブラリを使用して、3D 数学を実行しています。Eigen の Vector3d クラスはコンテナーのキーとして使用できないため、この問題を回避するために独自の Vector3dLite クラスを作成しました。
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
}
コンパイラがエラーをスローする場所は次のとおりです
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
//...
コンパイラエラーは次のとおりです。
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 を記述しようとしましたが、明らかに構文が正しくありません。
VertexIds.insert(make_pair(const Vector3dLite(tri.Vert1), unique_vertid));