Date: Tue, 14 Feb 2023 18:48:45 -0600
On Tue, 14 Feb 2023 at 18:35, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Tue, Feb 14, 2023 at 10:12 PM Gergely Nagy via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > std::vector<Trivial> t;
> > t.emplace_back(1, 2.0, "blah");
>
>
> I always used to use compound literals for this purpose:
>
> t.emplace_back( (Trivial){1,2.0,"blah"} );
>
Why, when you could just use aggregate initialization?
t.emplace_back( Trivial{1,2.0,"blah"} );
Strictly speaking I think these compound literals are only a feature
> of C, but every C++ compiler supports them.
>
> Ville posted "C++20 allows initializing aggregates with the
> parenthesized syntax", so does that mean we pretty much have compound
> literals in C++ except that we use the following syntax?
>
> Trivial(1,2.0,"blah")
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
std-proposals_at_[hidden]> wrote:
> On Tue, Feb 14, 2023 at 10:12 PM Gergely Nagy via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > std::vector<Trivial> t;
> > t.emplace_back(1, 2.0, "blah");
>
>
> I always used to use compound literals for this purpose:
>
> t.emplace_back( (Trivial){1,2.0,"blah"} );
>
Why, when you could just use aggregate initialization?
t.emplace_back( Trivial{1,2.0,"blah"} );
Strictly speaking I think these compound literals are only a feature
> of C, but every C++ compiler supports them.
>
> Ville posted "C++20 allows initializing aggregates with the
> parenthesized syntax", so does that mean we pretty much have compound
> literals in C++ except that we use the following syntax?
>
> Trivial(1,2.0,"blah")
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2023-02-15 00:48:58