mercredi 30 novembre 2016

Strange behaviour of default template-argument in a template-templae-parameter

Consider this C++11 program:

#include <iostream>

template <class A, class B = char> struct Cont {
    Cont () { std::cout << sizeof(B); }
};

template <template<class, class = int> class C, class E> class Wrap1
{
    C<E> ce;
};

template <template<class, class = int> class C, class... E> class Wrap2
{
    C<E...> ce;
};

int main ()
{
    Wrap1<Cont, void> w1;
    Wrap2<Cont, void> w2;
}

When compiled with either gcc or clang, the output is 41.

Is this behaviour according to the standard? Where exactly does the standard specify it (for both Wrap1 and Wrap2)?

This question is inspired in part by this other question.

Aucun commentaire:

Enregistrer un commentaire