Skip to content

Commit

Permalink
DNS parse: use expected{}.map() for rewrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
muggenhor committed Oct 24, 2018
1 parent b7e04b7 commit 2bb4f4d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dns/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ namespace dns
if (std::distance(first, last) < 2 + len)
return unexpected(parser_error::not_enough_data);
const auto next = std::next(first, 2 + len);
if (auto msg = parse(gsl::span{std::next(first, 2), next}); msg)
return std::make_pair(std::move(*msg), next);
else
return unexpected(std::move(msg).error());
return parse(gsl::span{std::next(first, 2), next})
.map(
[next] (auto&& msg) {
return std::make_pair(std::forward<decltype(msg)>(msg), next);
});
}
}

Expand Down

0 comments on commit 2bb4f4d

Please sign in to comment.