forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpure2-forward-return.cpp
More file actions
47 lines (29 loc) · 1.29 KB
/
pure2-forward-return.cpp
File metadata and controls
47 lines (29 loc) · 1.29 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
#define CPP2_INCLUDE_STD Yes
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
#line 1 "pure2-forward-return.cpp2"
//=== Cpp2 type definitions and function declarations ===========================
#line 1 "pure2-forward-return.cpp2"
#line 2 "pure2-forward-return.cpp2"
[[nodiscard]] auto first(auto&& rng) -> decltype(auto);
#line 7 "pure2-forward-return.cpp2"
extern int const global;
[[nodiscard]] auto f() -> int const&;
[[nodiscard]] auto main() -> int;
//=== Cpp2 function definitions =================================================
#line 1 "pure2-forward-return.cpp2"
#line 2 "pure2-forward-return.cpp2"
[[nodiscard]] auto first(auto&& rng) -> decltype(auto) {
if (cpp2::bounds_safety.is_active() && !(!(std::empty(rng))) ) { cpp2::bounds_safety.report_violation(""); }
#line 5 "pure2-forward-return.cpp2"
return *cpp2::impl::assert_not_null(std::begin(CPP2_FORWARD(rng))); }
int const global {42};
#line 8 "pure2-forward-return.cpp2"
[[nodiscard]] auto f() -> int const&{return global; }
#line 10 "pure2-forward-return.cpp2"
[[nodiscard]] auto main() -> int{
std::vector v {1, 2, 3};
first(v) = 4;
std::cout << first(cpp2::move(v)) << std::endl;// prints: 4
std::cout << f() << std::endl; // prints: 42
}