<div xmlns="http://www.w3.org/1999/xhtml">Hi,<br /><br />While experimenting with some heavily templated code I have faced with some problems. First of all, I do not understand whether my code should be compiled at all (because of processing of trailing parameters packs) and I have found nothing about it in C++17 standard draft. I tried 4 different compilers (with different front-ends) on godbolt: gcc, clang, icc, msvc.<br /><br />1) First question is about variadic templates and how they are expanded. Consider the following code:<br /><br /><span style="font-family:andale mono,times;">template<typename A> struct S {};<br /><br />template<typename T, typename...Rest><br />using U = S<T, Rest...>; // is it valid?<br /><br />using SI = U<int>; // seems, that there should be S<int> and there is nothing ill-formed</span><br /><br />The problem here is that only gcc (starting from version 7.1) is able to compile this code. Other compilers report that using directive is ill-formed because it provides too many template parameters for S. Who is right in this case?<br /><br />2) Second example is quite more complicated. The code is:<br /><br /><span style="font-family:andale mono,times;">template<typename A, typename B> struct S {};<br /><br />template<template<typename...> typename F><br />struct Flip {<br />  template<typename A, typename B, typename...Rest><br />  using Type = F<B, A, Rest...>;<br />};<br /><br />template<template<typename...> typename F, typename...Args><br />struct PartialApply {<br />  template<typename...Rest><br />  using Type = F<Args..., Rest...>;<br />};<br /><br />using X = typename PartialApply<Flip<S>::Type, int>::template Type<bool>; // there should be S<bool, int></span><br /><br />Now this can be compiled only by icc. Other compilers become mad and start to report very strange error. For example, gcc says that there is "pack expansion of 'B'" in Flip. clang and msvc produce similar error. Is this code valid C++ after all?<br /><br />Also if write similar code but in context of lambdas all compilers will work as expected. Does processing of variadic lambdas differ from processing of variadic templates?</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">I assume that some compilers are wrong and probably bugs should be filed but I'm not definitely sure. It will be very good if someone can explain whether these examples are valid or not and if not then why.</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">---</div><div xmlns="http://www.w3.org/1999/xhtml">Alexander</div><div xmlns="http://www.w3.org/1999/xhtml"> </div>