forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpure2-interpolation.cpp
More file actions
78 lines (57 loc) · 2.94 KB
/
pure2-interpolation.cpp
File metadata and controls
78 lines (57 loc) · 2.94 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#define CPP2_INCLUDE_STD Yes
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
#line 1 "pure2-interpolation.cpp2"
#line 2 "pure2-interpolation.cpp2"
class item;
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "pure2-interpolation.cpp2"
#line 2 "pure2-interpolation.cpp2"
class item {
public: [[nodiscard]] auto name() const& -> std::string;
public: [[nodiscard]] auto color() const& -> std::string;
public: [[nodiscard]] auto price() const& -> double;
public: [[nodiscard]] auto count() const& -> int;
};
[[nodiscard]] auto main() -> int;
//=== Cpp2 function definitions =================================================
#line 1 "pure2-interpolation.cpp2"
#line 3 "pure2-interpolation.cpp2"
[[nodiscard]] auto item::name() const& -> std::string { return "Dog kennel"; }
#line 4 "pure2-interpolation.cpp2"
[[nodiscard]] auto item::color() const& -> std::string { return "mauve"; }
#line 5 "pure2-interpolation.cpp2"
[[nodiscard]] auto item::price() const& -> double { return 3.14; }
#line 6 "pure2-interpolation.cpp2"
[[nodiscard]] auto item::count() const& -> int { return 42; }
#line 9 "pure2-interpolation.cpp2"
[[nodiscard]] auto main() -> int{
{
auto const& x{0};
#line 11 "pure2-interpolation.cpp2"
{
std::cout << "g" + cpp2::to_string(x) + "g" + cpp2::to_string(x) + "g" << "\n";
std::cout << "" + cpp2::to_string(x) + "g" + cpp2::to_string(x) + "g" << "\n";
std::cout << "" + cpp2::to_string(x) + "g" + cpp2::to_string(x) + "" << "\n";
std::cout << "" + cpp2::to_string(x) + cpp2::to_string(x) + "" << "\n";
std::cout << "\"" + cpp2::to_string(x) + "\"" << "\n";
std::cout << "\"" + cpp2::to_string(x) + "" << "\n";
std::cout << "\"" << "\n";
std::cout << "" << "\n";
std::cout << "pl(ug$h" << "\n";
std::cout << "" + cpp2::to_string(x) + "pl(ug$h" << "\n";
}
}
{
auto const& x{item()};
#line 25 "pure2-interpolation.cpp2"
{
std::cout << std::left << std::setw(20) << CPP2_UFCS(name)(x) << " color " << std::left << std::setw(10) << CPP2_UFCS(color)(x) << " price " << std::setw(10) << std::setprecision(3) << CPP2_UFCS(price)(x) << " in stock = " << std::boolalpha << (cpp2::impl::cmp_greater(CPP2_UFCS(count)(x),0)) << "\n";
std::cout << "" + cpp2::to_string(CPP2_UFCS(name)(x), "{:20}") + " color " + cpp2::to_string(CPP2_UFCS(color)(x), "{:10}") + " price " + cpp2::to_string(CPP2_UFCS(price)(x), "{: <10.2f}") + " in stock = " + cpp2::to_string(cpp2::impl::cmp_greater(CPP2_UFCS(count)(x),0)) + "\n";
}
}
#line 31 "pure2-interpolation.cpp2"
std::complex ri {1.2, 3.4};
std::cout << "complex: " + cpp2::to_string(cpp2::move(ri)) + "\n";// works on GCC 11.2+ and Clang 13+
// prints "customize me" on GCC 11.1 and Clang 12
}