Initializer Lists

Jason Merrill jason at redhat.com
Mon Jun 9 09:37:35 UTC 2008


The initializer list proposal

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2640.pdf
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2531.pdf 
(library changes only, the core changes are superceded by N2640)

involves some coordination between the compiler and the runtime library: 
the ABI needs to specify what interface the compiler uses to create a 
std::initializer_list<T>.

Past runtime library interfaces have used a "C" linkage function, but 
that doesn't really work for a template type, and any code that uses 
std::initializer_list must #include the <initializer_list> header first, 
so we don't have to worry about trying to synthesize the type inside the 
compiler.

I've been implementing this in g++, and currently have a private constructor

     initializer_list(const T* _a, size_t _l)

which the compiler invokes directly by suppressing access control over 
the call.

Any thoughts?

Jason



More information about the cxx-abi-dev mailing list