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

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

- File List
- File Members

cxx11-uniform-initialization.h
Go to the documentation of this file.
1// https://en.wikipedia.org/wiki/C%2B%2B11#Uniform_initialization
2
3// #1
4 struct BasicStruct {
5 int x;
6 double y;
7};
8
9 struct AltStruct {
10 AltStruct(int x, double y) : x_{x}, y_{y} {}
11
12 private:
13 int x_;
14 double y_;
15};
16
17 BasicStruct var1{5, 3.2};
18 AltStruct var2{2, 4.3};
19
20// #2
21 struct IdString {
22 std::string name;
23 int identifier;
24};
25
26 IdString get_string() {
27 return {"foo", 42}; //Note the lack of explicit type.
28}
29
30// #3
31std::vector<int> the_vec{4};
x
int x
Definition cxx11-lambda-functions-and-expressions.h:4
the_vec
std::vector< int > the_vec
Definition cxx11-uniform-initialization.h:31
var1
BasicStruct var1
Definition cxx11-uniform-initialization.h:17
get_string
IdString get_string()
Definition cxx11-uniform-initialization.h:26
var2
AltStruct var2
Definition cxx11-uniform-initialization.h:18
AltStruct
Definition cxx11-uniform-initialization.h:9
AltStruct::AltStruct
AltStruct(int x, double y)
Definition cxx11-uniform-initialization.h:10
AltStruct::y_
double y_
Definition cxx11-uniform-initialization.h:14
AltStruct::x_
int x_
Definition cxx11-uniform-initialization.h:13
BasicStruct
Definition cxx11-uniform-initialization.h:4
BasicStruct::x
int x
Definition cxx11-uniform-initialization.h:5
BasicStruct::y
double y
Definition cxx11-uniform-initialization.h:6
IdString
Definition cxx11-uniform-initialization.h:21
IdString::name
std::string name
Definition cxx11-uniform-initialization.h:22
IdString::identifier
int identifier
Definition cxx11-uniform-initialization.h:23