C++ 增强C++;线程本地存储向量
我正在为多线程创建一个tls向量,我想知道如何访问向量元素 基本上,我创建了:C++ 增强C++;线程本地存储向量,c++,multithreading,boost,vector,thread-local-storage,C++,Multithreading,Boost,Vector,Thread Local Storage,我正在为多线程创建一个tls向量,我想知道如何访问向量元素 基本上,我创建了: static boost::thread_specific_ptr< std::string > temp_str; static boost::thread_specific_ptr< std::vector< std::string > > _Vector_; 有什么建议吗? 谢谢:)这不是问题的原因,但标识符\u Vector\u是保留的。每个名称包含一个双下划线(u)或
static boost::thread_specific_ptr< std::string > temp_str;
static boost::thread_specific_ptr< std::vector< std::string > > _Vector_;
有什么建议吗?
谢谢:)这不是问题的原因,但标识符
\u Vector\u
是保留的。每个名称包含一个双下划线(u)或以下划线开头,后跟一个大写字母(2.11)的,都保留给实现以供任何使用。每个以下划线开头的名称都保留给实现,以用作全局命名空间中的名称。有趣的是…不知道这一点。另外,我想出了一个解决方案,那就是使用at()方法。So:Vector->get().at(i)
void myFunc()
{
//I need to assign _Vector[i]_ to temp_str
*temp_str = _Vector_.get()[i]; //I know this is an error
}