I have the following code example:
template<int PARAM>
struct GetTypeByInt;
template<>
struct GetTypeByInt<0>
{
using type = int;
}
template<>
struct GetTypeByInt<1>
{
using type = float;
}
template<int PARAM>
struct SomeClass
{
static_assert((PARAM == 0) || (PARAM == 1), "Incorrect type.");
void doSomething();
};
template<int PARAM>
void SomeClassM<PARAM>::doSomething()
{
GetTypeByInt<PARAM>::type value;
...
}
This code works on the VS2017 without any problems, but on the Clang 10.0(XCode) I have the following error:
Unexpected type name 'type': expected expression
For example, if I remove one of the specialization of the GetTypeByInt<0> or GetTypeByInt<1>, it will work, but together it doesn't work. What's the problem?