Reputation: 17138
Is there a function which would return (during compilation of metaprogram) in some form (List) a list of all available primitive types? Thanks
Upvotes: 0
Views: 4467
Reputation: 99665
The full list of Fundamental types you can find in C++ Standard §3.9.1:
char
signed char
short int
int
long int
unsigned char
unsigned short int
unsigned int
unsigned long int
wchar_t
bool
float
double
long double
void
Note that plain char
, signed char
, and unsigned char
are three distinct types. C++ Standard also defines size_t
and ptrdiff_t
(they're not fundamental though).
You can expect that every standard conformant compiler will support all these types. Each specific compiler can support more additional types supported as an extension.
Upvotes: 4
Reputation: 46647
There isn't - runtime introspection of this kind is not common nor possible nor useful in C++ (what would you do with a runtime function that gives you a list of the type names that you actually need to write your code in the first place?).
The primitive types supported by the language are:
bool
(unsigned,signed) char
wchar_t
(unsigned) short
(unsigned) int
(unsigned) long
[(unsigned) long long]
float
double
[long double]
Individual compilers support more, and many types are commonly available but implemented by means of typedefing the above primitive types (i.e. uint32_t
etc.).
For a full list, have a look at the language specification.
Upvotes: 5
Reputation: 26995
Incorrect question.
What is list of types? std::list<T>
? or array?
If it is std::list then what is T? T = "std::string"?
List of all types is described in C++ Standard.
bool
signed/unsigned char
signed/unsigned short int
signed/unsigned int
signed/unsigned long
size_t
wchar_t
float
double
Upvotes: 1