What primitive will S be then? Your main() is still broken.
For compile-time type recognition you can use template specialisation. You may not grasp it at once, but here is a hint:
Code:
template <typename T>
class is_fundamental {
public:
static const bool result = false;
};
template <>
class is_fundamental<char> {
public:
static const bool result = true;
};
template <>
class is_fundamental<int> {
public:
static const bool result = true;
};
You need to provide specialisation for every primitive. Then you can easily check whether given type is fundamental (unfortunately, this is done at run-time):
Code:
if (is_fundamental<int>::result)
{
// int is a fundamental type
}
I do not even want to mention that all your classes will also need (partial) specialisation.
Shortly: you need a better (easier that is) way of doing whatever you want to do now.