C++ Logo

std-discussion

Advanced search

tuples containing rvalue types

From: Zoe Carver <z.zoelec2_at_[hidden]>
Date: Sat, 4 May 2019 20:39:34 -0700
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

Received on 2019-05-04 22:41:25