boostorg / boostorg/pfr

Feature request: for_each_field multiple visitation

Open
#69 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
1.5k
Forks
176
Avg merge
5d 21h
Merged PRs (30d)
1

Description

Multiple visitation is easy enough to achieve with a library like Boost.Hana (see below), but I think it would be useful functionality for ```for_each_field``` to support directly.

```cpp
template
constexpr auto for_each_field(Invocable f, Aggregates&&... xs) -> void
{
namespace hana = boost::hana;
hana::for_each(hana::zip(boost::pfr::structure_tie(xs)...), hana::fuse(std::move(f)));
}
```
[Example on Compiler Explorer](https://godbolt.org/z/K9Krfh)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the for_each_field API and review the Boost.Hana-based multiple-visitation example in the issue, including the linked Compiler Explorer case. Determine how visitation across multiple aggregates should behave, then add coverage showing that the API invokes the callable for corresponding fields across the supplied objects.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.