In C++, is it possible to check (preferably at compile time) if a function argument reference value is thread-local?
E.g.
void foo( int& bar ) { ... }
I'd like to check/enforce that bar refer to a thread_local.
Assume C++17 or later on Windows and/or Fedora.
this bit of evil uses a lambda to create a thread local object within the
thread_local_decl_tthat is unique to each use site. We can pass thread local values around and verify they are indeed thread local with the C++ type system by doing athread_local_t<int>.thread_local_t<X>is a reference to a thread local value, whileauto name = THREAD_LOCAL(X)(construction arguments)declares a thread local value, using this system.Requires c++20.