boost::shared_ptr中没有名为value_type的类型
No type named value_type in boost::shared_ptr
我试图创建一个元组的向量,然后从函数中返回这个向量,但我得到了大量的错误,这些错误似乎与我传递pcl::PointCloudColorHandler作为元组的参数有关。具体来说,相关的错误是:
error: no type named 'value_type' in 'boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> >'
我的问题是,为什么不允许这种行为?下面是我的代码:
std::vector<std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr>, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>::Ptr > Map::getCloudColoredReal(){
std::vector<std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>::Ptr > changed_clouds;
try{
for(int i = 0; i < addedFiles.size(); i++){
if(associatedClouds.find(addedFiles[i].getPCDFileName()) != associatedClouds.end()){
pcl::PointCloud<pcl::PointXYZRGB> cloud(associatedClouds.find(addedFiles[i].getPCDFileName())->second);
pcl::PointCloud<PointXYZRGBAI> cloudInfo(masterClouds.find(addedFiles[i].getPCDFileName())->second);
for(int j = 0; j < cloud.points.size(); j++){
uint32_t red = (cloudInfo.points[j].rgba >> 16) & (0x0000ff);
uint32_t green = (cloudInfo.points[j].rgba >> 8) & (0x0000ff);
uint32_t blue = (cloudInfo.points[j].rgba) & (0x0000ff);
cloud.points[j].r = red;
cloud.points[j].g = green;
cloud.points[j].b = blue;
}
pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr constCloud(&cloud);
pcl::visualization::PointCloudColorHandlerRGBField::Ptr rgbHandler(&constCloud);
std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>::Ptr > tup = std::make_tuple(addedFiles[i].getPCDFileName(), constCloud, &rgbHandler);
changed_clouds.push_back(tup);
}
}
}
catch(std::exception& e){
std::cout << "Color Mode not set to real." << std::endl;
}
return changed_clouds;
}
完全错误:
In file included from /Users/wfehrnstrom/CmakeTest/dataViewerWidget.cpp:1:
In file included from /Users/wfehrnstrom/CmakeTest/dataViewerWidget.h:5:
In file included from /usr/local/include/vtk-7.0/QVTKWidget.h:39:
In file included from /usr/local/include/vtk-7.0/vtkGUISupportQtModule.h:36:
In file included from /usr/local/include/vtk-7.0/vtkInteractionStyleModule.h:36:
In file included from /usr/local/include/vtk-7.0/vtkRenderingCoreModule.h:40:
In file included from /usr/local/include/vtk-7.0/vtkAutoInit.h:18:
In file included from /usr/local/include/vtk-7.0/vtkDebugLeaksManager.h:26:
In file included from /usr/local/include/vtk-7.0/vtkSystemIncludes.h:36:
In file included from /usr/local/include/vtk-7.0/vtkIOStream.h:28:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:439:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:628:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1456:38: error: no type named 'value_type' in 'boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> >'
typedef typename allocator_type::value_type value_type;
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:337:22: note: in instantiation of template class 'std::__1::allocator_traits<boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >' requested here
typedef typename __alloc_traits::size_type size_type;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:458:15: note: in instantiation of template class 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >' requested here
: private __vector_base<_Tp, _Allocator>
^
/Users/wfehrnstrom/CmakeTest/dataViewerWidget.cpp:56:196: note: in instantiation of template class 'std::__1::vector<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >' requested here
std::vector<std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > > clouds_in_map = m_maps.at(i).getCloudColoredReal();
^
In file included from /Users/wfehrnstrom/CmakeTest/dataViewerWidget.cpp:1:
In file included from /Users/wfehrnstrom/CmakeTest/dataViewerWidget.h:5:
In file included from /usr/local/include/vtk-7.0/QVTKWidget.h:40:
In file included from /usr/local/include/vtk-7.0/QVTKInteractor.h:43:
In file included from /Users/wfehrnstrom/Qt5/5.7/clang_64/lib/QtCore.framework/Headers/QObject:1:
In file included from /Users/wfehrnstrom/Qt5/5.7/clang_64/lib/QtCore.framework/Headers/qobject.h:54:
In file included from /Users/wfehrnstrom/Qt5/5.7/clang_64/lib/QtCore.framework/Headers/qmetatype.h:55:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:467:30: error: '__alloc_traits' is a protected member of 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >'
typedef typename __base::__alloc_traits __alloc_traits;
^
/Users/wfehrnstrom/CmakeTest/dataViewerWidget.cpp:56:196: note: in instantiation of template class 'std::__1::vector<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >' requested here
std::vector<std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > > clouds_in_map = m_maps.at(i).getCloudColoredReal();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:334:54: note: declared protected here
typedef allocator_traits<allocator_type> __alloc_traits;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:468:30: error: 'reference' is a protected member of 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >'
typedef typename __base::reference reference;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:335:54: note: declared protected here
typedef value_type& reference;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:469:30: error: 'const_reference' is a protected member of 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >'
typedef typename __base::const_reference const_reference;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:336:54: note: declared protected here
typedef const value_type& const_reference;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:470:30: error: 'size_type' is a protected member of 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >'
typedef typename __base::size_type size_type;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:337:54: note: declared protected here
typedef typename __alloc_traits::size_type size_type;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:471:30: error: 'difference_type' is a protected member of 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >'
typedef typename __base::difference_type difference_type;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:338:54: note: declared protected here
typedef typename __alloc_traits::difference_type difference_type;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:472:30: error: 'pointer' is a protected member of 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >'
typedef typename __base::pointer pointer;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:339:54: note: declared protected here
typedef typename __alloc_traits::pointer pointer;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:473:30: error: 'const_pointer' is a protected member of 'std::__1::__vector_base<std::__1::tuple<std::__1::basic_string<char>, boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGB> > >, boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> > >'
typedef typename __base::const_pointer const_pointer;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:340:54: note: declared protected here
typedef typename __alloc_traits::const_pointer const_pointer;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/vector:479:53: error: no type named 'value_type' in 'boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> >'
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
9 errors generated.
看起来你缺少或放错了位置右尖括号:
std::vector<std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr >, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>::Ptr >
^ - wrong place for bracket
改为
std::vector<std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>::Ptr > >
^
和
std::vector<std::tuple<std::string, pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr, pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB>::Ptr > >
missing ? -^
相关文章:
- 瓦尔格林德:数学函数"Conditional jump or move depends on uninitialised value(s)"
- 使用 [] 运算符时"binding reference of type discards qualifiers"
- 为什么static_assert错误:即使我传递常量"expression must have a constant value"?
- 在 QVector<std::unique_ptr 上使用 std::find<Type>>
- 在类型和包装器之间reinterpret_cast是否安全<Type>?
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 控制到达非空函数clang(-Wreturn-type)的末尾
- 为什么我会" void value not ignored as it ought to be"?
- std::unordered_map 类型对象声明期间出现"field has incomplete type"错误
- 方法错误"not all control paths return a value"和方法不返回值
- 将系数存储在头文件的数组中("does not name a type"错误)
- 尝试打开 ifstream 时出现"Incomplete type"错误
- C++/SDL "initial value of reference to a non-const must be an lvalue"
- 将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
- 在"结构提升::enable_if<提升::is_pod<T>,无效>"中没有名为"type"的类型
- 如何修复" State Error (active) E0513 a value of type "const wchar_t *" cannot be assigned to an entity o
- "a value of type " void (exeCallback::*)(int) " cannot be assigned to an entity of type " void (*)(
- cmake -D <var>:<type>=<value> 参数"-D"是什么意思
- 没有用于初始化'value type'的匹配构造函数
- new(size, value) Type[0]返回的指针是否合法,是否可以用来构建数组?