C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: List initialize from tuple
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2021-02-13 02:01:58


On Sat, 13 Feb 2021 at 09:50, Jefferson Carpenter via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> Hey, I just had some code that I wanted to write where I list initialize
> a struct from a tuple.
>
> Of course C++ has std::make_from_tuple, but this uses direct
> initialization. That is
>
> struct Foo {
> int a;
> int b;
> };
>
> cannot be initialized using std::make_from_tuple<Foo, std::tuple<int, int>>.

In C++20, doing make_from_tuple<X> works out of the box:
https://wandbox.org/permlink/qlByUwVZlmLRgsZ3

because C++20 has https://wg21.link/p0960

You're welcome. :)


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups