Starting to add per-thread caches to the allocator

Trying to add a generic PerThread class has involved
a journey into the wonderful world of template programming,
including C++11 variadic templates.