如何从字符串中强制转换Boost::thread::id

How to cast back Boost::thread::id from string?

本文关键字:Boost 转换 thread id 字符串      更新时间:2023-10-16

所以我将boost::lexical_cast<std::string>(boost::this_thread::get_id())这个线程id转换为string。现在我想知道是否有可能把它变成线程::id?

既然您提到调用->interrupt,我假定您需要boost::thread对象,而不是boost::thread:id对象。

您最好的选择可能是在生成线程时创建string - boost::thread对象的映射

我认为你可以使用'boost::lexical_cast'将字符串转换为int/short/the_type_you_want。它看起来像这样:

boost::lexical_cast<int>(string_of_thread_id);