[Bug c++/56842] New: Argument deduction failure note is empty for alias template
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Apr 4 14:30:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56842
Bug #: 56842
Summary: Argument deduction failure note is empty for alias
template
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
For this code:
#include <type_traits>
struct Base { };
template<typename T>
struct Constraint1
: std::enable_if<std::is_base_of<Base, T>::value>
{ };
template <typename T,
typename Requires = typename Constraint1<T>::type>
void foo() { }
struct A { };
int main()
{
foo<A>();
}
GCC gives an excellent diagnostic:
b.cc: In function 'int main()':
b.cc:18:12: error: no matching function for call to 'foo()'
foo<A>();
^
b.cc:18:12: note: candidate is:
b.cc:12:6: note: template<class T, class Requires> void foo()
void foo() { }
^
b.cc:12:6: note: template argument deduction/substitution failed:
b.cc:11:10: error: no type named 'type' in 'struct Constraint1<A>'
typename Requires = typename Constraint1<T>::type>
^
However after changing it to use an alias template, which makes the declaration
of bar() much easier to read:
#include <type_traits>
struct Base { };
template<typename T>
using Constraint2
= typename std::enable_if<std::is_base_of<Base, T>::value>::type;
template <typename T,
typename Requires = Constraint2<T>>
void bar() { }
struct A { };
int main()
{
bar<A>();
}
GCC produces a useless diagnostic:
b.cc: In function 'int main()':
b.cc:16:12: error: no matching function for call to 'bar()'
bar<A>();
^
b.cc:16:12: note: candidate is:
b.cc:10:6: note: template<class T, class Requires> void bar()
void bar() { }
^
b.cc:10:6: note: template argument deduction/substitution failed:
More information about the Gcc-bugs
mailing list