The following code compiles and runs just fine on gcc 4.9.3 and clang 3.7.1
// std::unique_ptr
#include
// Template class for template-templa
This is CWG issue 1244:
The example in 14.4 [temp.type] paragraph 1 reads in significant part,
template<template<class> class TT> struct X { }; template<class> struct Y { }; template<class T> using Z = Y<T>; X<Y> y; X<Z> z;
and says that
y
andz
have the same type.This would only be true if alias template
Z
were considered to be equivalent to class templateY
. However, 14.5.7 [temp.alias] describes equivalence only for specializations of alias templates, not for the alias templates themselves. Either such rules should be specified, which could be tricky, or the example should be deleted.
We can reduce your example down to:
std::unique_ptr<Base<double, Buz>> f =
std::make_unique<Base<double, Bar>>();
This is well formed if and only if Buz
and Bar
are considered equivalent. gcc thinks they are, clang thinks they aren't. It's still an open question as to what the actual answer is.