C++ Logo

STD-DISCUSSION

Advanced search

Subject: tuples containing rvalue types
From: Zoe Carver (z.zoelec2_at_[hidden])
Date: 2019-05-04 22:39:34


Lvalue tuples do not interact well with rvalue types. For example:

int main()

{

    int x = 42;

    std::tuple<int&&, int&&> t(std::move(x), std::move(x));

    auto p = std::make_from_tuple<std::pair<int&&, int&&>>(t);

}

The above code fails to compile because the tuple values are not properly
forwarded to make_from_tuple.

Another example of this is in tuple_cat where the following will fail to
compile:

int main()

{

    int x = 42;

    std::tuple<int&&> t(std::move(x));

    auto t2 = std::tuple_cat(t);

}

I think there are probably other instances where similar problems could be
found in the standard library.

I brought this up in the discussion so I could get feedback before
submitting an LWG issue.

Thanks in advance,

Zoe



STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups