This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: "default template arguments may not be used in function templates"
On Mon, Jul 04, 2005 at 11:52:15AM -0700, Travis Spencer wrote:
> On 7/4/05, Vincent Torri <Vincent.Torri@iecn.u-nancy.fr> wrote:
> >
> > Hello,
>
> Hey, Vincent.
>
> > I have the following class:
> >
> > template <typename T, typename Synchronizer = synchronizer::None, typename
> > Creator = T * (*)()>
> > class value_cache
> > {
> > ***
> >
> > public: //interface
> >
> > boost::shared_ptr<T> Get() const
> > {
> > Synchronizer synchronizer();
> >
> > ***
> > ***
> > }
> > };
> >
> > But gcc reports this error message at compile time:
> >
> > "default template arguments may not be used in function templates"
> >
> > for the declaration of synchronizer().
> >
> > I use gcc 3.3.4
>
Hi,
your example looks a bit strange to me:
"synchronizer" could either be a class or a namespace;
then in the member function Get of class value_cache
you redeclare synchonizer as a function (with no
arguments, and return type Synchronizer).
Is this really what you want?!
> You can't use the default arguments in the function declaration (see
> http://tinyurl.com/bvnbx).
But in the above example there is no *function* template?
Oliver