Boost logo

Boost :

From: Tom Howard (tomhoward_at_[hidden])
Date: 2002-08-20 10:21:44


> > > gcc fails to compile following code:
> > >
> > > // ****************** start ******************
> > > template<typename FPT, typename ToleranceSource>
> > > inline bool
> > > compare_and_continue_impl( FPT left, FPT right, ToleranceSource
> > > tolerance_src )
> > > {
> > > close_at_tolerance<FPT> pred( tolerance_src );
> > > }
> > > // ****************** end ******************
> > >
> > > Here an error:
> > > a.cpp: In function `bool compare_and_continue_impl(FPT, FPT,
> > > ToleranceSource)':
> > > a.cpp:6: parse error before `>' token
> > >
> > > Does it correct?
> >
> > "Is it correct?" Quite possibly. If that's the whole translation unit,
>
> then
>
> > yes, it's quite correct. There's no definition for close_at_tolerance.
>
> But compare_and_continue_impl is not called. and should not be instantiated
> accordingly, isn't it?

I'm pretty new to boost and I haven't don't a lot of template programming. I
might be completely wrong but replacing

    close_at_tolerance<FPT> pred( tolerance_src );

with

    template close_at_tolerance<FPT> pred( tolerance_src );

may solve the problem. I remember coming across a very similar problem in
code I was working on a few months ago and I think this is how I solved it.
I might be completely wrong

>From my understanding, gcc isn't actually instatiating the
compare_and_continue_impl template, it's just in the process of parsing the
code itself when it produces the parse error.

Hope the above helps.

Cheers,

Tom Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk