Q:

Calculate some values using template size_t param

What is the C++ way to calculate some values using template params?
template<typename T, size_t SIZE>
class ThreadSafeArray
{
private:
    static const size_t BLOCK_SIZE = SIZE > 32 ? 16 : 4;
    static const size_t MUTEX_COUNT = SIZE / BLOCK_SIZE + 1;
    ...
};

or this
template<typename T, size_t SIZE>
class ThreadSafeArray
{
private:
    enum
    {
        BLOCK_SIZE = SIZE > 32 ? 16 : 4,
        MUTEX_COUNT = SIZE / BLOCK_SIZE + 1
    };
        ....
};

or somehow else?

A:

The enum hack is the old way to provide compile-time computations. It was used when in class initialization is not supportted by some compilers, so static const cannot be used. Nowadays its fixed in all modern compilers. 
So the preferred way is to use static const. 
Check this answer for more info.

