This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64588] New: [C++11] Wrong number of template arguments when template template parameter is template alias.
- From: "splinterofchaos at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 13 Jan 2015 23:16:48 +0000
- Subject: [Bug c++/64588] New: [C++11] Wrong number of template arguments when template template parameter is template alias.
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64588
Bug ID: 64588
Summary: [C++11] Wrong number of template arguments when
template template parameter is template alias.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: splinterofchaos at gmail dot com
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