#include namespace N { struct S { std::string str; }; extern thread_local S * ptd; inline S * get_ptd () { if (! ptd) ptd = new S; return ptd; } } // namespace N