File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -43,4 +43,12 @@ class lazyt
43
43
}
44
44
};
45
45
46
+ // / Delay the computation of \p fun to the next time the \c force method
47
+ // / is called.
48
+ template <typename valuet>
49
+ auto lazy (std::function<valuet()> fun) -> decltype(fun())
50
+ {
51
+ return lazyt<valuet>::from_fun (std::move (fun));
52
+ }
53
+
46
54
#endif // CPROVER_UTIL_LAZY_H
Original file line number Diff line number Diff line change @@ -16,8 +16,7 @@ SCENARIO("lazy test", "[core][util][lazy]")
16
16
++call_counter;
17
17
return s.length ();
18
18
};
19
- auto lazy_length =
20
- lazyt<int >::from_fun ([&]() { return length_with_counter (" foo" ); });
19
+ lazyt<int > lazy_length = lazy ([&] { return length_with_counter (" foo" ); });
21
20
22
21
REQUIRE (call_counter == 0 );
23
22
auto result = lazy_length.force ();
You can’t perform that action at this time.
0 commit comments