Skip to content

Commit 0ee0a47

Browse files
committed
fix unit tests
1 parent ebf6974 commit 0ee0a47

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/iceberg/util/lazy.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ class Lazy {
4545
public:
4646
template <typename... Args>
4747
requires std::invocable<decltype(InitFunc), Args...> &&
48-
std::same_as<std::invoke_result_t<decltype(InitFunc), Args...>,
49-
iceberg::Result<T>>
50-
iceberg::Result<T*> get(Args&&... args) const {
51-
iceberg::Result<T> result;
52-
std::call_once(
53-
flag, [&result, &args...]() { result = InitFunc(std::forward<Args>(args)...); });
54-
ICEBERG_ASSIGN_OR_RAISE(this->value, result);
48+
std::same_as<std::invoke_result_t<decltype(InitFunc), Args...>, Result<T>>
49+
Result<T*> get(Args&&... args) const {
50+
Result<T> result;
51+
std::call_once(flag, [&result, this, &args...]() {
52+
result = InitFunc(std::forward<Args>(args)...);
53+
if (result) {
54+
this->value = std::move(result.value());
55+
}
56+
});
57+
ICEBERG_RETURN_UNEXPECTED(result);
5558
return &value;
5659
}
5760

0 commit comments

Comments
 (0)