forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpure2-intro-example-three-loops.cpp
More file actions
64 lines (42 loc) · 1.79 KB
/
pure2-intro-example-three-loops.cpp
File metadata and controls
64 lines (42 loc) · 1.79 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
#define CPP2_INCLUDE_STD Yes
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
#line 1 "pure2-intro-example-three-loops.cpp2"
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "pure2-intro-example-three-loops.cpp2"
#line 2 "pure2-intro-example-three-loops.cpp2"
auto print(auto const& x) -> void;
#line 6 "pure2-intro-example-three-loops.cpp2"
auto decorate_and_print(auto& x) -> void;
#line 11 "pure2-intro-example-three-loops.cpp2"
[[nodiscard]] auto main() -> int;
#line 31 "pure2-intro-example-three-loops.cpp2"
#line 1 "pure2-intro-example-three-loops.cpp2"
//=== Cpp2 function definitions =================================================
#line 1 "pure2-intro-example-three-loops.cpp2"
#line 2 "pure2-intro-example-three-loops.cpp2"
auto print(auto const& x) -> void{
std::cout << ">> " << x << "\n";
}
#line 6 "pure2-intro-example-three-loops.cpp2"
auto decorate_and_print(auto& x) -> void{
x = "[" + x + "]";
print(x);
}
#line 11 "pure2-intro-example-three-loops.cpp2"
[[nodiscard]] auto main() -> int{
std::vector<std::string> words {
"hello", "big", "world"};
std::span<std::string> view {words};
auto i {cpp2_new<int>(0)};
for( ; cpp2::impl::cmp_less(*cpp2::impl::assert_not_null(i),CPP2_UFCS(ssize)(view)); ++*cpp2::impl::assert_not_null(i) ) {
print(CPP2_ASSERT_IN_BOUNDS(view, *cpp2::impl::assert_not_null(i)));
}
do {
std::cout << std::setw(4) << "**";
} while ( [&]{ --*cpp2::impl::assert_not_null(i) ; return true; }() && cpp2::impl::cmp_greater(*cpp2::impl::assert_not_null(i),0));
std::cout << "\n";
for ( auto& word : cpp2::move(words) )
decorate_and_print(word);
print(std::string{"end of program"});
}