Alasdair
Alasdair

Reputation: 14151

C++ Thread_local non-static member of class?

I'm trying to have one member variable of a class thread local. However it seems that thread_local in a class has to also be static..? But static would mean that all instances of that class share that variable. I want it so there can be different instances of the class, but for 1 of the member variables there is a different variable for each thread that has access to this object.

So how can I have a class object, that can be passed around, and one of its member variables is thread_local for this instance of the class (this object), but not for all instances of the class (all objects of this type)?

Upvotes: 2

Views: 1188

Answers (0)

Related Questions