For a parametric class C, I want to get always the “primitive” type irrespective of pointer, const or reference modifiers.
template<typename __T>
class C
{
public:
typedef std::some_magic_remove_all<__T>::type T;
}
int main()
{
C<some_type>::type a;
}
For example, for some_type equal to:
int&int**int*&int const &&int const * const- and so on
I want a is always of type int. How can I achieve it?
I originally also stripped extents (arrays), but Johannes noticed that this causes ambiguities for
const char[], and the question doesn’t mention them. If we also want to strip arrays (see also ideas mentioned in the comments), the following doesn’t complicate things too much:or with a helper class but a single template parameter:
It is normal if all the variants start looking about the same 😉