@perm & @roystgnr - shouldn't this be some 'meta type' that is guaranteed to be bigger than <T>?

I know I'm being pedantic, but conceivably this could be called with a wchar_t or even a char32_t.

I'd say either 

1. just make temp a std::vector<int> because latency will probably trump bandwidth for all conceivable use cases, or
2. assert that sizeof(T) <= sizeof(short int)

-Ben