[cxx-abi-dev] Initializer Lists

Gabriel Dos Reis gdr at integrable-solutions.net
Mon Jun 9 23:40:26 UTC 2008


On Mon, Jun 9, 2008 at 4:37 AM, Jason Merrill <jason at redhat.com> wrote:
> 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

What I had done was to directly create a struct object { const T*, size_t len }
and internally `reinterpret_cast' it to initializer_list<T> so the
creation was `magic'.
but I think your proposal is also good.

-- Gaby



More information about the cxx-abi-dev mailing list