Skip to content

Provide adapter to store RESP3 maps in vector<pair<T, U>> - #434

Open
mzimbres wants to merge 1 commit into
boostorg:developfrom
mzimbres:433-support-more-map-containers
Open

Provide adapter to store RESP3 maps in vector<pair<T, U>>#434
mzimbres wants to merge 1 commit into
boostorg:developfrom
mzimbres:433-support-more-map-containers

Conversation

@mzimbres

Copy link
Copy Markdown
Collaborator

No description provided.

@mzimbres
mzimbres requested a review from anarthal July 25, 2026 15:25
@cppalliance-bot

cppalliance-bot commented Jul 25, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://434.redis.prtest3.cppalliance.org/libs/redis/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-08-01 21:24:54 UTC

@mzimbres
mzimbres force-pushed the 433-support-more-map-containers branch from c3a667f to 3df3448 Compare July 25, 2026 21:13
: result_(t)
{
if (result_) {
result_->value() = T{};

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think I will undo this change as it will break user code. We should not erase data on behalf of the user and removing this line makes it possible to the user to append data to the container. The problem is that it will break user code and cause weird errors since not all users clear response objects before passing them to asyc_exec. It is something hard to change now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree - I think we've settled on not clearing data for the other adapters, and clearing for this one seems confusing.

void on_node(Result& res, resp3::basic_node<String> const& nd, system::error_code& ec)
{
if (is_aggregate(nd.data_type)) {
auto const m = element_multiplicity(nd.data_type);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we require a multiplicity of exactly 2? What happens if the server sends us an array of 5 elements, for instance?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I wouldn't be so strict. By not requiring 2 the user would be able to read a RESP3 array into a vector<pair<U,V>>, which for odd sizes would let the last element undefined as you noticed. Perhaps you are correct and we should exit with expects_resp3_map, which might catch some usage errors earlier.

if (node.data_type != resp3::type::null) {
op.emplace(T{});
converter<T>::apply(op.value(), node, ec);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is technically missing a else { op.reset(); }

@anarthal

Copy link
Copy Markdown
Collaborator

This covers vector<pair<T, U>> nicely, but doesn't address the new C++23 associative containers, abseil or Boost.Unordered. After this gets merged, do you want me to try to come up with an approach that covers these, or are we not aiming to cover them?

@mzimbres
mzimbres force-pushed the 433-support-more-map-containers branch from 3df3448 to d7fe631 Compare August 1, 2026 21:19
@mzimbres

mzimbres commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

This covers vector<pair<T, U>> nicely, but doesn't address the new C++23 associative containers, abseil or Boost.Unordered. After this gets merged, do you want me to try to come up with an approach that covers these, or are we not aiming to cover them?

Sure, thanks. It might not be trivial as I think there isn't a single concept that covers all e.g. map containers optimally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants