std::vector 处没有可行的重载“=”
No viable overloaded '=' at std::vector
我有以下类型的 c++ 程序:
typedef pcl::PointXYZI PointType;
typedef pcl::PointCloud<PointType> PointCloudType;
typedef std::vector<PointCloudType::Ptr> CloudPtrList;
主要是这个:
CloudPtrList clusterPtr(2);
for (int i = 0; i < clusterPtr.size(); ++i)
{
clusterPtr[i] = boost::make_shared<PointCloudType>();
}
当我尝试初始化这个向量(上面的)时,我不断收到这个错误“没有可行的重载=”
clusterPtr[i] = boost::make_shared<PointCloudType>();
这是完整的错误:
No viable overloaded '='
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3737:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'const std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3748:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3745:9: Candidate template ignored: could not match 'std::__1::shared_ptr' against 'boost::shared_ptr'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3756:9: Candidate template ignored: could not match 'std::__1::shared_ptr' against 'boost::shared_ptr'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3766:9: Candidate template ignored: could not match 'auto_ptr' against 'shared_ptr'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3790:9: Candidate template ignored: could not match 'unique_ptr' against 'shared_ptr'
从报错信息中可以看出...
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3737:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'const std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3748:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
...您正在使用较新版本的 PCL
,其中 boost::shared_ptr
已被 std::shared_ptr
取代:
#include <pcl/common/projection_matrix.h>
#include <pcl/point_types.h>
//#include <boost/make_shared.hpp> // boost::make_shared
#include <memory> // std::make_shared
typedef pcl::PointCloud<pcl::PointXYZI> PointCloudType;
int main() {
std::vector<PointCloudType::Ptr> clusterPtr(2);
for(int i = 0; i < clusterPtr.size(); ++i) {
clusterPtr[i] = std::make_shared<PointCloudType>(); // std::make_shared
}
}
我有以下类型的 c++ 程序:
typedef pcl::PointXYZI PointType;
typedef pcl::PointCloud<PointType> PointCloudType;
typedef std::vector<PointCloudType::Ptr> CloudPtrList;
主要是这个:
CloudPtrList clusterPtr(2);
for (int i = 0; i < clusterPtr.size(); ++i)
{
clusterPtr[i] = boost::make_shared<PointCloudType>();
}
当我尝试初始化这个向量(上面的)时,我不断收到这个错误“没有可行的重载=”
clusterPtr[i] = boost::make_shared<PointCloudType>();
这是完整的错误:
No viable overloaded '='
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3737:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'const std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3748:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3745:9: Candidate template ignored: could not match 'std::__1::shared_ptr' against 'boost::shared_ptr'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3756:9: Candidate template ignored: could not match 'std::__1::shared_ptr' against 'boost::shared_ptr'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3766:9: Candidate template ignored: could not match 'auto_ptr' against 'shared_ptr'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3790:9: Candidate template ignored: could not match 'unique_ptr' against 'shared_ptr'
从报错信息中可以看出...
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3737:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'const std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:3748:17: Candidate function not viable: no known conversion from 'typename boost::detail::sp_if_not_array<PointCloud<PointXYZI> >::type' (aka 'shared_ptr<pcl::PointCloud<pcl::PointXYZI> >') to 'std::__1::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >' for 1st argument
...您正在使用较新版本的 PCL
,其中 boost::shared_ptr
已被 std::shared_ptr
取代:
#include <pcl/common/projection_matrix.h>
#include <pcl/point_types.h>
//#include <boost/make_shared.hpp> // boost::make_shared
#include <memory> // std::make_shared
typedef pcl::PointCloud<pcl::PointXYZI> PointCloudType;
int main() {
std::vector<PointCloudType::Ptr> clusterPtr(2);
for(int i = 0; i < clusterPtr.size(); ++i) {
clusterPtr[i] = std::make_shared<PointCloudType>(); // std::make_shared
}
}