Skip to content

Instantly share code, notes, and snippets.

@tomspilman
Last active January 17, 2017 01:38
Show Gist options
  • Save tomspilman/856521da5affb4fb0e7633633b7a07cc to your computer and use it in GitHub Desktop.
Save tomspilman/856521da5affb4fb0e7633633b7a07cc to your computer and use it in GitHub Desktop.
class ThreadStaticBase
{
private:
int _tableSize;
int* _table;
System::Object** _store;
protected:
ThreadStaticBase();
System::Object** _address();
System::Object* _get();
System::Object* _set(System::Object* value);
public:
void remove();
};
template< typename T >
class ThreadStatic : public ThreadStaticBase
{
public:
ThreadStatic(T value) { }
T operator=(T value) { return (T)_set(value); }
operator T() { return (T)_get(); }
T* operator &() { return (T*)_address(); }
const T operator->() { return (T)_get(); }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment