This question already has answers here:
How can I have non-static thread-local variable for each instance
                                
                                    (3个答案)
                                
                        
                                10天前关闭。
            
                    
我在C ++类thread_local unsigned int counter_ = 0;的私有部分中声明了thread_local,但不断收到错误消息“为counter_指定了存储类”

最佳答案

来自C ++ 17 Standard * 12.2类成员)


  9成员不得与外部人员一起宣布
  存储类规范。在班级定义内,会员不得
  用thread_local存储类规范声明,除非也
  声明为静态。

关于c++ - thread_local“指定的存储类” ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59275011/

10-10 19:33