40 template <
typename R,
typename... Args>
41 struct Trait<R (*)(Args...)> {
42 using ReturnType = R::value_type;
45 using T = Trait<
decltype(InitFunc)>::ReturnType;
48 template <
typename... Args>
49 requires std::invocable<
decltype(InitFunc), Args...> &&
50 std::same_as<std::invoke_result_t<
decltype(InitFunc), Args...>, Result<T>>
51 Result<std::reference_wrapper<T>> Get(Args&&... args)
const {
53 flag_, [
this, &args...]() { value_ = InitFunc(std::forward<Args>(args)...); });
54 ICEBERG_RETURN_UNEXPECTED(value_);
55 return std::ref(*value_);
59 mutable Result<T> value_ = Invalid(
"Lazy value has not been initialized");
60 mutable std::once_flag flag_;