std::initializer_list construction

David Krauss potswa@gmail.com
Mon Feb 16 08:46:00 GMT 2015


I’m implementing C++ proposal N4166, “Movable initializer lists.” It defines a class derived from initializer_list. What is the best way to initialize such an object?

Currently, the construction of initializer_list objects is a bit odd. They are not aggregates, because the fields are private, but they are constructed using a CONSTRUCTOR node. Despite this, the library defines a private C++ constructor with a misleading comment that the compiler is able to call it.

I tried adding base-class fields to the derived-class constructor node, but that doesn’t seem to work. Is aggregate initialization still viable?

I tried forming a call expression using build_special_member_call and build_cplus_new. That works, but it still complains that the constructor is private despite the LOOKUP_PROTECT flag being unset. If the library constructor is necessary, how can it live up to its promise?

Thanks!


More information about the Gcc mailing list