我有两个矩阵类,一个用于 CPU,一个用于 GPU,分别是Matrix和CudaMatrix。声明和定义位于文件.h、.cpp和. 在 中,我有.cuh.cumain
Matrix<int2_> foo1(1,2);
// Definition of the elements of foo1...
CudaMatrix<int2_> foo2(1,2);
cout << typeid(foo1).name() << "\n";
cout << typeid(foo2).name() << "\n";
// Equality
foo2=foo1;
现在,我在 a和 a之间没有operator=重载,但是我有以下重载CudaMatrixMatrixoperator=
const CudaMatrix& operator=(const CudaMatrix<LibraryNameSpace::int2_>&);
两者之间CudaMatrix。会发生以下情况:
- 这两个
typeid返回正确的类foo1和foo2; - 上面的
operator=重载是在运行时编译和调用的,用于foo2=foo1赋值。相反,我会预料到会出现编译错误; - 分配的结果导致正确的结果
foo2!
我正在使用 Visual Studio 2010 并在发布模式下编译。
任何人都对为什么会发生这种明显不合逻辑的行为有一些提示?
谢谢。