错误:没有名为&#39; value_type&#39; in&#39; class boost :: shared_ptr <const pcl :: pointcloud <pcl :: pointxyz =“”>&gt;&#39;

时间:2016-11-04 04:40:36

标签: c++ templates point-cloud-library

我有一些代码如下所示:

typedef pcl::PointXYZRGB pcl_ColorPointType;
typedef pcl::PointXYZ pcl_PointType;
typedef pcl::PointCloud<pcl_PointType> pcl_XYZPointCloudType;
typedef pcl::PointCloud<pcl_ColorPointType> pcl_ColorPointCloudType;
typedef pcl_XYZPointCloudType::Ptr pcl_XYZPointCloudPtrType;
typedef pcl_ColorPointCloudType::Ptr pcl_ColorPointCloudPtrType;

void
BuildMeshFromDepthImage()
{
    pcl_XYZPointCloudConstPtrType pointCloud = BuildPurePointCloudFromDepthImage( ); // assume BuildPurePointCloudFromDepthImage function exists
    BuildMeshFromPointCloud<pcl_XYZPointCloudConstPtrType>( pointCloud );
}

template<typename T_pclPtr>
void BuildMeshFromPointCloud(const T_pclPtr &pointCloud )
{
    // some code

    // error: no type named 'value_type'
    const typename T_pclPtr::value_type::PointType& pt = pointCloud->points[i]; 

    // some code
}

知道为什么这不起作用?附:此代码适用于VS2010,但不适用于GCC4.9。可能是因为不同版本的PCL库?

1 个答案:

答案 0 :(得分:1)

来自pcl::PointCloud< PointT > Class Template Reference

typedef boost::shared_ptr< PointCloud< PointT > >   Ptr

Boost.SharedPtr

  当T不是数组类型时,

element_type是T,当T是U []或U [N]时,

是U.

这就是你需要的:

typename T_pclPtr::element_type::PointType& t= pointCloud->points[i];

对于C ++ 11或更高版本,您可以使用:

auto t= pointCloud->points[i];