Skip to content

Alternative way to adapt struct? #252

@denzor200

Description

@denzor200

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 #243, and possibly speed up its review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions