Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
auto Keyword Example
#include <iostream> #include <cmath> #include <typeinfo> template<class T, class U> auto add(T t, U u) -> decltype(t + u) // the return type is the type of operator+(T, U) { return t + u; } int main() { bool t = true; auto a = 1 + (int)t; std::cout << "type of a: " << typeid(a).name() << '\n'; auto b = 1.2 + 2.3; std::cout << "type of b: " << typeid(b).name() << '\n'; auto c = add(1, 1.2); std::cout << "type of c: " << typeid(c).name() << '\n'; auto d = true; std::cout << "type of d: " << typeid(d).name() << '\n'; float e = 1.2; auto f = e + (float)1.1; std::cout << "type of f: " << typeid(f).name() << '\n'; }
run
|
edit
|
history
|
help
0
C++ does not have reference-to-reference types
DESim Example with Hash Table
vector destruction - clang
test
regex
Rounding float to nearest 1000
unordered graphs search
Copy uint64 data into uint32 with padding
numeric_limits
mine