No default function template arguments?

Eric Lemings eric@lemings.com
Thu Apr 3 17:52:00 GMT 2003


[elemings@cyberia core]$ more Test01.cpp

#include <list>

class Foo { };

template <class T>
struct Pred {
  bool operator () (const Foo* f) {
    return (dynamic_cast<T*> (f) != NULL);
  }
};

typedef std::list<Foo*> FooList;

template <class T, class P = Pred<T> >
bool findFoo (const FooList& fooList) {

  return (false);
}

[elemings@cyberia core]$ g++ -g -Wall -frepo -c Test01.cpp
Test01.cpp:16: default template arguments may not be used in function
templates

WTF?  It's right there in Stroustrup, Chp. 13, Sect. 4.1.



More information about the Gcc-help mailing list