Skip to content

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

@tivek

Description

@tivek

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):

// compile with -std=c++1z
#include <boost/hana/tuple.hpp>
#include <tuple>

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<int, double, const char *>' decomposes into 1 elements, but 3 names were provided
}

Is such an enhancement feasible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions