[Bug c++/39452] New: G++ cannot compile local classes together with template.
jim_king_2000 at 163 dot com
gcc-bugzilla@gcc.gnu.org
Fri Mar 13 06:41:00 GMT 2009
The following code cannot be compiled by GCC 4.3.3.
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
class PrintOne : unary_function<int, void>
{
public:
result_type operator()(argument_type i)
{
wcout << i << L'\n';
}
};
int a[20] = {0, 0, 0, 0, 0};
for_each(a, a + 20, PrintOne());
return 0;
}
The error message is:
test.cpp:22: error: no matching function for call to `for_each(int[20], int*,
main()::PrintOne)'
If we move class PrintOne outside or do not use template function, the
compilation will succeed.
--
Summary: G++ cannot compile local classes together with template.
Product: gcc
Version: 4.3.4
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jim_king_2000 at 163 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39452
More information about the Gcc-bugs
mailing list