umbrello 2.34.70-5524f40e1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
cxx11-type-inference.h
Go to the documentation of this file.
1// https://en.wikipedia.org/wiki/C%2B%2B11#Type_inference
2
3// #1
4auto some_strange_callable_type = std::bind(&some_function, _2, _1, some_object);
6
7// #2
10
11// #3
12for (auto itr = myvec.cbegin(); itr != myvec.cend(); ++itr) ;
13
14// #4
15for (auto& x : myvec) ;
16
17// #5
18#include <vector>
19int main() {
20 const std::vector<int> v(1);
21 auto a = v[0]; // a has type int
22 decltype(v[1]) b = 1; // b has type const int&, the return type of
23 // std::vector<int>::operator[](size_type) const
24 auto c = 0; // c has type int
25 auto d = c; // d has type int
26 decltype(c) e; // e has type int, the type of the entity named by c
27 decltype((c)) f = c; // f has type int&, because (c) is an lvalue
28 decltype(0) g; // g has type int, because 0 is an rvalue
29}
std::vector< std::string > v
Definition: cxx11-initializer-lists.h:19
int x
Definition: cxx11-lambda-functions-and-expressions.h:4
bool b
Definition: cxx11-null-pointer-constant.h:6
auto some_strange_callable_type
Definition: cxx11-type-inference.h:4
decltype(some_int) other_integer_variable
Definition: cxx11-type-inference.h:9
auto other_variable
Definition: cxx11-type-inference.h:5
int some_int
Definition: cxx11-type-inference.h:8
int main()
Definition: cxx11-type-inference.h:19
QString a
Definition: petalnode.cpp:13