boostorg / boostorg/hana

Conversion of non-copyable Struct to tuple

Open
#452 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.9k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

I have the following use case that converts a non-copyable Struct to tuple:

```cpp
#include
#include

struct person {
person (person const&) = delete;

std::string name;
unsigned short age;
};

BOOST_HANA_ADAPT_STRUCT(person , name, age);

int main()
{
auto t = boost::hana::to_tuple(std::declval());
return 0;
}
```

that fails to compile with the following error:

```
boost/hana/detail/ebo.hpp:73:40: error: use of deleted function 'person::person(const person&)'
: data_(static_cast(t))
```

Since I did not see any restriction in the documentation regarding copyability, I wonder if this is expected and/or could be worked around?

Contributor guide

Open the contributing guide

Research direction

Reproduce the example using boost/hana.hpp and inspect boost/hana/detail/ebo.hpp, especially the construction reached through boost::hana::to_tuple. Determine whether conversion of the adapted non-copyable person is intended to work, then define the expected behavior and verify it with a focused regression test or documentation update.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.