Is a template alias a conductive internal and external parameter unmanaged context?

The problem arose from here - I wanted to create an approach that solves a more general problem. Consider an example:

#include <utility>

template<class T, std::size_t>
using deduced = T;

template<std::size_t N, class = std::make_index_sequence<N>>
struct Foo;

template<std::size_t N, std::size_t... Is>
struct Foo<N, std::index_sequence<Is...>>{
    template <class... Args>
    void Bar(deduced<Args, Is>...)
    {  }
};

int main() {
   Foo<3> myfoo;
   myfoo.Bar(true, 2.0f, 3); // OK
   //myfoo.Bar(1, 2, 3, 4); // error
}

clang has no problems compiling code, gcc, on the other hand, shows the following errors:

prog.cc: In function 'int main()':
prog.cc:18:27: error: no matching function for call to 'Foo<3ul>::Bar(bool, float, int)'
    myfoo.Bar(true, 2.0f, 3); // valid
                           ^
prog.cc:12:10: note: candidate: template<class ... Args> void Foo<N, std::integer_sequence<long unsigned int, Is ...> >::Bar(deduced<Args, Is>...) [with Args = {Args ...}; long unsigned int N = 3ul; long unsigned int ...Is = {0ul, 1ul, 2ul}]
     void Bar(deduced<Args, Is>...)
          ^~~
prog.cc:12:10: note:   template argument deduction/substitution failed:
prog.cc:18: confused by earlier errors, bailing out

[live demo]

Which confuses me, gcc does not have a problem with subtraction when using the same alias, but the external parameter package is not involved, for example:

void Bar(deduced<Args, 0>...)

So, the question is, is it legal to combine parameter packages from the external and internal class with an alias of this form to force the compiler to output one of the template parameters or is it a gcc error?

Edit (based on bogdan comment) :

MSVC (2017 RC), EDG, icc ( 16 17) , , . , ( bogdan) - clang, , (?)

+4

Source: https://habr.com/ru/post/1661887/


All Articles