当将std :: vector移至lambda表达式中并引发lambda表达式时,我在使用lang 8.0时遇到双重崩溃。其他编译器(例如gcc或clang 7)的可执行文件正在运行,没有错误。
我在代码中做非法行为吗?
template<typename F>
void myExecute(F&& f)
{
f();
}
int main()
{
try {
std::vector<double> test = {0.0, 1.0};
myExecute([v = std::move(test)]() {
throw std::runtime_error("exception");
});
}
catch (const std::exception& e) {
std::cout << e.what() << std::endl;
}
}
Run Code Online (Sandbox Code Playgroud)
对于在线程之间传递消息,我正在寻找具有以下属性的并发队列:
多个生产者,一个消费者.
该concurrent_bounded_queueTBB会提供,但我正在寻找替代方案,以避免TBB的额外的依赖.
该应用程序使用C++ 11和boost.我在找不到任何合适的东西.有什么选择?
在helgrind中运行官方boos asio示例代码的http async_client示例时,出现警告。文件中的这段代码boost/asio/detail/posix_event.hpp似乎是警告的原因:
// Signal the event and unlock the mutex.
template <typename Lock>
void signal_and_unlock(Lock& lock)
{
BOOST_ASSERT(lock.locked());
signalled_ = true;
lock.unlock();
::pthread_cond_signal(&cond_); // Ignore EINVAL.
}
Run Code Online (Sandbox Code Playgroud)
这是 valgrind/helgrind 的完整输出:
jcm@Ubuntu:~/samples/async-client/build$ valgrind --tool=helgrind ./async-client stackoverflow.com error.html
==2894== Helgrind, a thread error detector
==2894== Copyright (C) 2007-2011, and GNU GPL'd, by OpenWorks LLP et al.
==2894== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==2894== Command: ./async-client stackoverflow.com error.html
==2894==
==2894== ---Thread-Announcement------------------------------------------
==2894== …Run Code Online (Sandbox Code Playgroud)