我有一个SARavesphnp()
定义为类型的函数:
std::unordered_map<unsigned, std::unordered_map<unsigned, std::unordered_map<unsigned, double>>>;
但是,当我尝试返回相同类型的变量时,我收到此错误:
error: could not convert '(mat3d (*)[(long int)y2][(long int)z2])(& SARave)' from 'mat3d (*)[(long int)y2][(long int)z2] {aka std::unordered_map<unsigned int, std::unordered_map<unsigned int, std::unordered_map<unsigned int, double> > > (*)[(long int)y2][(long int)z2]}' to 'mat3d {aka std::unordered_map<unsigned int, std::unordered_map<unsigned int, std::unordered_map<unsigned int, double> > >}'
这是我的代码:
#include <unordered_map>
using mat3d = std::unordered_map<unsigned, std::unordered_map<unsigned, std::unordered_map<unsigned, double>>>;
mat3d foo(const int, const int, const int);
int main()
{
foo(10, 10, 10);
return 0;
}
mat3d foo(const int x2, const int y2, const int z2)
{
mat3d SARave[x2][y2][z2];
return SARave;
}