I'm trying to use type traits like in "Modern C++ Design" using a template to determine if a type has a variable size or not. e.g. a string requires variable size storage, an int has fixed-size storage. This code works on Microsoft C++, now I'm porting to mac and I get the error:
explicit specialization is not allowed in the current scope
What's the correct way to specialize this?
template <typename T>
class MyTypeTraits
{
template<class U> struct VariableLengthStorageTraits
{
enum { result = false };
};
template<> struct VariableLengthStorageTraits<std::wstring>
{
enum { result = true };
};
public:
enum{ IsVariableLengthType = VariableLengthStorageTraits<T>::result };
};