boostorg / boostorg/fusion

Alternative way to adapt struct?

Open
#252 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
50
Forks
68
PR merge metrics
No merged PRs in 30d

Description

Why not make it possible to adapt structures in an alternative way (not only through `BOOST_FUSION_ADAPT_STRUCT`)? For example, like this:
```
namespace demo
{
struct employee
{
std::string name;
int age;
};
}

// demo::employee is now a Fusion sequence
namespace boost { namespace fusion {
namespace adapted {
constexpr auto tie_members(const demo::employee& x) noexcept {
return std::tie(x.name, x.age);
}
}
}}
```

or, like this:
```
namespace demo
{
struct employee
{
std::string name;
int age;
constexpr auto tie_members() const noexcept {
return std::tie(name, age);
}
};
}
```
Does this fit into the Boost Fusion library? Does it make sense to create a PR? Even if no one uses this feature, it will somehow reduce the amount of code in https://github.com/boostorg/fusion/pull/243, and possibly speed up its review.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.