Type detection: Difference between revisions

No edit summary
Line 128:
3 is a hexadecimal digit
</pre>
 
=={{header|C++}}==
{{trans|D}}
<lang cpp>#include <iostream>
 
template <typename T>
auto typeString(const T&) {
return typeid(T).name();
}
 
class C {};
struct S {};
 
int main() {
std::cout << typeString(1) << '\n';
std::cout << typeString(1L) << '\n';
std::cout << typeString(1.0f) << '\n';
std::cout << typeString(1.0) << '\n';
std::cout << typeString('c') << '\n';
std::cout << typeString("string") << '\n';
std::cout << typeString(C{}) << '\n';
std::cout << typeString(S{}) << '\n';
std::cout << typeString(nullptr) << '\n';
}</lang>
{{out}}
<pre>int
long
float
double
char
char [7]
class C
struct S
std::nullptr_t</pre>
 
=={{header|Crystal}}==
1,452

edits