The following code does not compile:
#include <list>
#include <utility>
using namespace std;
class A
{
typedef list < pair <int, int> > PairList;
// Works
void f1 ( list < pair <int, int> > arg = PairList() )
{
}
// Does not work
void f2 ( list < pair <int, int> > arg = list < pair <int, int> > () )
{
}
};
testcase.cpp:14: error: expected , or ... before > token
testcase.cpp:14: error: wrong number of template arguments (1, should be 2)
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/stl_pair.h:68:
error: provided for template<class _T1, class _T2> struct std::pair
testcase.cpp:14: error: template argument 1 is invalid
testcase.cpp:14: error: template argument 2 is invalid
testcase.cpp:14: error: default argument missing for parameter 2 of void
A::f2(std::list<std::pair<int, int>, std::allocator<std::pair<int, int> > >,
int)
--
Summary: Default argument of type list < pair < A, B > > compiles
only when typedef is used
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: photon at seznam dot cz
GCC host triplet: Ubuntu Linux 7.04
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33754