http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57314
Bug ID: 57314
Summary: [SFINAE] GCC istantiates default-arguments for
member-template-functions of classtemplates bevore
allowed
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
GCC rejects the following code:
#include <type_traits>
template<bool bar> struct foo{
template<typename T, typename = typename std::enable_if<bar>::type>
void fun(T){}
};
int main(){
foo<false> var{};
}
The error claims: “error: no type named 'type' in 'struct std::enable_if<false,
void>”. Which is certainly true but according to my reading of the standard
perfectly OK, because the default-arguments of templates must not be
instantiated before usage:
Section 14.7.1:
“...The implicit instantiation of a class template specialization causes the
implicit instantiation of the declarations, but not of the definitions or
default arguments, of the class member functions, member classes, scoped member
enumerations, static data members and member templates;...“