umbrello 26.07.70-c53146a Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 auto some_strange_callable_type = std::bind(&some_function, _2, _1, some_object);
5 auto other_variable = 5;
6
7// #2
8 int some_int;
9 decltype(some_int) other_integer_variable = 5;
10
11// #3
12 for (auto itr = myvec.cbegin(); itr != myvec.cend(); ++itr) ;
13
14// #4
15 for (auto& x : myvec) ;
16
17// #5
18#include <vector>
19 int 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}
v
std::vector< std::string > v
Definition: cxx11-initializer-lists.h:19
x
int x
Definition: cxx11-lambda-functions-and-expressions.h:4
b
bool b
Definition: cxx11-null-pointer-constant.h:6
some_strange_callable_type
auto some_strange_callable_type
Definition: cxx11-type-inference.h:4
other_integer_variable
decltype(some_int) other_integer_variable
Definition: cxx11-type-inference.h:9
other_variable
auto other_variable
Definition: cxx11-type-inference.h:5
some_int
int some_int
Definition: cxx11-type-inference.h:8
main
int main()
Definition: cxx11-type-inference.h:19
a
QString a
Definition: petalnode.cpp:13