boostorg / boostorg/hana

[Tuple] C++17 structured bindings with hana::tuple

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

Description

C++17 introduces structured bindings, a way to initialize multiple separate variables using std::tuple, std::pair, or any "simple" class with all-public non-static data members.

hana::tuple strives to provide an interface similar to std::tuple, so it would be useful to have it "just work" with the new structured bindings syntax. With Boost 1.63.0 the following example does not compile on clang version 4.0.0 (trunk 291432):

```C++
// compile with -std=c++1z
#include
#include

int main()
{
// std::tuple OK
auto [a, b, c] = std::make_tuple(1, 3.14, "Hello");

// hana::tuple errors out
auto [d, e, f] = boost::hana::make_tuple(1, 3.14, "Hello");
// error: type 'boost::hana::tuple' decomposes into 1 elements, but 3 names were provided
}
```

Is such an enhancement feasible?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the example from boost/hana/tuple.hpp with Clang using -std=c++1z, then inspect hana::tuple's tuple-like interface and relevant customization points. Done means the three structured-binding examples compile and bind the expected values; no specific test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.