egcs support for local classes as template arguments

Don Waugaman dpw@cs.arizona.edu
Wed Dec 17 10:44:00 GMT 1997


When I try to compile the following program:

#include <algorithm>
#include <list>

int main(int argc, char** argv)
{
class Test
{
  public:
    void operator()(int) { } ;
};

    Test test_obj;
    list<int> test_list;

    for_each(test_list.begin(), test_list.end(), test_obj);
}

egcs responds with:

tst.cc: In function `int main(int, char **)':
tst.cc:18: type `main(int, char **)::Test' composed from a local class is not a valid template-argument

Oddly enough, using a local class as a template argument works fine with
gcc 2.7.2.1, the other compiler I have immediately at hand.  Did this have
to be changed due to the new template implementation, and will a fix have
to wait for e.g. namespace support?  (I ask the latter mostly because
main(int, char**)::Test looks an awful lot like a namespace declaration.)

The workaround is obvious - move the class definition outside the function -
and it works, but I was wondering if the use of local classes as template
arguments would be fixed any time soon.
-- 
    - Don Waugaman (dpw@cs.arizona.edu)    O-                  _|_  Will pun
Web Page: http://www.cs.arizona.edu/people/dpw/                 |   for food
In the Sonoran Desert, home of the phrase "It's a dry heat..."  |     <><
If tin whistles are made of tin, what are foghorns made of?



More information about the Gcc mailing list