|
| 1 | + |
| 2 | +#define CPP2_IMPORT_STD Yes |
| 3 | + |
| 4 | +//=== Cpp2 type declarations ==================================================== |
| 5 | + |
| 6 | + |
| 7 | +#include "cpp2util.h" |
| 8 | + |
| 9 | +#line 1 "pure2-function-body-reflection.cpp2" |
| 10 | + |
| 11 | +#line 2 "pure2-function-body-reflection.cpp2" |
| 12 | +class test; |
| 13 | + |
| 14 | + |
| 15 | +//=== Cpp2 type definitions and function declarations =========================== |
| 16 | + |
| 17 | +#line 1 "pure2-function-body-reflection.cpp2" |
| 18 | + |
| 19 | +#line 2 "pure2-function-body-reflection.cpp2" |
| 20 | +class test |
| 21 | + { |
| 22 | + public: [[nodiscard]] static auto one_liner(cpp2::impl::in<double> a, cpp2::impl::in<double> b, cpp2::impl::in<double> c) -> decltype(auto); |
| 23 | +struct return_list_ret { double r; float s; std::string t; }; |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +#line 6 "pure2-function-body-reflection.cpp2" |
| 28 | + public: [[nodiscard]] static auto return_list() -> return_list_ret; |
| 29 | +using branches_ret = double; |
| 30 | + |
| 31 | + |
| 32 | +#line 14 "pure2-function-body-reflection.cpp2" |
| 33 | + public: [[nodiscard]] static auto branches(cpp2::impl::in<double> a, cpp2::impl::in<double> b, cpp2::impl::in<double> c) -> branches_ret; |
| 34 | + |
| 35 | +#line 29 "pure2-function-body-reflection.cpp2" |
| 36 | + public: static auto binary_ops(double& a, cpp2::impl::in<double> b, cpp2::impl::in<double> c) -> void; |
| 37 | + |
| 38 | +#line 38 "pure2-function-body-reflection.cpp2" |
| 39 | + public: [[nodiscard]] static auto prefix() -> int; |
| 40 | + |
| 41 | +#line 48 "pure2-function-body-reflection.cpp2" |
| 42 | + public: static auto postfix(double& a) -> void; |
| 43 | + |
| 44 | +#line 54 "pure2-function-body-reflection.cpp2" |
| 45 | + public: [[nodiscard]] static auto qualified_ids() -> auto; |
| 46 | + public: test() = default; |
| 47 | + public: test(test const&) = delete; /* No 'that' constructor, suppress copy */ |
| 48 | + public: auto operator=(test const&) -> void = delete; |
| 49 | + |
| 50 | + |
| 51 | +#line 59 "pure2-function-body-reflection.cpp2" |
| 52 | +}; |
| 53 | + |
| 54 | +auto main() -> int; |
| 55 | + |
| 56 | +//=== Cpp2 function definitions ================================================= |
| 57 | + |
| 58 | +#line 1 "pure2-function-body-reflection.cpp2" |
| 59 | + |
| 60 | +#line 4 "pure2-function-body-reflection.cpp2" |
| 61 | + [[nodiscard]] auto test::one_liner(cpp2::impl::in<double> a, cpp2::impl::in<double> b, cpp2::impl::in<double> c) -> decltype(auto) { return (a + c) * b; } |
| 62 | + |
| 63 | +#line 6 "pure2-function-body-reflection.cpp2" |
| 64 | + [[nodiscard]] auto test::return_list() -> return_list_ret |
| 65 | + |
| 66 | + { |
| 67 | + cpp2::impl::deferred_init<double> r; |
| 68 | + cpp2::impl::deferred_init<float> s; |
| 69 | + cpp2::impl::deferred_init<std::string> t; |
| 70 | +#line 9 "pure2-function-body-reflection.cpp2" |
| 71 | + r.construct(42.0); |
| 72 | + s.construct(2.71828f); |
| 73 | + t.construct("e times pi"); |
| 74 | + return { std::move(r.value()), std::move(s.value()), std::move(t.value()) }; } |
| 75 | + |
| 76 | +#line 14 "pure2-function-body-reflection.cpp2" |
| 77 | + [[nodiscard]] auto test::branches(cpp2::impl::in<double> a, cpp2::impl::in<double> b, cpp2::impl::in<double> c) -> branches_ret |
| 78 | + |
| 79 | + { |
| 80 | + double r {3.14159}; |
| 81 | +#line 17 "pure2-function-body-reflection.cpp2" |
| 82 | + if (true) { |
| 83 | + r = r + a; |
| 84 | + } |
| 85 | + |
| 86 | + if (cpp2::impl::cmp_greater(a * b,c)) { |
| 87 | + r += sin(b); |
| 88 | + } |
| 89 | + else { |
| 90 | + r = c; |
| 91 | + }return r; |
| 92 | + } |
| 93 | + |
| 94 | +#line 29 "pure2-function-body-reflection.cpp2" |
| 95 | + auto test::binary_ops(double& a, cpp2::impl::in<double> b, cpp2::impl::in<double> c) -> void |
| 96 | + { |
| 97 | + a -= b * c + (1 << 2); |
| 98 | + bool test {[_0 = a, _1 = b, _2 = c]{ return cpp2::impl::cmp_less_eq(_0,_1) && cpp2::impl::cmp_less(_1,_2); }() && true || false}; |
| 99 | + auto x {1 & 2}; |
| 100 | + auto y {3 ^ 4}; |
| 101 | + auto z {5 | 6}; |
| 102 | + } |
| 103 | + |
| 104 | +#line 38 "pure2-function-body-reflection.cpp2" |
| 105 | + [[nodiscard]] auto test::prefix() -> int |
| 106 | + { |
| 107 | + auto a {-1}; |
| 108 | + auto b {+2}; |
| 109 | + if (!(true)) { |
| 110 | + return 0; |
| 111 | + } |
| 112 | + return cpp2::move(a) + cpp2::move(b); |
| 113 | + } |
| 114 | + |
| 115 | +#line 48 "pure2-function-body-reflection.cpp2" |
| 116 | + auto test::postfix(double& a) -> void |
| 117 | + { |
| 118 | + auto ptr {&a}; |
| 119 | + --++*cpp2::impl::assert_not_null(cpp2::move(ptr)); |
| 120 | + } |
| 121 | + |
| 122 | +#line 54 "pure2-function-body-reflection.cpp2" |
| 123 | + [[nodiscard]] auto test::qualified_ids() -> auto |
| 124 | + { |
| 125 | + std::vector<int> v {1, 2, 3}; |
| 126 | + return CPP2_UFCS(ssize)(cpp2::move(v)); |
| 127 | + } |
| 128 | + |
| 129 | +#line 61 "pure2-function-body-reflection.cpp2" |
| 130 | +auto main() -> int{} |
| 131 | + |
0 commit comments