Bug 64588 - [C++11] Wrong number of template arguments when template template parameter is template alias.
Summary: [C++11] Wrong number of template arguments when template template parameter i...
Status: RESOLVED DUPLICATE of bug 64587
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-13 23:16 UTC by splinterofchaos
Modified: 2015-01-14 11:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
The file producing the error (8.26 KB, text/plain)
2015-01-13 23:17 UTC, splinterofchaos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description splinterofchaos 2015-01-13 23:16:48 UTC
As far as I have been able to gather, and according to everyone I've asked, the following should be valid:


#include <utility>
 
template<class T>
using decay = typename std::decay<T>::type;

template<template<class...>class T, class...X>
struct Part {
  template<class...Y>
  using type = T<X..., Y...>;
};
 
template<template<class...>class T, template<class>class U>
struct UCompose {
  // Not ok!
  template<class X, class...Y>
  using type = T<U<X>, Y...>;
 
  //// Ok!
  //template<class X>
  //using type = T<U<X>>;
};
 
int main() {
  using IsInt = Part<std::is_same, int>;
  static_assert(IsInt::type<int>::value, "");    // Ok!
  using IsIntD = UCompose<IsInt::type, decay>;
  static_assert(IsIntD::type<int&>::value, "");  // Not ok.
}


The error is:


$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.9.1-16ubuntu6' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.1 (Ubuntu 4.9.1-16ubuntu6) 

$ g++ tmp.cpp --std=c++11 -Wall -Wextra -save-temps
tmp.cpp: In substitution of ‘template<template<class ...> class T, class ... X> template<class ... Y> using type = T<X ..., Y ...> [with Y = {typename std::decay<_Tp>::type, Y ...}; T = std::is_same; X = {int}]’:
tmp.cpp:16:29:   required from ‘struct UCompose<Part<std::is_same, int>::type, decay>’
tmp.cpp:27:23:   required from here
tmp.cpp:9:29: error: wrong number of template arguments (3, should be 2)
   using type = T<X..., Y...>;
                             ^
In file included from /usr/include/c++/4.9/bits/move.h:57:0,
                 from /usr/include/c++/4.9/bits/stl_pair.h:59,
                 from /usr/include/c++/4.9/utility:70,
                 from tmp.cpp:1:
/usr/include/c++/4.9/type_traits:922:12: error: provided for ‘template<class, class> struct std::is_same’
     struct is_same;
            ^


The message, "wrong number of template arguments" implies that three parameters are passed, but above it says "X = {int}" and "Y = {typename std::decay<_Tp>::type, Y ...}". The "Y ..." here should be empty; perhaps it comes from "UCompose::type", where again the "Y..." should be empty.

I have tried with gcc 4.8 and get the same error message. Attached is the output from -save-temps
Comment 1 splinterofchaos 2015-01-13 23:17:59 UTC
Created attachment 34440 [details]
The file producing the error

File didn't attach properly the first time.
Comment 2 Jonathan Wakely 2015-01-14 11:13:51 UTC
.

*** This bug has been marked as a duplicate of bug 64587 ***