0

Is there a ready function which can take a template parameter as an argument and determine that it is a user defined types(class or struct) or built-in data types(int, float, char...) ?

goktug96
  • 21
  • 3

1 Answers1

0

You're looking for the std::is_arithmetic template, which determines if the template parameter is an integer or a floating point type.

By process of elimination, the only remaining options are: pointer or a reference, a class, and void. Maybe an enum of some kind, too. It's unclear from your question how you want to classify those, but, if necessary, adding some additional checks on top of std::is_arithmetic should make it possible to disambiguate the given type further.

Sam Varshavchik
  • 114,536
  • 5
  • 94
  • 148
  • Note `std::is_fundamental` covers `void` and `std::nullptr_t` in addition to arithmetic types. On top of that, there are arrays, pointers & member pointers, and references. It might be easier starting from `is_class` and `is_union` and checking whether those fail, plus removing cv-qualifiers and pointers and/or references, depending on what exactly the OP wants. – chris Feb 01 '17 at 15:19