@@ -320,7 +320,7 @@ size() const
320320{
321321 std::size_t result = 0 ;
322322 MapFnType mapFn =
323- [&result, this ](std::string_view name, dom::Value const &)
323+ [&result, this ](std::string_view name, auto const & /* value or deferred */ )
324324 {
325325 result += !overlay_.exists (name);
326326 };
@@ -348,7 +348,7 @@ exists(std::string_view key) const
348348 }
349349 bool result = false ;
350350 MapFnType mapFn =
351- [&result, key](std::string_view name, dom::Value const &)
351+ [&result, key](std::string_view name, auto const & /* value or deferred */ )
352352 {
353353 if (!result && name == key)
354354 {
@@ -379,20 +379,36 @@ get(std::string_view key) const
379379 return overlay_.get (key);
380380 }
381381 Value result;
382- MapFnType mapFn = [&result, key](std::string_view name, dom::Value const & value) {
383- if ( result. isUndefined () && name == key )
382+ IOType io (
383+ [& result, key, this ](std::string_view name, auto const & value )
384384 {
385- result = value;
386- }
387- };
388- DeferFnType deferFn = [&result, key](std::string_view name,
389- std::function<dom::Value ()> const & deferred) {
390- if (result.isUndefined () && name == key)
385+ if (result.isUndefined () && name == key)
386+ {
387+ if constexpr (HasValueFromWithContext<std::remove_cvref_t <decltype (value)>, Context>)
388+ {
389+ ValueFrom (value, context_, result);
390+ }
391+ else
392+ {
393+ ValueFrom (value, result);
394+ }
395+ }
396+ },
397+ [&result, key, this ](std::string_view name, auto const & deferred)
391398 {
392- result = deferred ();
393- }
394- };
395- IOType io (mapFn, deferFn, context_);
399+ if (result.isUndefined () && name == key)
400+ {
401+ if constexpr (HasValueFromWithContext<std::remove_cvref_t <decltype (deferred ())>, Context>)
402+ {
403+ ValueFrom (deferred (), context_, result);
404+ }
405+ else
406+ {
407+ ValueFrom (deferred (), result);
408+ }
409+ }
410+ },
411+ context_);
396412 if constexpr (HasLazyObjectMapWithContext<T, Context>)
397413 {
398414 tag_invoke (LazyObjectMapTag{}, io, *underlying_, context_);
0 commit comments