-
Notifications
You must be signed in to change notification settings - Fork 267
Expand file tree
/
Copy pathmixed-bounds-safety-with-assert-2.cpp
More file actions
54 lines (34 loc) · 1.68 KB
/
mixed-bounds-safety-with-assert-2.cpp
File metadata and controls
54 lines (34 loc) · 1.68 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
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
#line 1 "mixed-bounds-safety-with-assert-2.cpp2"
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "mixed-bounds-safety-with-assert-2.cpp2"
#line 2 "mixed-bounds-safety-with-assert-2.cpp2"
[[nodiscard]] auto main() -> int;
#line 10 "mixed-bounds-safety-with-assert-2.cpp2"
auto add_42_to_subrange(auto& rng, cpp2::impl::in<int> start, cpp2::impl::in<int> end) -> void;
#line 23 "mixed-bounds-safety-with-assert-2.cpp2"
#include <vector>
#include <span>
#include <iostream>
//=== Cpp2 function definitions =================================================
#line 1 "mixed-bounds-safety-with-assert-2.cpp2"
#line 2 "mixed-bounds-safety-with-assert-2.cpp2"
[[nodiscard]] auto main() -> int{
std::vector<int> v {1, 2, 3, 4, 5};
add_42_to_subrange(v, 1, 3);
for ( auto const& i : cpp2::move(v) )
std::cout << i << "\n";
}
#line 10 "mixed-bounds-safety-with-assert-2.cpp2"
auto add_42_to_subrange(auto& rng, cpp2::impl::in<int> start, cpp2::impl::in<int> end) -> void
{
if (cpp2::bounds_safety.is_active() && !(cpp2::impl::cmp_less_eq(0,start)) ) { cpp2::bounds_safety.report_violation(""); }
if (cpp2::bounds_safety.is_active() && !(cpp2::impl::cmp_less_eq(end,CPP2_UFCS(ssize)(rng))) ) { cpp2::bounds_safety.report_violation(""); }
auto count {0};
for (
auto& i : rng ) { bool _for_break = false; do
if ([_0 = start, _1 = count, _2 = end]{ return cpp2::impl::cmp_less_eq(_0,_1) && cpp2::impl::cmp_less_eq(_1,_2); }()) {
i += 42;
} while (false); if (_for_break) { break; } ++count; }
}