[PATCH] [libcxx] Delay evaluation of __make_tuple_types to prevent blowing the max template instantiation depth. Fixes Bug #18345

Howard Hinnant howard.hinnant at gmail.com
Wed Oct 1 09:16:43 PDT 2014

On Oct 1, 2014, at 12:00 AM, Arthur O'Dwyer <arthur.j.odwyer at gmail.com> wrote:

> On Tue, Sep 30, 2014 at 6:47 PM, Eric Fiselier <eric at efcs.ca> wrote:
>> http://reviews.llvm.org/D4467
> Incidentally, and sorry if this is a dumb question, but what's the
> rationale for libc++ allowing either
>    using A = std::array<double,3>;
>    A a;
>    std::tuple<A> t;
>    t = a;

The rationale for this is to support an extension which has been proposed for standardization here:


This proposal makes the tuple constructor taking U… implicit if all U… implicitly construct from all T….  This greatly aids (for example) in returning tuple types from factory functions:

std::tuple<int, int, int>
    return {3, 4, 5};

> or
>    using A = std::array<double,3>;
>    A a;
>    std::tuple<double,double,double> t;
>    t = a;

This is another extension.  This example would already work if A is pair, instead of std::array.  libc++ introduces the concept of “tuple-like”, and tuple cleanly interoperates with tuple-like types.  The set of tuple-like types are pair and array.  One might imagine making complex tuple-like as well.

See <__tuple> for the __tuple_like<T> trait which controls this behavior.

This extension has not been proposed for standardization.


More information about the cfe-commits mailing list