|
7 | 7 | #include "cpp2util.h"
|
8 | 8 |
|
9 | 9 |
|
| 10 | +#line 2 "pure2-interpolation.cpp2" |
| 11 | +class item; |
| 12 | + |
10 | 13 |
|
11 | 14 | //=== Cpp2 type definitions and function declarations ===========================
|
12 | 15 |
|
13 | 16 |
|
14 | 17 | #line 2 "pure2-interpolation.cpp2"
|
| 18 | +class item { |
| 19 | + public: [[nodiscard]] auto name() const& -> std::string; |
| 20 | + public: [[nodiscard]] auto color() const& -> std::string; |
| 21 | + public: [[nodiscard]] auto price() const& -> double; |
| 22 | + public: [[nodiscard]] auto count() const& -> int; |
| 23 | +}; |
| 24 | + |
15 | 25 | [[nodiscard]] auto main() -> int;
|
16 |
| - |
| 26 | + |
17 | 27 |
|
18 | 28 | //=== Cpp2 function definitions =================================================
|
19 | 29 |
|
20 | 30 |
|
21 |
| -#line 2 "pure2-interpolation.cpp2" |
| 31 | +#line 3 "pure2-interpolation.cpp2" |
| 32 | + [[nodiscard]] auto item::name() const& -> std::string { return "Dog kennel"; } |
| 33 | + [[nodiscard]] auto item::color() const& -> std::string { return "mauve"; } |
| 34 | + [[nodiscard]] auto item::price() const& -> double { return 3.14; } |
| 35 | + [[nodiscard]] auto item::count() const& -> int { return 42; } |
| 36 | + |
| 37 | +#line 9 "pure2-interpolation.cpp2" |
22 | 38 | [[nodiscard]] auto main() -> int{
|
23 |
| - auto x {0}; |
24 |
| - std::cout << "g" + cpp2::to_string(x) + "g" + cpp2::to_string(x) + "g" << "\n"; |
25 |
| - std::cout << cpp2::to_string(x) + "g" + cpp2::to_string(x) + "g" << "\n"; |
26 |
| - std::cout << cpp2::to_string(x) + "g" + cpp2::to_string(x) << "\n"; |
27 |
| - std::cout << cpp2::to_string(x) + cpp2::to_string(x) << "\n"; |
28 |
| - std::cout << "\"" + cpp2::to_string(x) + "\"" << "\n"; |
29 |
| - std::cout << "\"" + cpp2::to_string(x) << "\n"; |
30 |
| - std::cout << "\"" << "\n"; |
31 |
| - std::cout << "" << "\n"; |
32 |
| - std::cout << "pl(ug$h" << "\n"; |
33 |
| - std::cout << cpp2::to_string(std::move(x)) + "pl(ug$h" << "\n"; |
| 39 | +{ |
| 40 | +auto x = 0; |
| 41 | + |
| 42 | +#line 11 "pure2-interpolation.cpp2" |
| 43 | + { |
| 44 | + std::cout << "g" + cpp2::to_string(x) + "g" + cpp2::to_string(x) + "g" << "\n"; |
| 45 | + std::cout << cpp2::to_string(x) + "g" + cpp2::to_string(x) + "g" << "\n"; |
| 46 | + std::cout << cpp2::to_string(x) + "g" + cpp2::to_string(x) << "\n"; |
| 47 | + std::cout << cpp2::to_string(x) + cpp2::to_string(x) << "\n"; |
| 48 | + std::cout << "\"" + cpp2::to_string(x) + "\"" << "\n"; |
| 49 | + std::cout << "\"" + cpp2::to_string(x) << "\n"; |
| 50 | + std::cout << "\"" << "\n"; |
| 51 | + std::cout << "" << "\n"; |
| 52 | + std::cout << "pl(ug$h" << "\n"; |
| 53 | + std::cout << cpp2::to_string(x) + "pl(ug$h" << "\n"; |
| 54 | + |
| 55 | + } |
| 56 | +} |
| 57 | +{ |
| 58 | +auto x = item(); |
| 59 | + |
| 60 | +#line 25 "pure2-interpolation.cpp2" |
| 61 | + { |
| 62 | + std::cout << std::left << std::setw(20) << CPP2_UFCS_0(name, x) << " color " << std::left << std::setw(10) << CPP2_UFCS_0(color, x) << " price " << std::setw(10) << std::setprecision(3) << CPP2_UFCS_0(price, x) << " in stock = " << std::boolalpha << (cpp2::cmp_greater(CPP2_UFCS_0(count, x),0)) << "\n"; |
| 63 | + |
| 64 | + std::cout << cpp2::to_string(CPP2_UFCS_0(name, x), "{:20}") + " color " + cpp2::to_string(CPP2_UFCS_0(color, x), "{:10}") + " price " + cpp2::to_string(CPP2_UFCS_0(price, x), "{: <10.2f}") + " in stock = " + cpp2::to_string(cpp2::cmp_greater(CPP2_UFCS_0(count, std::move(x)),0)) + "\n"; |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +#line 31 "pure2-interpolation.cpp2" |
34 | 69 | }
|
35 | 70 |
|
0 commit comments