-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathtest2.cxx
36 lines (28 loc) · 992 Bytes
/
test2.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "format.hxx"
int main() {
// The inner parts are opened up recursively until we hit something that's
// not array-like, and the format specifiers apply to these elements.
std::vector<float> x {
5 * M_PI,
M_PI,
M_PI / 5
};
// Print the array with default settings.
"Default settings = {x}\n"_print;
// Print the array in hexadecimal scientific notation.
"Hexadecimal array = {x:a}\n"_print;
// Print the array with width.precision specifiers. Center-justify the
// numbers and fill the 11-character width with '*' characters.
"Fill and width/prec = {x:*^11.2}\n"_print;
// Print the array with dynamic width.precision specifiers.
int y = 9;
int z = 12;
"Dynamic width/prec = {x:{y + 5}.{z / 4}}\n"_print;
// Initialize a linked list from the vector.
std::list<double> w {
x.begin(), x.end()
};
// Circle format prints linked lists like other array-like containrs.
"An std::list<double> = {w}\n"_print;
return 0;
}