需要对c++脚本进行修复(而不是我的)

Need a fix for c++ script (not mine)

本文关键字:我的 c++ 脚本      更新时间:2023-10-16

我在试图构建的脚本中有以下代码。

typedef std::vector< typename Sphere::vec_type > VV; 
typedef typename Sphere::vec_type vec_type; 
VV v( count , s.dimension() ); 
for ( int ii=0; ii<count; ++ii ) { 
v[ii] = randomPointOnSurface( s ); 

它会产生以下错误:

error: no matching function for call to 'std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >::_M_fill_initialize(size_t, int&)'
/usr/include/c++/4.4/bits/stl_vector.h:1033: note: candidates are: void std::vector<_Tp, _Alloc>::_M_fill_initialize(size_t, const _Tp&) [with _Tp = std::vector<float, std::allocator<float> >, _Alloc = std::allocator<std::vector<float, std::allocator<float> > >]

解决方法是删除s.dimensions(),但有其他方法可以解决吗?

您有一个嵌套的向量,所以您需要类似的东西

VV v( count , vec_type(s.dimension()) ); 

这将每个CCD_ 1内部向量初始化为具有大小CCD_。