Visual studio 2012编译Tbb40关于std::Copy_exception的错误解决

问题:编译时出现错误:

d:\tbb40_20120613oss\include\tbb\tbb_exception.h(357) : error C2039: “copy_exception”: 不是“std”的成员
d:\tbb40_20120613oss\include\tbb\tbb_exception.h(357) : error C3861: “copy_exception”: 找不到标识符

 

搜索结果:http://software.intel.com/en-us/forums/showthread.php?t=105837

 

Visual Studio 2012

I'm trying out the release candidate of Visual Studio 2012. tbb_exception.h does not compile due to use of std::copy_exception(). I'm having a hard time finding any info on this method. Is it really part of the std namespace? Will VS2012 be supported soon?
Thanks,
Paul
 

Vladimir Polin (Intel)June 8, 2012 11:28 PM PDT
Rate
 
Visual Studio 2012

Hello, you are right, 
the issue is the same for clang ( http://software.intel.com/en-us/forums/showthread.php?t=102603&o=a&s=lr), C++x0 std::copy_exception was renamed to std::make_exception_ptr in final version of C++11 standard. So you need to either rename it in the header or define /DTBB_USE_CAPTURED_EXCEPTION=1 to not use exception_ptr like for old compilers.
We are working on how is better to support both cases at once (i.e. vs2010 and vs2012).
thanks for the report
--Vladimir
Update - details on the issue:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1130
 

Sergey KostrovJune 9, 2012 4:22 PM PDT
Rate
 
Visual Studio 2012

Quoting paul3579
I'm trying out the release candidate of Visual Studio 2012. tbb_exception.h does not compile due to use of std::copy_exception(). I'm having a hard time finding any info on this method. Is it really part of the std namespace?

I just done verifications with different versions/editions of  Visual Studio and MinGW. Here are results:

     - Visual Studio 2005 Professional Edition - 'copy_exception' is not supported

     - Visual Studio 2008 Express Edition - 'copy_exception' is not supported

     - Visual Studio 2010 Express Edition - 'copy_exception' is  supported in ' exception' header file

     - MinGW v3.4.2 - 'copy_exception' is not supported

I don't think that Microsoft will remove that support in Visual Studio 2012.
 

简单解决办法(可能不规范):

更改该.h中

tbb_exception_ptr ( const captured_exception& src ) : my_ptr(std::copy_exception(src)) {}

tbb_exception_ptr ( const captured_exception& src ) : my_ptr(NULL) {}

问题解决,但可能爆异常时有问题!

加速这一段代码例程#include <thread> #include <mutex> // 用于保护m_vpdEdgePoints和m_vdEdgeGradient的锁 std::mutex g_mutex; void process_edges(const cv::Mat& RoiMat, const std::vectorcv::Point2d& m_vpdEquinoxPoints, const double m_dMeasureLength, const double m_dMeasureHeight, const double m_dSigma, const int m_nThresholdCircle, const int m_nTranslationCircle, const std::vector<double>& m_vdMeasureAngle, std::vectorcv::Point2d& m_vpdEdgePoints, std::vector<double>& m_vdEdgeGradient, int start_idx, int end_idx, Extract1DEdgeCircle Extract1DEdgeCircle) { std::vector<Edge1D_Result> edges; for (int i = start_idx; i < end_idx; i++) { edges = Extract1DEdgeCircle.Get1DEdge(RoiMat, m_vpdEquinoxPoints[i], m_dMeasureLength, m_dMeasureHeight,m_vdMeasureAngle[i], m_dSigma, m_nThresholdCircle, m_nTranslationCircle == 1 ? Translation::Poisitive : Translation::Negative, Selection::Strongest); // 使用锁保护m_vpdEdgePoints和m_vdEdgeGradient //std::lock_guardstd::mutex lock(g_mutex); for (int j = 0; j < edges.size(); j++) { m_vpdEdgePoints.push_back(edges[j].m_pdEdgePoint); m_vdEdgeGradient.push_back(edges[j].m_dGradient); } } } int main() { int m = m_vpdEquinoxPoints.size(); const int num_threads = 10; std::vectorstd::thread threads(num_threads); std::vectorstd::vectorcv::Point2d edge_points(num_threads); std::vector<std::vector<double>> edge_gradients(num_threads); for (int i = 0; i < num_threads; i++) { int start_idx = i * m / num_threads; int end_idx = (i + 1) * m / num_threads; threads[i] = std::thread(process_edges, std::ref(RoiMat), std::ref(m_vpdEquinoxPoints), m_dMeasureLength, m_dMeasureHeight, m_dSigma, m_nThresholdCircle, m_nTranslationCircle, std::ref(m_vdMeasureAngle), std::ref(edge_points[i]), std::ref(edge_gradients[i]), start_idx, end_idx, Extract1DEdgeCircle); } for (int i = 0; i < num_threads; i++) { threads[i].join(); // 合并结果 m_vpdEdgePoints.insert(m_vpdEdgePoints.end(), edge_points[i].begin(), edge_points[i].end()); m_vdEdgeGradient.insert(m_vdEdgeGradient.end(), edge_gradients[i].begin(), edge_gradients[i].end()); } return 0; }
最新发布
05-25
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值